mirror of
https://github.com/seerr-team/seerr.git
synced 2026-10-12 02:22:17 +00:00
* refactor: update Next.js and React.js * refactor: update Next.js images * refactor: update ESLint rules and fix warnings/errors * fix: remove old intl polyfill * fix: add proper size to next/image components * fix: adjust full-size for next/image components * fix: temporary allow all domains for image optimization * build: fixes an issue where dev env could lead to javascript heap out of memory * fix: resolve webpack cache issue with country-flag-icons * refactor: switch compiler from Babel to SWC * fix: resize logo in sidebar * fix: break word on long path to avoid text overflow * chore: added sharp for production image optimisation * fix: change extract script for i18n to a custom script * fix: resolve GitHub CodeQL alert * chore: temporarily remove builds for ARMv7 * fix: resize avatar images * refactor: update Node.js to v20 * fix: resolve various UI issues * build: migrate yarn to pnpm and restrict engine to node@^20.0.0 * ci: specify the pnpm version to use in workflow actions * ci: fix typo in pnpm action-setup for cypress workflow * test(cypress): use pnpm instead of yarn * style: ran prettier on pnpm-lock * ci(cypress): setup nodejs v20 in cypress workflow * ci: pnpm cache to reduce install time * ci: use sh shell to get pnpm store directory * build(dockerfile): migrate to pnpm from yarn in docker builds * build(dockerfile): copy the proper pnpm lockfile * build: install pnpm for all platforms * build(dockerfile): remove unnecessary `&&` on apk installation steps * build: migrate pnpm 8 to 9 * build(dockerfile): add node-gyp back in * build(dockerfile): install node-gyp through npm * build(dockerfile): ignore scripts to not run husky install when devdependencies are pruned * build: migrate to pnpm from yarn * chore: remove a section that is no longer relevant --------- Co-authored-by: fallenbagel <[email protected]>
115 lines
3.3 KiB
TypeScript
115 lines
3.3 KiB
TypeScript
import Modal from '@app/components/Common/Modal';
|
|
import useSettings from '@app/hooks/useSettings';
|
|
import defineMessages from '@app/utils/defineMessages';
|
|
import { Transition } from '@headlessui/react';
|
|
import axios from 'axios';
|
|
import { Field, Formik } from 'formik';
|
|
import { useIntl } from 'react-intl';
|
|
import * as Yup from 'yup';
|
|
|
|
const messages = defineMessages('components.Login', {
|
|
title: 'Add Email',
|
|
description:
|
|
'Since this is your first time logging into {applicationName}, you are required to add a valid email address.',
|
|
email: 'Email address',
|
|
validationEmailRequired: 'You must provide an email',
|
|
validationEmailFormat: 'Invalid email',
|
|
saving: 'Adding…',
|
|
save: 'Add',
|
|
});
|
|
|
|
interface AddEmailModalProps {
|
|
username: string;
|
|
password: string;
|
|
onClose: () => void;
|
|
onSave: () => void;
|
|
}
|
|
|
|
const AddEmailModal: React.FC<AddEmailModalProps> = ({
|
|
onClose,
|
|
username,
|
|
password,
|
|
onSave,
|
|
}) => {
|
|
const intl = useIntl();
|
|
const settings = useSettings();
|
|
|
|
const EmailSettingsSchema = Yup.object().shape({
|
|
email: Yup.string()
|
|
.email(intl.formatMessage(messages.validationEmailFormat))
|
|
.required(intl.formatMessage(messages.validationEmailRequired)),
|
|
});
|
|
|
|
return (
|
|
<Transition
|
|
appear
|
|
show
|
|
enter="transition ease-in-out duration-300 transform opacity-0"
|
|
enterFrom="opacity-0"
|
|
enterTo="opacuty-100"
|
|
leave="transition ease-in-out duration-300 transform opacity-100"
|
|
leaveFrom="opacity-100"
|
|
leaveTo="opacity-0"
|
|
>
|
|
<Formik
|
|
initialValues={{
|
|
email: '',
|
|
}}
|
|
validationSchema={EmailSettingsSchema}
|
|
onSubmit={async (values) => {
|
|
try {
|
|
await axios.post('/api/v1/auth/jellyfin', {
|
|
username: username,
|
|
password: password,
|
|
email: values.email,
|
|
});
|
|
|
|
onSave();
|
|
} catch (e) {
|
|
// set error here
|
|
}
|
|
}}
|
|
>
|
|
{({ errors, touched, handleSubmit, isSubmitting, isValid }) => {
|
|
return (
|
|
<Modal
|
|
onCancel={onClose}
|
|
okButtonType="primary"
|
|
okText={
|
|
isSubmitting
|
|
? intl.formatMessage(messages.saving)
|
|
: intl.formatMessage(messages.save)
|
|
}
|
|
okDisabled={isSubmitting || !isValid}
|
|
onOk={() => handleSubmit()}
|
|
title={intl.formatMessage(messages.title)}
|
|
>
|
|
{intl.formatMessage(messages.description, {
|
|
applicationName: settings.currentSettings.applicationTitle,
|
|
})}
|
|
<label htmlFor="email" className="text-label">
|
|
{intl.formatMessage(messages.email)}
|
|
</label>
|
|
<div className="mt-1 mb-2 sm:col-span-2 sm:mt-0">
|
|
<div className="flex rounded-md shadow-sm">
|
|
<Field
|
|
id="email"
|
|
name="email"
|
|
type="text"
|
|
placeholder={intl.formatMessage(messages.email)}
|
|
/>
|
|
</div>
|
|
{errors.email && touched.email && (
|
|
<div className="error">{errors.email}</div>
|
|
)}
|
|
</div>
|
|
</Modal>
|
|
);
|
|
}}
|
|
</Formik>
|
|
</Transition>
|
|
);
|
|
};
|
|
|
|
export default AddEmailModal;
|