Skip to content

Commit

Permalink
refactor: better definition between the upload calls for both a prima…
Browse files Browse the repository at this point in the history
…ry and an additional driver (#409)

* chore: remove console.log(...)

* refactor: better definition between the upload calls for a primary vs an additional driver
  • Loading branch information
SeanCassiere authored Aug 5, 2024
1 parent bde3aee commit e510544
Showing 1 changed file with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ function AdditionalDriverSignaturePopover(props: BaseDriverProps) {
})
);

console.log(props.driver.driverName, signatureQuery.data);

const data =
signatureQuery.data.status === 200 ? signatureQuery.data.body : null;

Expand Down Expand Up @@ -469,8 +467,29 @@ function SignatureDialog(

signaturePadRef.current?.off();

const fallbackName =
props.submitMode === "primary" ? "Driver" : "Additional driver";
let fallbackName = "Driver";

if (props.submitMode === "primary") {
uploadSignature.mutate({
body: {
agreementId: props.agreementId,
base64String: dataUrl,
imageName: props.driver.driverId.toString(),
imageType: ".jpg",
isDamageView: false,
reservationId: 0,
signatureDate: new Date().toISOString(),
signatureImage: null,
signatureName: props.driver.driverName || fallbackName,

isCheckIn: props.stage === "checkin",
driverId: props.driver.driverId.toString(),
},
});
return;
}

fallbackName = "Additional driver";

uploadSignature.mutate({
body: {
Expand All @@ -484,22 +503,9 @@ function SignatureDialog(
signatureImage: null,
signatureName: props.driver.driverName || fallbackName,

...(props.submitMode === "primary"
? {
isCheckIn: props.stage === "checkin",
}
: {
// checkin needs to always be false for additional drivers
isCheckIn: false,
}),

...(props.submitMode === "primary"
? {
driverId: props.driver.driverId.toString(),
}
: {
additionalDriverId: props.driver.driverId.toString(),
}),
// checkin needs to always be false for additional drivers
isCheckIn: false,
additionalDriverId: props.driver.driverId.toString(),
},
});
};
Expand Down

0 comments on commit e510544

Please sign in to comment.