diff --git a/src/components/Docs/AdminDocs.tsx b/src/components/Docs/AdminDocs.tsx index 4dfaeee9..4e59e42f 100644 --- a/src/components/Docs/AdminDocs.tsx +++ b/src/components/Docs/AdminDocs.tsx @@ -27,7 +27,7 @@ function AdminDocs() { const [documentations, setDocumentations] = useState([]); const [title, setTitle] = useState(''); const [description, setDescription] = useState(''); - const [role, setRole] = useState(''); + const [role, setRole] = useState('Trainee'); const [buttonLoading, setButtonLoading] = useState(false); const [isSubDocument, setIsSubDocument] = useState(false); const [selectedDocId, setSelectedDocId] = useState(''); @@ -45,7 +45,7 @@ function AdminDocs() { setSelectedContent(null); }; - const [getDocumentations] = useLazyQuery(GET_DOCUMENTATION, { + const [getDocumentations, { loading }] = useLazyQuery(GET_DOCUMENTATION, { fetchPolicy: 'network-only', onCompleted: (data) => { @@ -238,293 +238,321 @@ function AdminDocs() { const contents = [permission]; - const page1 = ( + const Skeleton = ( <> -
- +
+
+ + +
+
+
+ {[0, 1, 2, 3, 4, 5].map((i) => ( +
+
+
+
+
+
+
+ ))}
+ + ); - {/* {documentations.map((documentation) => ( */} -
-
- ({ - Document: ( - <> -
- -
- { - setIsUpdate(true); - setDocumentModel(!documentModel); - setTitle(documentation.title); - setDescription(documentation.description); - setSelectedDocId(documentation.id); - setRole(documentation.for); - }} - /> - - { - handleDeleteDocumentation(documentation.id); - }} - /> -
-
- -
-
-
- - {documentation.for} - - {documentation.description} - + +
+ {!loading && documentations.length > 0 && ( +
+ ({ + Document: ( + +
+ +
+ { - setIsSubDocument(true); + setIsUpdate(true); setDocumentModel(!documentModel); + setTitle(documentation.title); + setDescription(documentation.description); + setSelectedDocId(documentation.id); + setRole(documentation.for); + }} + /> + + { + handleDeleteDocumentation(documentation.id); }} - > - {t(`Add SubDocument`)} - + />
- {documentation.subDocuments.map( - (subDocument: { title: any; description: any }) => ( -
+
+ {documentation.for} +
+
+ {documentation.description} - { - handleDeleteSubDocumentation( - documentation.id, - subDocument.title, - subDocument.description, - ); - }} - />
- ), - )} -
- - ), - Action: <>, - }))} - columns={columns} - title={t('')} - /> -
+
+ + {documentation.subDocuments.map( + (subDocument: { title: any; description: any }) => ( +
+ + { + handleDeleteSubDocumentation( + documentation.id, + subDocument.title, + subDocument.description, + ); + }} + /> +
+ ), + )} +
+ + ), + Action: <>, + }))} + columns={columns} + title={t('')} + /> +
+ )} + {!loading && documentations.length === 0 && ( +

+ There are no documentations by now. +

+ )}
- {/* - )) - - } */} ); return ( <> -
-
-
-

- {isUpdate ? t('Update Document') : t('Add Document')} -

-
-
-
-
-
-

- {isUpdate - ? t( - 'Enter the title and description of the document you want to update', - ) - : t( - 'Enter the title and description of the document you want to add', - )} -

-
-
-
- { - setTitle(e.target.value); - }} - value={title} - type="text" - name="title" - className="w-full px-5 py-2 font-sans text-xs text-black border rounded outline-none dark:bg-dark-tertiary border-primary" - placeholder={t('title')} - /> +
+
+
+
+

+ {isUpdate ? t('Update Document') : t('Add Document')} +

+
+
+
+ +
+

+ {isUpdate + ? t( + 'Enter the title and description of the document you want to update', + ) + : t( + 'Enter the title and description of the document you want to add', + )} +

-
-
-
-
-