Skip to content

Commit

Permalink
(wip) refactor: Update language handling in FormProvider and schema.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kariamos committed Oct 15, 2024
1 parent 75d0bb3 commit 1b03de3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 40 deletions.
6 changes: 2 additions & 4 deletions src/pages/campaigns/components/campaignForm/FormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const FormProvider = ({
deviceTypes: selectedTypes,
deviceList: selectedDevices,
countries: dossier?.countries || [],
languages: dossier?.languages?.map((lang) => lang.id.toString()) || [],
languages: dossier?.languages?.map((lang) => lang.name) || [],
description: dossier?.description || "",
productLink: dossier?.productLink || "",
goal: dossier?.goal || "",
Expand Down Expand Up @@ -233,9 +233,7 @@ const FormProvider = ({
deviceList: values.deviceList.map((device) => parseInt(device, 10)),
csm: parseInt(values.csm),
roles: roles,
languages: values.languages.map((language) =>
parseInt(language, 10)
),
languages: values.languages.map((language) => language),
countries: values.countries,
description: values.description,
productLink: values.productLink,
Expand Down
89 changes: 53 additions & 36 deletions src/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,19 +805,17 @@ export interface components {
short_name?: string;
} & (
| {
/** @enum {string} */
type: "text" | "gender" | "phone_number" | "address";
type: components["schemas"]["PreselectionQuestionSimple"];
}
| {
/** @enum {string} */
type: "multiselect" | "select" | "radio";
options: {
type: components["schemas"]["PreselectionQuestionMultiple"];
options?: {
value: string;
isInvalid?: boolean;
}[];
}
| {
type: string;
type: components["schemas"]["PreselectionQuestionCuf"];
options?: {
value: number;
isInvalid?: boolean;
Expand Down Expand Up @@ -942,11 +940,23 @@ export interface components {
cap?: number;
};
countries?: components["schemas"]["CountryCode"][];
languages?: number[];
languages?: string[];
browsers?: number[];
productType?: number;
notes?: string;
};
/**
* PreselectionQuestionSimple
* @enum {string}
*/
PreselectionQuestionSimple: "gender" | "text" | "phone_number" | "address";
/**
* PreselectionQuestionMultiple
* @enum {string}
*/
PreselectionQuestionMultiple: "multiselect" | "select" | "radio";
/** PreselectionQuestionCuf */
PreselectionQuestionCuf: string;
};
responses: {
/** A user */
Expand Down Expand Up @@ -1966,8 +1976,6 @@ export interface operations {
200: {
content: {
"application/json": {
/** @enum {string} */
status: "draft" | "published" | "draft-modified";
goal: string;
usersNumber: number;
sentiments: {
Expand All @@ -1989,6 +1997,7 @@ export interface operations {
id: number;
name: string;
}[];
visible: number;
};
};
};
Expand All @@ -2015,30 +2024,25 @@ export interface operations {
};
requestBody: {
content: {
"application/json":
| {
goal: string;
usersNumber: number;
sentiments: {
id?: number;
clusterId: number;
value: number;
comment: string;
}[];
methodology: {
/** @enum {string} */
type: "qualitative" | "quantitative" | "quali-quantitative";
description: string;
};
questions: {
id?: number;
name: string;
}[];
}
| {
/** @enum {string} */
status: "publish";
};
"application/json": {
goal?: string;
usersNumber?: number;
visible?: number;
methodology?: {
description: string;
type: string;
};
sentiments?: {
clusterId: number;
value: number;
comment: string;
id?: number;
}[];
questions?: {
name: string;
id?: number;
}[];
};
};
};
};
Expand Down Expand Up @@ -3305,7 +3309,9 @@ export interface operations {
/** OK */
200: {
content: {
"application/json": (components["schemas"]["PreselectionFormQuestion"] & {
"application/json": ({
question: string;
short_name?: string;
value?:
| number
| {
Expand All @@ -3319,7 +3325,19 @@ export interface operations {
error?: string;
};
id: number;
})[];
} & (
| {
type: components["schemas"]["PreselectionQuestionSimple"];
}
| {
type: components["schemas"]["PreselectionQuestionMultiple"];
options: string[];
}
| {
type: components["schemas"]["PreselectionQuestionCuf"];
options?: number[];
}
))[];
};
};
403: components["responses"]["NotAuthorized"];
Expand Down Expand Up @@ -4195,7 +4213,6 @@ export interface operations {
};
countries?: components["schemas"]["CountryCode"][];
languages?: {
id: number;
name: string;
}[];
browsers?: {
Expand Down

0 comments on commit 1b03de3

Please sign in to comment.