Join-9df7f4fb.js.map (8291B)
1 {"version":3,"file":"Join-9df7f4fb.js","sources":["../../src/pages/Join.tsx"],"sourcesContent":["import React, { useState, useContext } from \"react\";\nimport { Client } from \"../context\";\nimport { Header } from \"../components/header\";\nimport { useNavigate } from \"react-router-dom\";\nimport { useTranslation } from \"react-i18next\";\n\nconst ACTIVE_TAB_CSS = \"inline-block p-4 w-full text-gray-900 bg-gray-100 hover:ring-blue-300 hover:ring-1 focus:ring-transparent focus:outline-none dark:bg-gray-700 dark:text-white\";\nconst TAB_CSS = \"inline-block p-4 w-full bg-white hover:text-gray-700 hover:bg-gray-50 hover:ring-blue-300 hover:ring-1 focus:ring-transparent focus:outline-none dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700\";\n\nexport default function Join() {\n const navigate = useNavigate();\n const client = useContext(Client);\n const [homeserver, setHomeserver] = useState(import.meta.env.VITE_MATRIX_SERVER_URL);\n const [username, setUsername] = useState(\"\");\n const [password, setPassword] = useState(\"\");\n const [createProfile, setCreateProfile] = useState(true);\n const [currentTab, setCurrentTab] = useState(\"login\");\n const { t } = useTranslation();\n\n const onSubmit = async (_e: React.FormEvent) => {\n if (!client) {\n return;\n }\n if (homeserver === \"\" || username === \"\" || password === \"\") {\n return;\n }\n if (currentTab === \"login\" && !client?.isLoggedIn()) {\n await client.login(homeserver, username, password, createProfile);\n } else if (currentTab === \"register\" && !client.isLoggedIn()) {\n await client.register(homeserver, username, password, createProfile);\n }\n navigate('/', { replace: true });\n }\n\n const onInput = (e: React.FormEvent) => {\n const target = (e.target as HTMLInputElement);\n const value = target.type === 'checkbox' ? target.checked : target.value;\n const name = target.name;\n switch (name) {\n case \"homeserver\": {\n setHomeserver(value as string);\n break;\n }\n case \"username\": {\n setUsername(value as string);\n break;\n }\n case \"password\": {\n setPassword(value as string);\n break;\n }\n case \"createProfile\": {\n setCreateProfile(value as boolean);\n break;\n }\n }\n }\n\n return (\n <div className=\"flex flex-col\">\n <header>\n <Header />\n </header>\n\n <main className=\"m-12 mt-6\">\n <h1 className=\"text-3xl font-bold mb-4 text-white\">{t('Join')}</h1>\n <div className=\"flex items-center flex-col\">\n <ul className=\"w-1/4 mb-8 hidden text-sm font-medium text-center text-gray-500 rounded-lg divide-x divide-gray-200 shadow sm:flex dark:divide-gray-700 dark:text-gray-400\">\n <li className=\"w-full\">\n <a href=\"#\" className={currentTab === \"login\" ? `${ACTIVE_TAB_CSS} rounded-l-lg` : `${TAB_CSS} rounded-l-lg`} onClick={(_e) => { setCurrentTab(\"login\"); }}>{t('Login')}</a>\n </li>\n <li className=\"w-full\">\n <a href=\"#\" className={currentTab === \"register\" ? `${ACTIVE_TAB_CSS} rounded-r-lg` : `${TAB_CSS} rounded-r-lg`} onClick={(_e) => { setCurrentTab(\"register\"); }}>{t('Register')}</a>\n </li>\n </ul>\n <form onSubmit={onSubmit} className=\"flex flex-col items-start w-1/4\">\n <input className=\"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder:text-data text-white mb-4 w-full\" type=\"url\" placeholder={t(\"Homeserver\") as string} name=\"homeserver\" value={homeserver} onInput={onInput} />\n <input className=\"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder:text-data text-white mb-4 w-full\" autoComplete=\"username\" type=\"text\" placeholder={t(\"Username\") as string} name=\"username\" value={username} onInput={onInput} />\n <input className=\"search-bg shadow rounded-lg border-0 py-3 px-4 placeholder:text-data text-white mb-4 w-full\" autoComplete=\"current-password\" type=\"password\" placeholder={t(\"Password\") as string} name=\"password\" value={password} onInput={onInput} />\n <label className=\"mb-4 flex items-center\">\n <input className=\"checked:bg-blue-600 checked:border-transparent checked:bg-no-repeat checked:bg-[url('/tick.svg')] outline-none focus:outline-offset-2 focus:ring-blue-600 focus:ring-offset-2 focus:ring-offset-white p-0 inline-block align-middle box-border select-none shrink-0 shadow h-5 w-5 appearance-none rounded bg-white border-none\" type=\"checkbox\" name=\"createProfile\" checked={createProfile} onChange={onInput} />\n <span className=\"ml-4 text-data text-base font-medium\">{t('Create account')}</span>\n </label>\n\n <button type=\"submit\" className=\"text-white font-bold text-lg logo-bg rounded-xl py-2 px-10 shadow transition-transform ease-in-out duration-300 hover:scale-105 w-1/2 self-center justify-center flex\">{currentTab === \"login\" ? t(\"Login\") : t(\"Register\")}</button>\n </form>\n </div>\n </main >\n </div >\n );\n}"],"names":["ACTIVE_TAB_CSS","TAB_CSS","Join","navigate","useNavigate","client","useContext","Client","homeserver","setHomeserver","useState","username","setUsername","password","setPassword","createProfile","setCreateProfile","currentTab","setCurrentTab","useTranslation","onSubmit","_e","onInput","e","target","value","jsxs","jsx","Header"],"mappings":"6GAMA,MAAMA,EAAiB,gKACjBC,EAAU,iNAEhB,SAAwBC,GAAO,CAC3B,MAAMC,EAAWC,IACXC,EAASC,aAAWC,CAAM,EAC1B,CAACC,EAAYC,CAAa,EAAIC,EAAS,SAAA,2CAAsC,EAC7E,CAACC,EAAUC,CAAW,EAAIF,WAAS,EAAE,EACrC,CAACG,EAAUC,CAAW,EAAIJ,WAAS,EAAE,EACrC,CAACK,EAAeC,CAAgB,EAAIN,WAAS,EAAI,EACjD,CAACO,EAAYC,CAAa,EAAIR,WAAS,OAAO,EAC9C,CAAE,GAAMS,IAERC,EAAW,MAAOC,GAAwB,CACvChB,IAGDG,IAAe,IAAMG,IAAa,IAAME,IAAa,KAGrDI,IAAe,SAAW,EAACZ,GAAA,MAAAA,EAAQ,cACnC,MAAMA,EAAO,MAAMG,EAAYG,EAAUE,EAAUE,CAAa,EACzDE,IAAe,YAAc,CAACZ,EAAO,cAC5C,MAAMA,EAAO,SAASG,EAAYG,EAAUE,EAAUE,CAAa,EAEvEZ,EAAS,IAAK,CAAE,QAAS,EAAM,CAAA,GAAA,EAG7BmB,EAAWC,GAAuB,CACpC,MAAMC,EAAUD,EAAE,OACZE,EAAQD,EAAO,OAAS,WAAaA,EAAO,QAAUA,EAAO,MAEnE,OADaA,EAAO,KACN,CACV,IAAK,aAAc,CACff,EAAcgB,CAAe,EAC7B,KACJ,CACA,IA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