Skip to content

Commit

Permalink
Allow vhu plates edition from signature modal and dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
providenz committed Jan 9, 2025
1 parent 2b7bc99 commit ab8a344
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 110 deletions.
2 changes: 2 additions & 0 deletions back/src/bsvhu/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export function expandVhuFormFromDb(form: PrismaVhuForm): GraphqlVhuForm {
mail: form.transporterCompanyMail,
vatNumber: form.transporterCompanyVatNumber
}),
customInfo: form.transporterCustomInfo,
recepisse: nullIfNoValues<BsvhuRecepisse>({
number: form.transporterRecepisseNumber,
department: form.transporterRecepisseDepartment,
Expand Down Expand Up @@ -370,6 +371,7 @@ function flattenVhuTransporterInput({
transporterCompanyVatNumber: chain(transporter, t =>
chain(t.company, c => c.vatNumber)
),
transporterCustomInfo: chain(transporter, t => t.customInfo),
transporterRecepisseNumber: chain(transporter, t =>
chain(t.recepisse, r => r.number)
),
Expand Down
2 changes: 2 additions & 0 deletions back/src/bsvhu/typeDefs/bsvhu.inputs.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ input BsvhuTransporterInput {
company: CompanyInput
"Récépissé transporteur"
recepisse: BsvhuRecepisseInput
"Champ libre"
customInfo: String
"Informations liés au transport"
transport: BsvhuTransportInput
}
Expand Down
2 changes: 2 additions & 0 deletions back/src/bsvhu/typeDefs/bsvhu.objects.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ type BsvhuTransporter {
company: FormCompany
"Récépissé transporteur"
recepisse: BsvhuRecepisse
"Champ libre"
customInfo: String
"Informations liés au transport"
transport: BsvhuTransport
}
Expand Down
6 changes: 5 additions & 1 deletion back/src/bsvhu/validation/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export type BsvhuEditableFields = Required<
| "emitterCustomInfo"
| "emitterNotOnTD"
| "destinationCustomInfo"
| "transporterCustomInfo"
| "emitterEmissionSignatureDate"
| "emitterEmissionSignatureAuthor"
| "transporterTransportSignatureDate"
Expand Down Expand Up @@ -541,6 +540,11 @@ export const bsvhuEditionRules: BsvhuEditionRules = {
}
}
},
transporterCustomInfo: {
readableFieldName:
"les champs d'informations complémentaires du transporteur",
sealed: { from: "TRANSPORT" }
},
ecoOrganismeName: {
readableFieldName: "le nom de l'éco-organisme",
sealed: { from: "OPERATION" },
Expand Down
1 change: 0 additions & 1 deletion back/src/bsvhu/validation/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ const rawBsvhuSchema = z.object({
)
.max(2, "Un maximum de 2 plaques d'immatriculation est accepté")
.default([]),

ecoOrganismeName: z.string().nullish(),
ecoOrganismeSiret: siretSchema(CompanyRole.EcoOrganisme).nullish(),
brokerCompanyName: z.string().nullish(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ function BsdCardList({
const hasAutomaticSignature = siretsWithAutomaticSignature?.includes(
node?.emitter?.company?.siret
);

return (
<li className="bsd-card-list__item" key={key}>
<BsdCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
MutationUpdateBsdasriArgs,
MutationUpdateBsffArgs,
MutationUpdateBspaohArgs,
MutationUpdateFormTransporterArgs
MutationUpdateFormTransporterArgs,
MutationUpdateBsvhuArgs
} from "@td/codegen-ui";
import TdModal from "../../../common/Components/Modal/Modal";
import { NotificationError } from "../../../common/Components/Error/Error";
Expand All @@ -20,6 +21,7 @@ import { UPDATE_BSDD_TRANSPORTER } from "../../../common/queries/bsdd/queries";
import { UPDATE_BSFF_FORM } from "../../../common/queries/bsff/queries";
import { UPDATE_BSDASRI } from "../../../common/queries/bsdasri/queries";
import { UPDATE_BSPAOH } from "../../../common/queries/bspaoh/queries";
import { UPDATE_VHU_FORM } from "../../../common/queries/bsvhu/queries";
import TransporterInfoEditForm from "./TransporterInfoEditForm";
import { Loader } from "../../../common/Components";

Expand Down Expand Up @@ -73,6 +75,13 @@ const TransporterInfoEditModal = ({
UPDATE_BSPAOH
);

const [
updateTransporterInfoBsvhu,
{ error: errorBsvhu, loading: loadingBsvhu }
] = useMutation<Pick<Mutation, "updateBsvhu">, MutationUpdateBsvhuArgs>(
UPDATE_VHU_FORM
);

const onSubmitForm = async data => {
if (bsd.type === BsdType.Bsdd) {
await updateTransporterInfoBsdd({
Expand Down Expand Up @@ -140,17 +149,35 @@ const TransporterInfoEditModal = ({
}
}
});
} else if (bsd.type === BsdType.Bsvhu) {
await updateTransporterInfoBsvhu({
variables: {
id: bsd.id,
input: {
transporter: {
customInfo: data.customInfo,
transport: { plates: formattedPlates }
}
}
}
});
}
};

const error =
errorBsdd || errorBsda || errorBsdasri || errorBsff || errorBspaoh;
errorBsdd ||
errorBsda ||
errorBsdasri ||
errorBsff ||
errorBspaoh ||
errorBsvhu;
const loading =
loadingBsdd ||
loadingBsda ||
loadingBsdasri ||
loadingBsff ||
loadingBspaoh;
loadingBspaoh ||
loadingBsvhu;

return (
<TdModal
Expand Down
Loading

0 comments on commit ab8a344

Please sign in to comment.