From bb80df27db056cec69267af13fd27ad60444834f Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Fri, 1 Nov 2024 10:42:21 -0500 Subject: [PATCH] prettier run --- .../Admin/Extensions/AdminExtensions.tsx | 138 +++++++++--------- .../EditExtensionModal/EditExtensionModal.tsx | 97 ++++++------ .../ViewExtensionModal/ViewExtensionModal.tsx | 105 +++++++------ .../src/client/src/hooks/admin/useAdmin.ts | 6 +- 4 files changed, 182 insertions(+), 164 deletions(-) diff --git a/apcd-cms/src/client/src/components/Admin/Extensions/AdminExtensions.tsx b/apcd-cms/src/client/src/components/Admin/Extensions/AdminExtensions.tsx index 509a4b00..4e60902a 100644 --- a/apcd-cms/src/client/src/components/Admin/Extensions/AdminExtensions.tsx +++ b/apcd-cms/src/client/src/components/Admin/Extensions/AdminExtensions.tsx @@ -8,19 +8,22 @@ import ViewExtensionModal from 'apcd-components/Extensions/ViewExtensionModal/Vi import EditExtensionModal from 'apcd-components/Extensions/EditExtensionModal/EditExtensionModal'; import { formatDate } from 'utils/dateUtil'; - export const AdminExtensions: React.FC = () => { const [status, setStatus] = useState('All'); const [org, setOrg] = useState('All'); const [page, setPage] = useState(1); - const { data, isLoading, isError, refetch } = useExtensions(status, org, page); + const { data, isLoading, isError, refetch } = useExtensions( + status, + org, + page + ); const [isViewModalOpen, setIsViewModalOpen] = useState(false); const [isEditModalOpen, setIsEditModalOpen] = useState(false); - const [selectedExtension, setSelectedExtension] = + const [selectedExtension, setSelectedExtension] = useState(null); -console.log(data); + console.log(data); const clearSelections = () => { setStatus(''); @@ -32,19 +35,19 @@ console.log(data); refetch(); }, [status, org, page, refetch]); - if (isLoading) { - return ; + if (isLoading) { + return ; } if (isError) { - return ( - - There was an error loading the page.{''} - - Please submit a ticket. - - - ); + return ( + + There was an error loading the page.{''} + + Please submit a ticket. + + + ); } const openAction = ( @@ -53,24 +56,21 @@ console.log(data); ) => { const actionsDropdown = event.target; const selectedOption = actionsDropdown.value; - setSelectedExtension( - data?.page.find((x) => x.ext_id === ext_id) ?? null - ); + setSelectedExtension(data?.page.find((x) => x.ext_id === ext_id) ?? null); if (selectedOption == 'viewExtension') { setIsViewModalOpen(true); } else if (selectedOption == 'editExtension') { - setIsEditModalOpen(true); + setIsEditModalOpen(true); } actionsDropdown.selectedIndex = 0; }; - return ( -
-

View Extension Requests

-

All submitted extension requests

-
-
+
+

View Extension Requests

+

All submitted extension requests

+
+
{/* Filter */}
@@ -114,63 +114,63 @@ console.log(data);
- - - - {data?.header.map((columnName: string, index: number) => ( - - ))} - - - - {data?.page.map((row: ExtensionRow, rowIndex: number) => ( - - - - - - - - - + + ))} + +
{columnName}
{formatDate(row.created)}{row.org_name}{row.requestor}{row.type}{row.ext_outcome}{row.ext_status}{formatDate(row.approved_expiration_date)} + + + + {data?.header.map((columnName: string, index: number) => ( + + ))} + + + + {data?.page.map((row: ExtensionRow, rowIndex: number) => ( + + + + + + + + + - - ))} - -
{columnName}
{formatDate(row.created)}{row.org_name}{row.requestor}{row.type}{row.ext_outcome}{row.ext_status}{formatDate(row.approved_expiration_date)} -
-
+ + + + +
+
{selectedExtension && ( - <> - setIsViewModalOpen(false)} - /> - setIsEditModalOpen(false)} - /> - - )} -
+ <> + setIsViewModalOpen(false)} + /> + setIsEditModalOpen(false)} + /> + + )}
+
); }; diff --git a/apcd-cms/src/client/src/components/Extensions/EditExtensionModal/EditExtensionModal.tsx b/apcd-cms/src/client/src/components/Extensions/EditExtensionModal/EditExtensionModal.tsx index 769a6aff..1683842d 100644 --- a/apcd-cms/src/client/src/components/Extensions/EditExtensionModal/EditExtensionModal.tsx +++ b/apcd-cms/src/client/src/components/Extensions/EditExtensionModal/EditExtensionModal.tsx @@ -54,14 +54,19 @@ const EditExtensionModal: React.FC = ({ const [showErrorMessage, setShowErrorMessage] = useState(false); const [errorMessage, setErrorMessage] = useState(''); const [userFields, setUserFields] = useState([ - { label: 'Applicable Data Period', value: extension?.applicable_data_period || 'None' }, - { label: 'Approved Expiration Date', value: extension?.approved_expiration_date || 'None' }, + { + label: 'Applicable Data Period', + value: extension?.applicable_data_period || 'None', + }, + { + label: 'Approved Expiration Date', + value: extension?.approved_expiration_date || 'None', + }, { label: 'Exception Status', value: extension?.ext_status }, { label: 'Exception Outcome', value: extension?.ext_outcome }, { label: 'Exception Notes', value: extension?.notes || 'None' }, ]); - if (!extension) return null; // Use the custom hook to get form fields and validation @@ -100,13 +105,18 @@ const EditExtensionModal: React.FC = ({ if (onEditSuccess && response) { onEditSuccess(response); setUserFields([ - { label: 'Applicable Data Period', value: values.applicable_data_period || 'None' }, - { label: 'Approved Expiration Date', value: values.approved_expiration_date || 'None' }, + { + label: 'Applicable Data Period', + value: values.applicable_data_period || 'None', + }, + { + label: 'Approved Expiration Date', + value: values.approved_expiration_date || 'None', + }, { label: 'Exception Status', value: values.ext_status }, { label: 'Exception Outcome', value: values.ext_outcome }, { label: 'Exception Notes', value: values.notes || 'None' }, ]); - } setShowSuccessMessage(true); @@ -140,7 +150,7 @@ const EditExtensionModal: React.FC = ({ setShowSuccessMessage(false); setShowErrorMessage(false); }; -/* + /* const userFields = [ { label: 'Applicable Data Period', @@ -172,8 +182,7 @@ const EditExtensionModal: React.FC = ({ >
-
- -
-

Details

-
-
-
Created
-
{extension.created}
-
Entity Organization
-
{extension.org_name}
-
Requestor
-
{extension.requestor}
-
Requestor Email
-
{extension.requestor_email}
-
Extension Type
-
{extension.type}
-
Status
-
{extension.ext_status}
-
Outcome
-
{extension.ext_outcome}
-
Applicable Data Period
-
{extension.applicable_data_period}
-
Current Expected Date
-
{extension.current_expected_date}
-
Requested Target Date
-
{extension.requested_target_date}
-
Approved Expiration Date
-
{extension.approved_expiration_date}
-
Extension Justification
-
{extension.explanation_justification}
-
Extension Notes
-
{extension.notes}
-
Last Updated
-
{extension.updated_at}
-
-
+ +
+

+ Extension Details ID {extension.ext_id} for {extension.org_name} +

+ +
+ +
+

Details

+
+
+
Created
+
{extension.created}
+
Entity Organization
+
{extension.org_name}
+
Requestor
+
{extension.requestor}
+
Requestor Email
+
+ {extension.requestor_email} +
+
Extension Type
+
{extension.type}
+
Status
+
{extension.ext_status}
+
Outcome
+
{extension.ext_outcome}
+
Applicable Data Period
+
+ {extension.applicable_data_period} +
+
Current Expected Date
+
+ {extension.current_expected_date} +
+
Requested Target Date
+
+ {extension.requested_target_date} +
+
Approved Expiration Date
+
+ {extension.approved_expiration_date} +
+
Extension Justification
+
+ {extension.explanation_justification} +
+
Extension Notes
+
{extension.notes}
+
Last Updated
+
{extension.updated_at}
+
- +
+
); }; diff --git a/apcd-cms/src/client/src/hooks/admin/useAdmin.ts b/apcd-cms/src/client/src/hooks/admin/useAdmin.ts index 29328582..e9cce090 100644 --- a/apcd-cms/src/client/src/hooks/admin/useAdmin.ts +++ b/apcd-cms/src/client/src/hooks/admin/useAdmin.ts @@ -53,11 +53,11 @@ const getExtensions = async (params: any) => { }; export const useExtensions = ( - status?: string, + status?: string, org?: string, page?: number - ): UseQueryResult => { - const params: { status?: string; org?: string; page?: number } = { +): UseQueryResult => { + const params: { status?: string; org?: string; page?: number } = { status, org, page,