diff --git a/src/sections/new-collection/NewCollection.tsx b/src/sections/new-collection/NewCollection.tsx index 3aa117f6d..961a26639 100644 --- a/src/sections/new-collection/NewCollection.tsx +++ b/src/sections/new-collection/NewCollection.tsx @@ -8,6 +8,7 @@ import { RequiredFieldText } from '../shared/form/RequiredFieldText/RequiredFiel import { BreadcrumbsGenerator } from '../shared/hierarchy/BreadcrumbsGenerator' import { CollectionForm, CollectionFormData } from './collection-form' import { SeparationLine } from '../shared/layout/SeparationLine/SeparationLine' +import { PageNotFound } from '../page-not-found/PageNotFound' interface NewCollectionProps { ownerCollectionId: string @@ -24,9 +25,6 @@ export function NewCollection({ ownerCollectionId, collectionRepository }: NewCo ownerCollectionId ) - // TODO:ME If is not loading and collection is not found, show a message and navigate to the root collection - // One good thing would be add toastify to show messages on top of the page for this kind of things - useEffect(() => { if (!isLoadingCollection) { setIsLoading(false) @@ -34,19 +32,19 @@ export function NewCollection({ ownerCollectionId, collectionRepository }: NewCo }, [isLoading, isLoadingCollection, setIsLoading]) if (!isLoading && !collection) { - return

Owner Collection not found

+ return } // TODO:ME Create Skeleton if (isLoading || !collection) { return

Loading...

} - // TODO:ME name = user name, affiliation = user affiliation, first email = user email - const formDefaultValues: Partial = { + + const formDefaultValues: CollectionFormData = { hostCollection: collection.name, name: user?.displayName ? `${user?.displayName} Collection` : '', alias: '', - type: undefined, + type: '', contacts: [{ value: user?.email ?? '' }], affiliation: user?.affiliation ?? '', storage: 'Local (Default)', diff --git a/src/sections/new-collection/NewCollectionFactory.tsx b/src/sections/new-collection/NewCollectionFactory.tsx index f9c248495..d948bcac6 100644 --- a/src/sections/new-collection/NewCollectionFactory.tsx +++ b/src/sections/new-collection/NewCollectionFactory.tsx @@ -14,7 +14,6 @@ export class NewCollectionFactory { function NewCollectionWithParams() { const { ownerCollectionId = 'root' } = useParams<{ ownerCollectionId: string }>() - // TODO:ME Maybe assert that collection with ownerCollectionId exists first, could be root or a specific collection // TODO:ME What roles can create a collection, what checks to do? return ( diff --git a/src/sections/new-collection/collection-form/index.tsx b/src/sections/new-collection/collection-form/index.tsx index ac7ac9fbd..404529f76 100644 --- a/src/sections/new-collection/collection-form/index.tsx +++ b/src/sections/new-collection/collection-form/index.tsx @@ -17,19 +17,23 @@ import styles from './CollectionForm.module.scss' export interface CollectionFormProps { collectionRepository: CollectionRepository - defaultValues: Partial + defaultValues: CollectionFormData } export type CollectionFormData = { hostCollection: string name: string - affiliation?: string + affiliation: string alias: string - storage?: CollectionStorage - type: CollectionType - description?: string + storage: CollectionStorage + type: CollectionType | '' + description: string contacts: { value: string }[] } +// On the submit function callback, type is CollectionType as type field is required and wont never be "" +export type CollectionFormValuesOnSubmit = Omit & { + type: CollectionType +} export const CollectionForm = ({ collectionRepository, defaultValues }: CollectionFormProps) => { const formContainerRef = useRef(null) @@ -110,10 +114,7 @@ export const CollectionForm = ({ collectionRepository, defaultValues }: Collecti -