diff --git a/apcd_cms/src/client/src/components/Admin/EditExceptionModal/EditExceptionModal.tsx b/apcd_cms/src/client/src/components/Admin/EditExceptionModal/EditExceptionModal.tsx index 226ba6c8..ec621a46 100644 --- a/apcd_cms/src/client/src/components/Admin/EditExceptionModal/EditExceptionModal.tsx +++ b/apcd_cms/src/client/src/components/Admin/EditExceptionModal/EditExceptionModal.tsx @@ -21,8 +21,11 @@ import * as Yup from 'yup'; import { ExceptionRow } from 'hooks/admin'; import { formatDate } from 'utils/dateUtil'; import styles from './EditExceptionModal.module.css'; + +import QueryWrapper from 'core-wrappers/QueryWrapper'; import FieldWrapper from 'core-wrappers/FieldWrapperFormik'; import Button from 'core-components/Button'; +import Message from 'core-components/Message'; interface EditRecordModalProps { isOpen: boolean; @@ -53,6 +56,10 @@ const EditExceptionModal: React.FC = ({ const [showSuccessMessage, setShowSuccessMessage] = useState(false); const [showErrorMessage, setShowErrorMessage] = useState(false); const [errorMessage, setErrorMessage] = useState(''); + const [isLoading, setIsLoading] = useState(true); + const [loadingError, setLoadingError] = useState( + Error('Exception data is not avalible') + ); const dateFormat: Intl.DateTimeFormatOptions = { year: 'numeric', month: 'short', @@ -60,6 +67,10 @@ const EditExceptionModal: React.FC = ({ }; if (!exception) return null; + if (isLoading) { + setIsLoading(false); + setLoadingError(null); + } // Use the custom hook to get form fields and validation const useFormFields = () => { @@ -240,23 +251,52 @@ const EditExceptionModal: React.FC = ({

Edit Selected Exception

- -
- - {exception.request_type == 'Threshold' && ( + + + + + + {exception.request_type == 'Threshold' && ( + + + + + Requested: {exception.requested_threshold}% + + + + )} = ({ className="form-text text-muted" style={{ fontStyle: 'italic' }} > - Requested: {exception.requested_threshold}% + Current:{' '} + {exception.approved_expiration_date + ? new Date( + exception.approved_expiration_date + ).toLocaleDateString() + : 'None'} - )} - - - - - Current:{' '} - {exception.approved_expiration_date - ? new Date( - exception.approved_expiration_date - ).toLocaleDateString() - : 'None'} - - - - - - + - {statusOptions?.map( - (val, index) => - val !== 'All' && ( - - ) - )} - - - - - - + {statusOptions?.map( + (val, index) => + val !== 'All' && ( + + ) + )} + + + + + - {outcomeOptions?.map((val, index) => ( - - ))} - - - - - - - - 2000 character limit - - - - -
- - Success: The exception data has been successfully updated. - - - Error: {errorMessage} - - - -
-
-

Current Exception Information

-
- {currentException.map((field, index) => ( - - {field.label}: - {field.value} - - ))} -
+ + {outcomeOptions?.map((val, index) => ( + + ))} + + + + + + + + 2000 character limit + + + +
+
+ + Success: The exception data has been successfully updated. + + + Error: {errorMessage} + + + +
+
+

Current Exception Information

+
+ {currentException.map((field, index) => ( + + {field.label}: + {field.value} + + ))} +
+
diff --git a/apcd_cms/src/client/src/components/Admin/ViewUsers/EditRecordModal.tsx b/apcd_cms/src/client/src/components/Admin/ViewUsers/EditRecordModal.tsx index f55b65e3..1dcf73df 100644 --- a/apcd_cms/src/client/src/components/Admin/ViewUsers/EditRecordModal.tsx +++ b/apcd_cms/src/client/src/components/Admin/ViewUsers/EditRecordModal.tsx @@ -14,6 +14,8 @@ import * as Yup from 'yup'; import { UserRow } from 'hooks/admin'; import styles from './ViewUsers.module.scss'; import { formatDate } from 'utils/dateUtil'; +import QueryWrapper from 'core-wrappers/QueryWrapper'; +import FieldWrapper from 'core-wrappers/FieldWrapperFormik'; import Button from 'core-components/Button'; interface EditRecordModalProps { @@ -32,8 +34,17 @@ const EditRecordModal: React.FC = ({ const [successModalOpen, setSuccessModalOpen] = useState(false); const [errorModalOpen, setErrorModalOpen] = useState(false); const [errorMessage, setErrorMessage] = useState(''); + const [isLoading, setIsLoading] = useState(true); + const [loadingError, setLoadingError] = useState( + Error('User data is not avalible') + ); if (!user) return null; + console.log('The user is ', user); + if (isLoading) { + setIsLoading(false); + setLoadingError(null); + } const initialValues: UserRow = { ...user, @@ -118,146 +129,173 @@ const EditRecordModal: React.FC = ({
Edit Selected User
- - {({ isSubmitting, dirty }) => ( -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + {({ isSubmitting, dirty }) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2000 character limit + + + + + +
+ + + )} +
+
+
+ {userFields.map((field, index) => ( + + +

{field.label}:

-
- - - - - - 2000 character limit - - - +

{field.value}

-
- - - )} - -
-
- {userFields.map((field, index) => ( - - -

{field.label}:

- - -

{field.value}

- -
- ))} -
+ ))} +
+
@@ -266,6 +304,7 @@ const EditRecordModal: React.FC = ({ toggle={() => setSuccessModalOpen(false)} className={styles.customModal} > + {/* Success must be in line with submit button*/}