chore(org): Updates for github data and account refresh
This commit is contained in:
parent
b3a21ad955
commit
cf26ba933a
7 changed files with 172 additions and 66 deletions
|
@ -10,6 +10,7 @@ import { LoadingContext } from 'shared/context/loading-context.mjs'
|
|||
// Components
|
||||
import { BackToAccountButton } from './shared.mjs'
|
||||
import { SaveSettingsButton } from 'shared/components/buttons/save-settings-button.mjs'
|
||||
import { Popout } from 'shared/components/popout/index.mjs'
|
||||
|
||||
export const ns = ['account', 'toast']
|
||||
|
||||
|
@ -24,12 +25,13 @@ export const GithubSettings = ({ title = false, welcome = false }) => {
|
|||
const toast = useToast()
|
||||
|
||||
// State
|
||||
const [github, setGithub] = useState(account.github || '')
|
||||
const [githubUsername, setGithubUsername] = useState(account.data.githubUsername || '')
|
||||
const [githubEmail, setGithubEmail] = useState(account.data.githubEmail || '')
|
||||
|
||||
// Helper method to save changes
|
||||
const save = async () => {
|
||||
startLoading()
|
||||
const result = await backend.updateAccount({ github })
|
||||
const result = await backend.updateAccount({ data: { githubUsername, githubEmail } })
|
||||
if (result.success) {
|
||||
setAccount(result.data.account)
|
||||
toast.for.settingsSaved()
|
||||
|
@ -40,17 +42,35 @@ export const GithubSettings = ({ title = false, welcome = false }) => {
|
|||
return (
|
||||
<div className="max-w-xl">
|
||||
{title ? <h2 className="text-4xl">{t('githubTitle')}</h2> : null}
|
||||
<div className="flex flex-row items-center mt-4">
|
||||
<label className="font-bold">{t('username')}</label>
|
||||
<div className="flex flex-row items-center mb-4">
|
||||
<input
|
||||
value={github}
|
||||
onChange={(evt) => setGithub(evt.target.value)}
|
||||
value={githubUsername}
|
||||
onChange={(evt) => setGithubUsername(evt.target.value)}
|
||||
className="input w-full input-bordered flex flex-row"
|
||||
type="text"
|
||||
placeholder={t('github')}
|
||||
placeholder={account.username}
|
||||
/>
|
||||
</div>
|
||||
<label className="font-bold">{t('email')}</label>
|
||||
<div className="flex flex-row items-center mb-4">
|
||||
<input
|
||||
value={githubEmail}
|
||||
onChange={(evt) => setGithubEmail(evt.target.value)}
|
||||
className="input w-full input-bordered flex flex-row"
|
||||
type="text"
|
||||
placeholder={`${account.username}@users.freesewing.org`}
|
||||
/>
|
||||
</div>
|
||||
<SaveSettingsButton btnProps={{ onClick: save }} />
|
||||
{!welcome && <BackToAccountButton loading={loading} />}
|
||||
<Popout note>
|
||||
<p className="text-sm font-bold">{t('githubWhy1')}</p>
|
||||
<p className="text-sm">{t('githubWhy2')}</p>
|
||||
<p className="text-sm">{t('githubWhy3')}</p>
|
||||
<p className="text-sm">{t('githubWhy4')}</p>
|
||||
<p className="text-sm">{t('tooComplex')}</p>
|
||||
</Popout>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue