diff --git a/src/app/[id]/create/page.tsx b/src/app/[id]/create/page.tsx index 760ea21..ec11781 100644 --- a/src/app/[id]/create/page.tsx +++ b/src/app/[id]/create/page.tsx @@ -9,14 +9,13 @@ import {Field, Form, Formik} from 'formik'; import {useRouter, useSearchParams} from 'next/navigation'; import {Button} from '@nextui-org/button'; import {NotFoundError} from '@/models/Errors'; -import {Table, TableBody, TableCell, TableColumn, TableHeader, TableRow} from '@nextui-org/table'; -import NumberInputWithButtons from '@/components/NumberInput'; import SuccessModal from '@/components/SuccessModal'; import {FaArrowAltCircleLeft, FaSave} from 'react-icons/fa'; import {Textarea} from '@nextui-org/input'; -import {validateBetweenZeroAndFive} from '@/utils/validationUtils'; import ErrorModal from '@/components/ErrorModal'; import {Spinner} from '@nextui-org/react'; +import ContactInformationForm from '@/components/ContactInformationForm'; +import ReleasePatternForm from '@/components/ReleasePatternForm'; export default function Page({params}: { params: { id: string } }) { const router = useRouter(); @@ -129,177 +128,16 @@ export default function Page({params}: { params: { id: string } }) { }) => (
-
-

Kontaktinformasjon

- - - - - - - - - - - -
+

Utgivelsesmønster

- - - Dag - Antall - - - - Mandag - - - - - - - Tirsdag - - - - - - - Onsdag - - - - - - - Torsdag - - - - - - - Fredag - - - - - - - Lørdag - - - - - - - Søndag - - - - - -
+
diff --git a/src/components/ContactAndReleaseInfo.tsx b/src/components/ContactAndReleaseInfo.tsx index 764227d..0d742fd 100644 --- a/src/components/ContactAndReleaseInfo.tsx +++ b/src/components/ContactAndReleaseInfo.tsx @@ -3,13 +3,14 @@ import {title} from '@prisma/client'; import {Button} from '@nextui-org/button'; import {FaEdit, FaSave} from 'react-icons/fa'; import {ImCross} from 'react-icons/im'; -import {Field, Form, Formik} from 'formik'; -import {Table, TableBody, TableCell, TableColumn, TableHeader, TableRow} from '@nextui-org/table'; -import NumberInputWithButtons from '@/components/NumberInput'; -import {validateBetweenZeroAndFive} from '@/utils/validationUtils'; +import {Form, Formik} from 'formik'; import SuccessModal from '@/components/SuccessModal'; import ErrorModal from '@/components/ErrorModal'; import {Spinner} from '@nextui-org/react'; +import ReleasePatternForm from '@/components/ReleasePatternForm'; +import ContactInformationForm from '@/components/ContactInformationForm'; +import ReleasePattern from '@/components/ReleasePattern'; +import ContactInformation from '@/components/ContactInformation'; interface ContactAndReleaseInfoProps { @@ -63,177 +64,18 @@ const ContactAndReleaseInfo: FC = (props: ContactAnd }) => (
-

Kontaktinformasjon

- - - - - - - - - - - -

Utgivelsesmønster

- - - Dag - Antall - - - - Mandag - - - - - - - Tirsdag - - - - - - - Onsdag - - - - - - - Torsdag - - - - - - - Fredag - - - - - - - Lørdag - - - - - - - Søndag - - - - - -
+ {isSubmitting ? ( ) : ( @@ -270,86 +112,29 @@ const ContactAndReleaseInfo: FC = (props: ContactAnd ) : ( <> {currentValue && -
-

Kontaktinformasjon:

- - {currentValue.vendor && -
-

Avleverer:

-

{currentValue.vendor}

-
- } - - {currentValue.contact_name && -
-

Kontaktperson:

-

{currentValue.contact_name}

-
- } - - {currentValue.contact_email && -
-

E-post:

-

{currentValue.contact_email}

-
- } - - {currentValue.contact_phone && -
-

Telefon:

-

{currentValue.contact_phone}

-
- } - - {currentValue.release_pattern && -
-

Utgivelsesmønster:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mandag:{currentValue.release_pattern[0]}
Tirsdag:{currentValue.release_pattern[1]}
Onsdag:{currentValue.release_pattern[2]}
Torsdag:{currentValue.release_pattern[3]}
Fredag:{currentValue.release_pattern[4]}
Lørdag:{currentValue.release_pattern[5]}
Søndag:{currentValue.release_pattern[6]}
-
- } - - -
+
+

Kontaktinformasjon:

+ + + + {currentValue.release_pattern && + + } + +
} )} diff --git a/src/components/ContactInformation.tsx b/src/components/ContactInformation.tsx new file mode 100644 index 0000000..79f85f2 --- /dev/null +++ b/src/components/ContactInformation.tsx @@ -0,0 +1,44 @@ +import React from 'react'; + +interface ContactInformationProps { + vendor?: string | null; + contactName?: string | null; + contactEmail?: string | null; + contactPhone?: string | null; +} + +const ContactInformation = (props: ContactInformationProps) => { + return ( + <> + {props.vendor && +
+

Avleverer:

+

{props.vendor}

+
+ } + + {props.contactName && +
+

Kontaktperson:

+

{props.contactName}

+
+ } + + {props.contactEmail && +
+

E-post:

+

{props.contactEmail}

+
+ } + + {props.contactPhone && +
+

Telefon:

+

{props.contactPhone}

+
+ } + + ); +}; + +export default ContactInformation; \ No newline at end of file diff --git a/src/components/ContactInformationForm.tsx b/src/components/ContactInformationForm.tsx new file mode 100644 index 0000000..0569b67 --- /dev/null +++ b/src/components/ContactInformationForm.tsx @@ -0,0 +1,64 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import {ChangeEvent, FC} from 'react'; +import {Field} from 'formik'; + +interface ContactInformationProps { + values: { + contact_email: string | null; + contact_name: string | null; + contact_phone: string | null; + vendor: string | null; + }; + handleChange: (e: ChangeEvent) => void; + handleBlur: (e: FocusEvent) => void; + className?: string; +} + +const ContactInformationForm: FC = ({values, handleChange, handleBlur, className}) => { + return ( +
+

Kontaktinformasjon

+ + + + + + + + + + + +
+ ); +}; + +export default ContactInformationForm; \ No newline at end of file diff --git a/src/components/NumberInput.tsx b/src/components/NumberInput.tsx index fa65089..9f96587 100644 --- a/src/components/NumberInput.tsx +++ b/src/components/NumberInput.tsx @@ -46,8 +46,8 @@ const NumberInputWithButtons: FC = ({ }; return ( -
-
+
+