Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landing Page clear button #154

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions backend/src/document_data/document_data.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ export class DocumentDataController {
return this.documentDataService.getProvisionsByDocTypeIdAndDtid(document_type_id, dtid);
}

@Get('get/:document_type_id/:dtid')
getDocData(@Param('document_type_id') document_type_id: number, @Param('dtid') dtid: number) {
return this.documentDataService.getProvisionsByDocTypeIdAndDtid(document_type_id, dtid);
}

@Get('get-enabled-provisions/:document_type_id/:dtid')
getEnabledProvisionsByDocTypeIdAndDtid(
@Param('document_type_id') document_type_id: number,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/common/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const getDocumentTypes = () => {
};

export const getDocumentData = async (document_type_id: number, dtid: number): Promise<DocumentDataDTO> => {
const url = `${config.API_BASE_URL}/document-data/get/${document_type_id}/${dtid}`;
const url = `${config.API_BASE_URL}/document-data/provisions/${document_type_id}/${dtid}`;
const getParameters = api.generateApiParameters(url);
const response = await api.get<DocumentDataDTO>(getParameters);
return response;
Expand Down
42 changes: 36 additions & 6 deletions frontend/src/app/content/pages/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { setProvisionDataObjects, setSelectedProvisionIds } from '../../store/re
import { setSelectedVariableIds, setVariables } from '../../store/reducers/variableSlice';
import { RootState } from '../../store/store';
import { setSearchState } from '../../store/reducers/searchSlice';
import CustomCollapsible from './documentpreview/CustomCollapsible';

const LandingPage: FC = () => {
const [loading, setLoading] = useState<boolean>(false);
Expand All @@ -54,6 +55,7 @@ const LandingPage: FC = () => {
const selectedVariableIds: number[] = useSelector((state: RootState) => state.variable.selectedVariableIds);
const variables = useSelector((state: RootState) => state.variable.variables);
const searchState = useSelector((state: RootState) => state.search);
const [isOpen, setIsOpen] = useState(false);

useEffect(() => {
const fetchBasicData = async () => {
Expand Down Expand Up @@ -135,7 +137,7 @@ const LandingPage: FC = () => {
setProvisionGroups(activeProvisionGroups);
} catch (error) {
console.error('Failed to fetch data', error);
setData(null);
//setData(null);
} finally {
setLoading(false);
}
Expand Down Expand Up @@ -164,6 +166,7 @@ const LandingPage: FC = () => {
setError(err);
setShowError(true);
} finally {
setIsOpen(true);
setLoading(false);
}
} else {
Expand Down Expand Up @@ -227,6 +230,14 @@ const LandingPage: FC = () => {
return { variableSaveData, provisionSaveData };
};

const handleClear = () => {
setDtidInput(null);
setData(null);
setIsOpen(false);
setSelectedDocTypeId(null);
};
const toggleCollapsible = () => setIsOpen(!isOpen);

const getReportData = () => {
const selectedProvisions = provisions.filter((provision) => selectedProvisionIds.includes(provision.provision_id));
const provisionJsonArray: ProvisionJson[] = selectedProvisions.map((provision) => {
Expand Down Expand Up @@ -303,10 +314,14 @@ const LandingPage: FC = () => {
<div className="inlineDiv ml-4 mr-4">
<input type="number" className="form-control" id="dtid" value={dtidInput || ''} onChange={handleDtidChange} />
</div>
<Button variant="success" onClick={fetchDataHandler}>
<Button variant="success" onClick={fetchDataHandler} style={{ marginRight: '10px', width: '150px' }}>
Retrieve
</Button>

<Button variant="outline-primary" style={{ backgroundColor: 'transparent', color: 'black', width: '150px' }} onClick={handleClear}>Clear</Button>

</div>

{showError && (
<Alert variant="danger" className="mb-3 d-inline-block" style={{ width: 'auto', maxWidth: '100%' }}>
{error}
Expand All @@ -322,11 +337,26 @@ const LandingPage: FC = () => {
<div className="font-weight-bold inlineDiv mr-1">Primary Contact Name:</div>
<div className="inlineDiv">{data?.primaryContactName}</div>
</div>
<Collapsible title="Disposition Transaction ID Details">
<CustomCollapsible
title="Disposition Transaction ID Details"
isOpen={isOpen}
toggleCollapsible={toggleCollapsible}
isSpanRequired={false}
>
{data ? <DtidDetails data={data!} /> : <Skeleton />}
</Collapsible>
<Collapsible title="Tenure Details">{data ? <TenureDetails data={data!} /> : <Skeleton />}</Collapsible>
<Collapsible title="Interested Parties">{data ? <InterestedParties data={data!} /> : <Skeleton />}</Collapsible>
</CustomCollapsible>
<CustomCollapsible
title="Tenure Details"
isOpen={isOpen}
toggleCollapsible={toggleCollapsible}
isSpanRequired={false}
>{data ? <TenureDetails data={data!} /> : <Skeleton />}</CustomCollapsible>
<CustomCollapsible
title="Interested Parties"
isOpen={isOpen}
toggleCollapsible={toggleCollapsible}
isSpanRequired={false}
>{data ? <InterestedParties data={data!} /> : <Skeleton />}</CustomCollapsible>

<hr />
<h3>Create Document</h3>
Expand Down
Loading