Skip to content

Commit

Permalink
fix(import): rename fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Feb 20, 2024
1 parent 41b55b8 commit 7c4b3aa
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export type UsagerImportObject = {
liencommune?: string;
liencommuneDetail?: string;
typeMenage?: string;
situationResidentielle?: string;
situationResidentielleDetail?: string;
residence?: string;
residenceDetail?: string;
causeInstabilite?: string;
causeDetail?: string;
raisonDemande?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("UsagersImportCiviliteSchema invalid schema", () => {
domiciliationExistante: "NO",
revenus: "yes",
typeMenage: "invalid-typeMenage",
situationResidentielle: "invalid-situationResidentielle",
residence: "invalid-residence",
causeInstabilite: "invalid-causeInstabilite",
raisonDemande: "invalid-raisonDemande",
accompagnement: "n",
Expand All @@ -56,7 +56,7 @@ describe("UsagersImportCiviliteSchema invalid schema", () => {
"domiciliationExistante",
"revenus",
"typeMenage",
"situationResidentielle",
"residence",
"causeInstabilite",
"raisonDemande",
"accompagnement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ export const UsagersImportUsagerSchema = yup
liencommune: oneOfString(Object.keys(ENTRETIEN_LIEN_COMMUNE)).notRequired(),
liencommuneDetail: yup.string(),
typeMenage: oneOfString(Object.keys(ENTRETIEN_TYPE_MENAGE)).notRequired(),
situationResidentielle: oneOfString(
Object.keys(ENTRETIEN_RESIDENCE)
).notRequired(),
situationResidentielleDetail: yup.string().notRequired(),
residence: oneOfString(Object.keys(ENTRETIEN_RESIDENCE)).notRequired(),
residenceDetail: yup.string().notRequired(),
causeInstabilite: oneOfString(
Object.keys(ENTRETIEN_CAUSE_INSTABILITE)
).notRequired(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ describe("UsagersImportCiviliteSchema schema", () => {
liencommune: "SOCIAL",
liencommuneDetail: "Suivi social",
typeMenage: "FEMME_ISOLE_AVEC_ENFANT",
situationResidentielle: "HEBERGEMENT_TIERS",
situationResidentielleDetail: "",
residence: "HEBERGEMENT_TIERS",
residenceDetail: "",
causeInstabilite: "ERRANCE",
causeDetail: "détails cause",
raisonDemande: "EXERCICE_DROITS",
Expand Down Expand Up @@ -121,8 +121,8 @@ describe("UsagersImportCiviliteSchema schema", () => {
raisonDemandeDetail: "détails raison demande",
revenus: true,
revenusDetail: "détails revenus",
situationResidentielle: "HEBERGEMENT_TIERS",
situationResidentielleDetail: "détails situation",
residence: "HEBERGEMENT_TIERS",
residenceDetail: "détails situation",
statutDom: "REFUS",
typeDom: "RENOUVELLEMENT",
typeMenage: "FEMME_ISOLE_AVEC_ENFANT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const TEST_INVALID_IMPORT_USAGER: UsagerImportObject = {
liencommune: "SOCIAL",
liencommuneDetail: "suivi social",
typeMenage: "FEMME_ISOLE_AVEC_ENFANT",
situationResidentielle: "HEBERGEMENT_TIERS",
situationResidentielleDetail: "détails situation",
residence: "HEBERGEMENT_TIERS",
residenceDetail: "détails situation",
causeInstabilite: "ERRANCE",
causeDetail: "détails cause",
raisonDemande: "EXERCICE_DROITS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const TEST_VALID_IMPORT_ROW = [
"SOCIAL", // liencommune
"suivi social", // liencommune
"FEMME_ISOLE_AVEC_ENFANT", // typeMenage
"HEBERGEMENT_TIERS", // situationResidentielle
"détails situation", // situationResidentielleDetails
"HEBERGEMENT_TIERS", // residence
"détails situation", // residenceDetails
"ERRANCE", // causeInstabilite
"détails cause", // causeDetail
"EXERCICE_DROITS", // raisonDemande
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const TEST_VALID_IMPORT_USAGER: UsagerImportObject = {
liencommune: "SOCIAL",
liencommuneDetail: "Suivi social",
typeMenage: "FEMME_ISOLE_AVEC_ENFANT",
situationResidentielle: "HEBERGEMENT_TIERS",
situationResidentielleDetail: "",
residence: "HEBERGEMENT_TIERS",
residenceDetail: "",
causeInstabilite: "ERRANCE",
causeDetail: "détails cause",
raisonDemande: "EXERCICE_DROITS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const TEST_VALID_IMPORT_USAGER_REFUS: UsagerImportObject = {
raisonDemandeDetail: "détails raison demande",
revenus: "OUI",
revenusDetail: "détails revenus",
situationResidentielle: "HEBERGEMENT_TIERS",
situationResidentielleDetail: "détails situation",
residence: "HEBERGEMENT_TIERS",
residenceDetail: "détails situation",
statutDom: "REFUS",
surnom: undefined,
typeDom: "RENOUVELLEMENT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ describe("usagersImportValidator parse invalid data", () => {
"SOCIAL", // liencommune
"suivi social", // liencommune
"invalid-typeMenage", // typeMenage
"invalid-situationResidentielle", // situationResidentielle
"détails situation", // situationResidentielleDetail
"invalid-residence", // residence
"détails situation", // residenceDetail
"invalid-causeInstabilite", // causeInstabilite
"détails cause", // causeDetail
"invalid-raisonDemande", // raisonDemande
Expand Down Expand Up @@ -149,7 +149,7 @@ describe("usagersImportValidator parse invalid data", () => {
columnNumber: 28,
label: "Situation résidentielle",
rowNumber: 10,
value: "invalid-situationResidentielle",
value: "invalid-residence",
},
{
columnNumber: 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ describe("usagersImportValidator parse valid data", () => {
liencommune: "SOCIAL",
liencommuneDetail: "suivi social",
typeMenage: "FEMME_ISOLE_AVEC_ENFANT",
situationResidentielle: "HEBERGEMENT_TIERS",
situationResidentielleDetail: "détails situation",
residence: "HEBERGEMENT_TIERS",
residenceDetail: "détails situation",
causeInstabilite: "ERRANCE",
causeDetail: "détails cause",
raisonDemande: "EXERCICE_DROITS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,39 +175,38 @@ function buildEntretien(usagerRow): Partial<UsagerEntretien> {
entretien.accompagnementDetail = usagerRow.accompagnementDetail;
}

entretien.revenus = usagerRow.revenus;
if (usagerRow.revenus) {
entretien.revenusDetail = usagerRow.revenusDetail;
entretien.situationPro = usagerRow.situationPro ?? null;
if (usagerRow?.situationPro && usagerRow?.situationProDetail) {
entretien.situationProDetail = usagerRow.situationProDetail;
}
entretien.situationPro = usagerRow.situationPro;

entretien.revenus = usagerRow.revenus;
if (usagerRow.revenus) {
if (usagerRow?.revenus && usagerRow?.revenusDetail) {
entretien.revenusDetail = usagerRow.revenusDetail;
}

entretien.liencommune = usagerRow.liencommune;
if (usagerRow.liencommune) {
if (usagerRow?.liencommune && usagerRow?.liencommuneDetail) {
entretien.liencommuneDetail = usagerRow.liencommuneDetail;
}

entretien.residence = usagerRow.situationResidentielle;
if (usagerRow.situationResidentielle) {
entretien.residenceDetail = usagerRow.situationResidentielleDetail;
entretien.residence = usagerRow.residence ?? null;
if (usagerRow?.residence && usagerRow?.residenceDetaildentielle) {
entretien.residenceDetail = usagerRow.residenceDetail;
}

entretien.orientation = usagerRow.orientation;
if (usagerRow.orientation) {
if (usagerRow?.orientation && usagerRow?.orientationDetail) {
entretien.orientationDetail = usagerRow.orientationDetail;
}

entretien.raison = usagerRow.raisonDemande;
if (usagerRow.raisonDemande) {
entretien.raison = usagerRow.raisonDemande ?? null;
if (usagerRow?.raisonDemande && usagerRow?.raisonDemandeDetail) {
entretien.raisonDetail = usagerRow.raisonDemandeDetail;
}

entretien.cause = usagerRow.causeInstabilite;
if (usagerRow.causeInstabilite) {
entretien.cause = usagerRow.causeInstabilite ?? null;
if (usagerRow?.causeInst && usagerRow?.causeDetailabilite) {
entretien.causeDetail = usagerRow.causeDetail;
}
return entretien;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const USAGERS_IMPORT_COLUMNS: Record<
liencommune: { index: 24, label: "Lien avec la commune" },
liencommuneDetail: { index: 25, label: "Détail du lien avec la commune" },
typeMenage: { index: 26, label: "Composition du ménage" },
situationResidentielle: { index: 27, label: "Situation résidentielle" },
situationResidentielleDetail: {
residence: { index: 27, label: "Situation résidentielle" },
residenceDetail: {
index: 28,
label: "Si autre situation résidentielle, précisez",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,14 @@ <h2 class="text-danger">Votre fichier ne peut pas être importé !</h2>
</td>
<td
[ngClass]="{
'table-danger':
!row.columns[COL.situationResidentielle.index]?.isValid
'table-danger': !row.columns[COL.residence.index]?.isValid
}"
>
{{ row.columns[COL.situationResidentielle.index]?.value }}
{{ row.columns[COL.residence.index]?.value }}
</td>

<td>
{{ row.columns[COL.situationResidentielleDetail.index]?.value }}
{{ row.columns[COL.residenceDetail.index]?.value }}
</td>

<td
Expand Down

0 comments on commit 7c4b3aa

Please sign in to comment.