Skip to content

Commit

Permalink
fix: type issue with source_information in DREF application
Browse files Browse the repository at this point in the history
  • Loading branch information
samshara committed Dec 11, 2023
1 parent 6bde7ad commit 89fc5ea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/views/DrefApplicationForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ export function Component() {
event_map_file,
cover_image_file,
images_file,
source_information,
...otherValues
} = removeNull(response);

setValue({
...otherValues,
planned_interventions: planned_interventions?.map(
Expand All @@ -247,6 +247,7 @@ export function Component() {
indicators: intervention.indicators?.map(injectClientId),
}),
),
source_information: source_information?.map(injectClientId),
needs_identified: needs_identified?.map(injectClientId),
national_society_actions: national_society_actions?.map(injectClientId),
risk_security: risk_security?.map(injectClientId),
Expand Down
38 changes: 22 additions & 16 deletions src/views/DrefApplicationForm/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ type InterventionResponse = NonNullable<DrefRequestBody['planned_interventions']
type IndicatorResponse = NonNullable<InterventionResponse['indicators']>[number];
type RiskSecurityResponse = NonNullable<DrefRequestBody['risk_security']>[number];
type ImagesFileResponse = NonNullable<DrefRequestBody['images_file']>[number];
type SourceInformationResponse = NonNullable<DrefRequestBody['source_information']>[number];

type NeedIdentifiedFormFields = NeedIdentifiedResponse & { client_id: string };
type NsActionFormFields = NsActionResponse & { client_id: string; }
type InterventionFormFields = InterventionResponse & { client_id: string };
type IndicatorFormFields = IndicatorResponse & { client_id: string };
type SourceInformationFormFields = SourceInformationResponse & { client_id: string };

type RiskSecurityFormFields = RiskSecurityResponse & { client_id: string; };
type ImagesFileFormFields = ImagesFileResponse & { client_id: string };
Expand All @@ -81,31 +83,35 @@ type DrefFormFields = (
DeepReplace<
DeepReplace<
DeepReplace<
DrefRequestBody,
NeedIdentifiedResponse,
NeedIdentifiedFormFields
DeepReplace<
DrefRequestBody,
NeedIdentifiedResponse,
NeedIdentifiedFormFields
>,
NsActionResponse,
NsActionFormFields
>,
NsActionResponse,
NsActionFormFields
InterventionResponse,
InterventionFormFields
>,
InterventionResponse,
InterventionFormFields
IndicatorResponse,
IndicatorFormFields
>,
IndicatorResponse,
IndicatorFormFields
>,
IndicatorResponse,
IndicatorFormFields
RiskSecurityResponse,
RiskSecurityFormFields
>,
RiskSecurityResponse,
RiskSecurityFormFields
ImagesFileResponse,
ImagesFileFormFields
>,
ImagesFileResponse,
ImagesFileFormFields
EventMapFileResponse,
EventMapFileFormField
>,
EventMapFileResponse,
EventMapFileFormField
>
SourceInformationResponse,
SourceInformationFormFields
>
);

export type PartialDref = PartialForm<
Expand Down

0 comments on commit 89fc5ea

Please sign in to comment.