From 9c23884e121da1887def79cbcd3b6e2574488f50 Mon Sep 17 00:00:00 2001 From: davidmtacc Date: Mon, 25 Nov 2024 17:55:25 -0800 Subject: [PATCH] manual merge to new folder structure (#378) Co-authored-by: Chandra Y --- .../static/submissions/css/table.css | 3 +- apcd_cms/src/apps/submissions/views.py | 45 ++++++----- apcd_cms/src/apps/utils/apcd_database.py | 1 + .../EditExtensionModal/EditExtensionModal.tsx | 75 ++++++++++--------- .../ViewFileSubmissions/ViewSubmissions.tsx | 57 +++++++++++++- .../Extensions/ExtensionFormInfo.tsx | 4 +- .../Submitter/Extensions/ExtensionsForm.tsx | 2 +- .../src/client/src/hooks/submissions/index.ts | 1 + .../src/hooks/submissions/useSubmissions.ts | 12 ++- 9 files changed, 139 insertions(+), 61 deletions(-) diff --git a/apcd_cms/src/apps/submissions/static/submissions/css/table.css b/apcd_cms/src/apps/submissions/static/submissions/css/table.css index 910385e1..534fbda5 100644 --- a/apcd_cms/src/apps/submissions/static/submissions/css/table.css +++ b/apcd_cms/src/apps/submissions/static/submissions/css/table.css @@ -12,5 +12,6 @@ .submission-table td:nth-of-type(4):before { content: "Outcome"; } .submission-table td:nth-of-type(5):before { content: "Status"; } .submission-table td:nth-of-type(6):before { content: "Last Updated"; } - .submission-table td:nth-of-type(7):before { content: "Actions"; } + .submission-table td:nth-of-type(7):before { content: "Payor Code"; } + .submission-table td:nth-of-type(8):before { content: "Actions"; } } diff --git a/apcd_cms/src/apps/submissions/views.py b/apcd_cms/src/apps/submissions/views.py index bfba1012..26e08629 100644 --- a/apcd_cms/src/apps/submissions/views.py +++ b/apcd_cms/src/apps/submissions/views.py @@ -29,11 +29,14 @@ def get(self, request, *args, **kwargs): status = request.GET.get('status', 'All') sort = request.GET.get('sort', 'Newest Received') + submitter_id = request.GET.get('submitterId', 'All') + payor_code = request.GET.get('payorCode', 'All') page_number = int(request.GET.get('page', 1)) items_per_page = int(request.GET.get('limit', 50)) + try: submission_content = get_user_submissions_and_logs(request.user.username) - filtered_submissions = self.filtered_submissions(submission_content, status, sort) + filtered_submissions = self.filtered_submissions(submission_content, status, sort, submitter_id, payor_code) paginator = Paginator(filtered_submissions, items_per_page) page_info = paginator.get_page(page_number) @@ -44,20 +47,18 @@ def get(self, request, *args, **kwargs): except Exception as e: logger.error("Error fetching filtered user data: %s", e) return JsonResponse({'error': str(e)}, status=500) - + def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context.update(self.get_view_submissions_json(get_user_submissions_and_logs(self.request.user.username))) return context - + def get_options(self, request): try: - status_options = ['All', 'In Process', 'Complete'] - sort_options = [ - {'name': 'Newest Received', 'value': 'newDate'}, - {'name': 'Oldest Received', 'value': 'oldDate'}, - ] - + status_options = ['All', 'In Process', 'Complete'] + sort_options = [{'name': 'Newest Received', 'value': 'newDate'}, + {'name': 'Oldest Received', 'value': 'oldDate'}] + return JsonResponse({ 'status_options': status_options, 'sort_options': sort_options, @@ -66,40 +67,46 @@ def get_options(self, request): logger.error("Error fetching options data: %s", e) return JsonResponse({'error': str(e)}, status=500) - def filtered_submissions(self, submission_content, status, sort): + def filtered_submissions(self, submission_content, status, sort, submitter_id, payor_code): def getDate(submission): date = submission['received_timestamp'] return parser.parse(date) if date is not None else parser.parse('1-1-3005') - + if status != 'All': - submission_content = [submission for submission in submission_content - if submission['status'].lower() == status.lower()] - + submission_content = [submission for submission in submission_content + if submission['status'].lower() == status.lower()] + + if submitter_id != 'All': + submission_content = [submission for submission in submission_content + if submission['submitter_id'] == int(submitter_id)] + if payor_code != 'All': + submission_content = [submission for submission in submission_content + if submission['payor_code'] == int(payor_code)] submission_content = sorted( submission_content, key=lambda row: getDate(row), reverse=(sort == 'Newest Received') ) return submission_content - - def get_view_submissions_json(self, submission_content, selected_status='All', selected_sort='Newest Received'): + + def get_view_submissions_json(self, submission_content, selected_status='All', selected_sort='Newest Received', submission_id='All', payor_code='All'): context = { 'page': [], 'selected_status': selected_status, 'selected_sort': selected_sort, 'pagination_url_namespaces':'submissions:list_submissions' } - + def _set_submissions(submission): return { 'submission_id': submission['submission_id'], 'submitter_id': submission['submitter_id'], - 'entity_name': submission['entity_name'], 'file_name': submission['file_name'], 'status': submission['status'], 'outcome': title_case(submission['outcome']) if submission['outcome'] else None, 'received_timestamp': submission['received_timestamp'], 'updated_at': submission['updated_at'], + 'payor_code': submission['payor_code'], 'view_modal_content': submission['view_modal_content'], } for submission in submission_content: @@ -112,4 +119,4 @@ def _set_submissions(submission): def check_submitter_role(request): logger.info("Checking submitter access for user: %s", request.user.username) - return JsonResponse({"is_submitter": has_apcd_group(request.user)}) + return JsonResponse({"is_submitter": has_apcd_group(request.user)}) \ No newline at end of file diff --git a/apcd_cms/src/apps/utils/apcd_database.py b/apcd_cms/src/apps/utils/apcd_database.py index 6652250e..5f91e31a 100644 --- a/apcd_cms/src/apps/utils/apcd_database.py +++ b/apcd_cms/src/apps/utils/apcd_database.py @@ -897,6 +897,7 @@ def get_user_submissions_and_logs(user): 'outcome', submissions.outcome, 'received_timestamp', submissions.received_timestamp, 'updated_at', submissions.updated_at, + 'payor_code', submissions.payor_code, 'view_modal_content', ( SELECT COALESCE(json_agg(json_build_object( 'log_id', submission_logs.log_id, 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 e9ff9744..bbbd1fa4 100644 --- a/apcd_cms/src/client/src/components/Extensions/EditExtensionModal/EditExtensionModal.tsx +++ b/apcd_cms/src/client/src/components/Extensions/EditExtensionModal/EditExtensionModal.tsx @@ -23,7 +23,10 @@ import * as Yup from 'yup'; import { ExtensionRow } from 'hooks/admin'; import { useEntities } from 'hooks/entities'; import QueryWrapper from 'core-wrappers/QueryWrapper'; -import { convertPeriodLabelToApiValue, convertApiValueToPeriodLabel } from 'utils/dateUtil'; +import { + convertPeriodLabelToApiValue, + convertApiValueToPeriodLabel, +} from 'utils/dateUtil'; import styles from './EditExtensionModal.module.css'; import FieldWrapper from 'core-wrappers/FieldWrapperFormik'; import Button from 'core-components/Button'; @@ -103,8 +106,10 @@ const EditExtensionModal: React.FC = ({ const { ext_id } = values; const api_values = { ...values, - 'applicable_data_period': convertPeriodLabelToApiValue(values['applicable_data_period']), - } + applicable_data_period: convertPeriodLabelToApiValue( + values['applicable_data_period'] + ), + }; const url = `administration/update-extension/${ext_id}/`; try { @@ -120,7 +125,9 @@ const EditExtensionModal: React.FC = ({ setUserFields([ { label: 'Applicable Data Period', - value: convertApiValueToPeriodLabel(values.applicable_data_period) || 'None', + value: + convertApiValueToPeriodLabel(values.applicable_data_period) || + 'None', }, { label: 'Approved Expiration Date', @@ -190,11 +197,11 @@ const EditExtensionModal: React.FC = ({
- + = ({ ))} -
- Current:{' '}{(extension.applicable_data_period)} +
+ Current: {extension.applicable_data_period}
- + + required={false} + > = ({ onChange={formik.handleChange} onBlur={formik.handleBlur} /> -
+
Current:{' '} {extension.approved_expiration_date ? new Date( @@ -252,12 +257,14 @@ const EditExtensionModal: React.FC = ({ ).toLocaleDateString() : 'None'}
- + - + = ({ ) )} - + - + = ({ - + = ({ onChange={formik.handleChange} onBlur={formik.handleBlur} /> -
- 2000 character limit -
+
2000 character limit

- - Success: The exception data has been successfully updated. - + + Success: The exception data has been successfully updated. + Error: {errorMessage} diff --git a/apcd_cms/src/client/src/components/Submissions/ViewFileSubmissions/ViewSubmissions.tsx b/apcd_cms/src/client/src/components/Submissions/ViewFileSubmissions/ViewSubmissions.tsx index 271044dc..9c5c65cc 100644 --- a/apcd_cms/src/client/src/components/Submissions/ViewFileSubmissions/ViewSubmissions.tsx +++ b/apcd_cms/src/client/src/components/Submissions/ViewFileSubmissions/ViewSubmissions.tsx @@ -5,6 +5,7 @@ import { useSubmissionFilters, FileSubmissionLogsModalContent, } from 'hooks/submissions'; +import { Entities, useEntities } from 'hooks/entities'; import LoadingSpinner from 'core-components/LoadingSpinner'; import Button from 'core-components/Button'; import SectionMessage from 'core-components/SectionMessage'; @@ -23,6 +24,7 @@ export const ViewFileSubmissions: React.FC = () => { 'Outcome', 'Status', 'Last Updated', + 'Payor Code', 'Actions', ]; const { @@ -34,6 +36,9 @@ export const ViewFileSubmissions: React.FC = () => { const [status, setStatus] = useState('All'); const [sort, setSort] = useState('Newest Received'); const [page, setPage] = useState(1); + const [submitterId, setSubmitterId] = useState('All'); + const [payorCode, setPayorCode] = useState('All'); + const [submitterPayorCode, setSubmitterPayorCode] = useState('All'); const [viewModalOpen, setViewModalOpen] = useState(false); const [selectedSubmission, setSelectedSubmission] = useState(null); @@ -51,12 +56,26 @@ export const ViewFileSubmissions: React.FC = () => { isLoading: isSubmissionLoading, isError: isSubmissionError, refetch, - } = useListSubmissions(status, sort, page); + } = useListSubmissions(status, sort, submitterId, payorCode, page); + + useEffect(() => { + if (submitterId && payorCode) { + setSubmitterPayorCode(`${submitterId},${payorCode}`); + } else { + setSubmitterPayorCode('All'); + } + }, [submitterId, payorCode]); useEffect(() => { refetch(); }, [status, sort, page]); + const { + data: submitterData, + isLoading: entitiesLoading, + error: entitiesError, + } = useEntities(); + if (isSubmissionLoading) { return ; } @@ -75,6 +94,8 @@ export const ViewFileSubmissions: React.FC = () => { const clearSelections = () => { setStatus('All'); setSort('Newest Received'); + setSubmitterId('All'); + setPayorCode('All'); setPage(1); }; @@ -113,7 +134,38 @@ export const ViewFileSubmissions: React.FC = () => { ))} - {status !== 'All' || sort !== 'Newest Received' ? ( + + Payor Code: + + + {status !== 'All' || + sort !== 'Newest Received' || + submitterId !== 'All' || + payorCode !== 'All' ? ( ) : null}
@@ -137,6 +189,7 @@ export const ViewFileSubmissions: React.FC = () => { {titleCase(row.outcome)} {titleCase(row.status)} {formatDate(row.updated_at)} + {row.payor_code}