import React from 'react'; import { useTranslation, i18n } from 'next-i18next'; import { i18n as i18nConfig } from '^/config/next-i18next.config'; import { toastSuccess, toastError } from '~/client/util/apiNotification'; import { useRegistrationWhiteList } from '~/stores/context'; import { usePersonalSettings } from '~/stores/personal-settings'; export const BasicInfoSettings = (): JSX.Element => { const { t } = useTranslation(); const { data: registrationWhiteList } = useRegistrationWhiteList(); const { data: personalSettingsInfo, mutate: mutatePersonalSettings, sync, updateBasicInfo, error, } = usePersonalSettings(); const submitHandler = async() => { try { await updateBasicInfo(); sync(); toastSuccess(t('toaster.update_successed', { target: t('Basic Info'), ns: 'commons' })); } catch (err) { toastError(err); } }; const changePersonalSettingsHandler = (updateData) => { if (personalSettingsInfo == null) { return; } mutatePersonalSettings({ ...personalSettingsInfo, ...updateData }); }; return ( <>
changePersonalSettingsHandler({ name: e.target.value })} />
changePersonalSettingsHandler({ email: e.target.value })} /> {registrationWhiteList != null && registrationWhiteList.length !== 0 && (
{t('page_register.form_help.email')}
    {registrationWhiteList.map(data =>
  • {data}
  • )}
)}
changePersonalSettingsHandler({ isEmailPublished: true })} />
changePersonalSettingsHandler({ isEmailPublished: false })} />
{ i18nConfig.locales.map((locale) => { if (i18n == null) { return } const fixedT = i18n.getFixedT(locale); return (
changePersonalSettingsHandler({ lang: locale })} />
); }) }
changePersonalSettingsHandler({ slackMemberId: e.target.value })} />
); };