diff --git a/src/app/[id]/page.tsx b/src/app/[id]/page.tsx index 3cb6eca..853f629 100644 --- a/src/app/[id]/page.tsx +++ b/src/app/[id]/page.tsx @@ -14,10 +14,10 @@ import { updateShelfForTitle } from '@/services/local.data'; import {box, contact_info, title} from '@prisma/client'; -import {useRouter, useSearchParams} from 'next/navigation'; +import {useSearchParams} from 'next/navigation'; import {NotFoundError} from '@/models/Errors'; import {Button} from '@nextui-org/button'; -import {FaArrowAltCircleLeft, FaBoxOpen, FaEdit, FaExternalLinkAlt, FaSave} from 'react-icons/fa'; +import {FaBoxOpen, FaEdit, FaExternalLinkAlt, FaSave} from 'react-icons/fa'; import BoxRegistrationModal from '@/components/BoxRegistrationModal'; import NotesComponent from '@/components/NotesComponent'; import EditTextInput from '@/components/EditTextInput'; @@ -33,6 +33,8 @@ import ContactInformationForm from '@/components/ContactInformationForm'; import {ImCross} from 'react-icons/im'; import ContactInformation from '@/components/ContactInformation'; import ReleasePattern from '@/components/ReleasePattern'; +import TitleNotFound from '@/components/TitleNotFound'; +import SuccessAlert from '@/components/SuccessAlert'; export default function Page({params}: { params: { id: string } }) { const [titleString, setTitleString] = useState(); @@ -42,7 +44,6 @@ export default function Page({params}: { params: { id: string } }) { const [boxFromDb, setBoxFromDb] = useState(); const [titleFromDbNotFound, setTitleFromDbNotFound] = useState(false); const [showBoxRegistrationModal, setShowBoxRegistrationModal] = useState(false); - const router = useRouter(); const titleFromQueryParams = useSearchParams()?.get('title'); const [isEditing, setIsEditing] = useState(false); const [showError, setShowError] = useState(false); @@ -199,7 +200,7 @@ export default function Page({params}: { params: { id: string } }) { return (
- {titleContact ? (<> {/* TODO: Fiks slik at det funker også når contactInfo ikke finnes. */} + {titleContact ? (<>
@@ -398,18 +399,9 @@ export default function Page({params}: { params: { id: string } }) { )} - {showSuccess && ( -
-

Kontaktinformasjonen ble lagret

- -
- )} + {showSuccess && + setShowSuccess(false)}/> + } - {titleString ? ( -
-

{titleString}

- {catalogTitle && catalogTitle.endDate && ( - - )} -
- ) : ( -

Henter tittel ...

- )} - -

Fant ikke kontakt- og utgivelsesinformasjon for denne tittelen. Ønsker du å - legge til?

-
- - -
- + } void; +} + +const SuccessAlert = ({ message, onClick }: SuccessAlertProps) => { + return ( +
+

{ message }

+ +
+ ); +}; + +export default SuccessAlert; \ No newline at end of file diff --git a/src/components/TitleNotFound.tsx b/src/components/TitleNotFound.tsx new file mode 100644 index 0000000..05e4756 --- /dev/null +++ b/src/components/TitleNotFound.tsx @@ -0,0 +1,60 @@ +import {CatalogTitle} from '@/models/CatalogTitle'; +import WarningLabel from '@/components/WarningLabel'; +import {catalogDateStringToNorwegianDateString} from '@/utils/dateUtils'; +import {Button} from '@nextui-org/button'; +import {FaArrowAltCircleLeft, FaEdit} from 'react-icons/fa'; +import React from 'react'; +import {useRouter} from 'next/navigation'; + +interface TitleNotFoundProps { + titleId: number; + titleString?: string; + catalogTitle?: CatalogTitle; +} + +const TitleNotFound = ({titleId, titleString, catalogTitle}: TitleNotFoundProps) => { + const router = useRouter(); + + return ( + <> + {titleString ? ( +
+

{titleString}

+ {catalogTitle && catalogTitle.endDate && ( + + )} +
+ ) : ( +

Henter tittel ...

+ )} + +

Fant ikke kontakt- og utgivelsesinformasjon for denne tittelen. Ønsker du å + legge til?

+
+ + +
+ + ); +}; + +export default TitleNotFound; \ No newline at end of file