Skip to content

Commit

Permalink
fix types to fit with instance without other wikidata softwares
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeBu committed Jul 26, 2024
1 parent 5676443 commit 9063734
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 47 deletions.
9 changes: 1 addition & 8 deletions api/src/core/usecases/readWriteSillData/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,7 @@ export const thunks = {

assert(index !== -1, "Can't update instance, it doesn't exist");

const {
mainSoftwareSillId,
organization,
otherSoftwareWikidataIds,
publicUrl,
targetAudience,
...rest
} = formData;
const { mainSoftwareSillId, organization, publicUrl, targetAudience, ...rest } = formData;

assert<Equals<typeof rest, {}>>();

Expand Down
1 change: 0 additions & 1 deletion api/src/core/usecases/readWriteSillData/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,4 @@ export type InstanceFormData = {
organization: string;
targetAudience: string;
publicUrl: string | undefined;
otherSoftwareWikidataIds: string[];
};
3 changes: 1 addition & 2 deletions api/src/rpc/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,7 @@ const zInstanceFormData = (() => {
"mainSoftwareSillId": z.number(),
"organization": z.string(),
"targetAudience": z.string(),
"publicUrl": z.string().optional(),
"otherSoftwareWikidataIds": z.array(z.string())
"publicUrl": z.string().optional()
});

{
Expand Down
1 change: 0 additions & 1 deletion api/src/tools/test.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,5 @@ export const createInstanceFormData = makeObjectFactory<InstanceFormData>({
organization: "Default organization",
targetAudience: "Default audience",
mainSoftwareSillId: 1,
otherSoftwareWikidataIds: [],
publicUrl: "https://example.com"
});
2 changes: 1 addition & 1 deletion web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link rel="shortcut icon" href="%PUBLIC_URL%/dsfr/favicon/favicon.ico?v=1.12.1" type="image/x-icon" />
<link rel="manifest" href="%PUBLIC_URL%/dsfr/favicon/manifest.webmanifest?v=1.12.1" crossorigin="use-credentials" />

<link rel="stylesheet" href="%PUBLIC_URL%/dsfr/utility/icons/icons.min.css?hash=cfdb5c1c" />
<link rel="stylesheet" href="%PUBLIC_URL%/dsfr/utility/icons/icons.min.css?hash=3375e412" />
<link rel="stylesheet" href="%PUBLIC_URL%/dsfr/dsfr.min.css?v=1.12.1" />

<%
Expand Down
1 change: 0 additions & 1 deletion web/src/core/adapter/sillApiMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const sillApi: SillApi = {
"id": 0,
"mainSoftwareSillId": 9,
"organization": "CNRS",
"otherWikidataSoftwares": [],
"publicUrl": "https://videos.ahp-numerique.fr/",
"targetAudience": `Plateforme vidéos des Archives Henri-Poincaré (laboratoire du CNRS, de l'Université de Lorraine et de
l'Université de Strasbourg). Vous y trouverez des vidéos de philosophie et d'histoire des sciences et des techniques.`
Expand Down
4 changes: 0 additions & 4 deletions web/src/core/usecases/instanceForm/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const initializationData = createSelector(
| undefined
| {
mainSoftwareSillId: number | undefined;
otherSoftwares: WikidataEntry[];
organization: string | undefined;
publicUrl: string | undefined;
targetAudience: string | undefined;
Expand All @@ -37,7 +36,6 @@ const initializationData = createSelector(
if (preFillData === undefined) {
return {
"mainSoftwareSillId": undefined,
"otherSoftwares": [],
"organization": undefined,
"publicUrl": undefined,
"targetAudience": undefined
Expand All @@ -48,15 +46,13 @@ const initializationData = createSelector(
case "update":
return {
"mainSoftwareSillId": preFillData.mainSoftwareSillId,
"otherSoftwares": preFillData.otherWikidataSoftwares,
"organization": preFillData.organization,
"publicUrl": preFillData.publicUrl,
"targetAudience": preFillData.targetAudience
};
case "navigated from software form":
return {
"mainSoftwareSillId": preFillData.justRegisteredSoftwareSillId,
"otherSoftwares": [],
"organization": undefined,
"publicUrl": undefined,
"targetAudience": undefined
Expand Down
2 changes: 0 additions & 2 deletions web/src/core/usecases/instanceForm/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace State {
type: "update";
instanceId: number;
mainSoftwareSillId: number;
otherWikidataSoftwares: WikidataEntry[];
organization: string;
publicUrl: string | undefined;
targetAudience: string;
Expand All @@ -41,7 +40,6 @@ namespace State {
step1Data:
| {
mainSoftwareSillId: number;
otherWikidataSoftwares: WikidataEntry[];
}
| undefined;
isSubmitting: boolean;
Expand Down
16 changes: 3 additions & 13 deletions web/src/core/usecases/instanceForm/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export const thunks = {
"type": "update",
"instanceId": instance.id,
"mainSoftwareSillId": instance.mainSoftwareSillId,
"otherWikidataSoftwares": instance.otherWikidataSoftwares,
"organization": instance.organization,
"publicUrl": instance.publicUrl,
"targetAudience": instance.targetAudience
Expand Down Expand Up @@ -115,21 +114,15 @@ export const thunks = {
dispatch(actions.cleared());
},
"completeStep1":
(props: {
mainSoftwareSillId: number;
otherWikidataSoftwares: WikidataEntry[];
}) =>
(props: { mainSoftwareSillId: number }) =>
(...args) => {
const { mainSoftwareSillId, otherWikidataSoftwares } = props;
const { mainSoftwareSillId } = props;

const [dispatch] = args;

dispatch(
actions.step1Completed({
"step1Data": {
mainSoftwareSillId,
otherWikidataSoftwares
}
"step1Data": { mainSoftwareSillId }
})
);
},
Expand All @@ -155,9 +148,6 @@ export const thunks = {
const formData: ApiTypes.InstanceFormData = {
"mainSoftwareSillId": step1Data.mainSoftwareSillId,
organization,
"otherSoftwareWikidataIds": step1Data.otherWikidataSoftwares.map(
({ externalId }) => externalId
),
publicUrl,
targetAudience
};
Expand Down
8 changes: 3 additions & 5 deletions web/src/ui/pages/instanceForm/InstanceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,14 @@ export default function InstanceForm(props: Props) {
<InstanceFormStep1
className={cx(classes.step, classes.step1)}
initialFormData={{
"mainSoftwareSillId": initializationData.mainSoftwareSillId,
"otherWikidataSoftwares": initializationData.otherSoftwares
"mainSoftwareSillId": initializationData.mainSoftwareSillId
}}
getLibreSoftwareWikidataOptions={queryString =>
getExternalSoftwareOptions({ queryString, "language": lang })
}
onSubmit={({ mainSoftwareSillId, otherWikidataSoftwares }) =>
onSubmit={({ mainSoftwareSillId }) =>
instanceForm.completeStep1({
mainSoftwareSillId,
otherWikidataSoftwares
mainSoftwareSillId
})
}
allSillSoftwares={allSillSoftwares}
Expand Down
12 changes: 3 additions & 9 deletions web/src/ui/pages/instanceForm/Step1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ export type Step1Props = {
className?: string;
initialFormData: {
mainSoftwareSillId: number | undefined;
otherWikidataSoftwares: WikidataEntry[];
};
onSubmit: (formData: {
mainSoftwareSillId: number;
otherWikidataSoftwares: WikidataEntry[];
}) => void;
onSubmit: (formData: { mainSoftwareSillId: number }) => void;
allSillSoftwares: {
softwareName: string;
softwareSillId: number;
Expand Down Expand Up @@ -77,8 +73,7 @@ export function InstanceFormStep1(props: Step1Props) {
assert(mainSoftware !== undefined);

return mainSoftware;
})(),
"otherWikidataSoftwares": initialFormData.otherWikidataSoftwares
})()
}
});

Expand All @@ -101,8 +96,7 @@ export function InstanceFormStep1(props: Step1Props) {
className={className}
onSubmit={handleSubmit(data =>
onSubmit({
"mainSoftwareSillId": data.mainSoftware.softwareSillId,
"otherWikidataSoftwares": data.otherWikidataSoftwares
"mainSoftwareSillId": data.mainSoftware.softwareSillId
})
)}
>
Expand Down

0 comments on commit 9063734

Please sign in to comment.