-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: view agreement signature and driver signing status (#405)
* feat: view for seeing the status of checkout and checkin signature states * feat: view agreement customer signature and signature status * refactor: reduce unnecessary use of `cn` * chore: upgrade tanstack router to 1.46.4
- Loading branch information
1 parent
12fa5fb
commit f5a0777
Showing
8 changed files
with
396 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { z } from "zod"; | ||
|
||
import { c } from "@/lib/api/c"; | ||
import { DigitalSignatureDriverSchema } from "@/lib/schemas/digital-signature/driverList"; | ||
|
||
import { StructuredErrorSchema, UnauthorizedErrorSchema } from "./helpers"; | ||
|
||
const rootDigitalSignatureContract = c.router({ | ||
getDriversList: { | ||
method: "GET", | ||
path: "/v3/digitalsignature/additionaldriverlist", | ||
query: z.object({ | ||
agreementId: z.string().optional(), | ||
reservationId: z.string().optional(), | ||
}), | ||
responses: { | ||
200: z.array(DigitalSignatureDriverSchema), | ||
}, | ||
}, | ||
getDigitalSignatureImageUrl: { | ||
method: "POST", | ||
path: "/v3/digitalsignature/reloadsignatureimageurl", | ||
responses: { | ||
200: z.string(), | ||
204: z.string().or(z.undefined()), | ||
401: UnauthorizedErrorSchema, | ||
404: StructuredErrorSchema, | ||
}, | ||
body: z.object({ | ||
isCheckin: z.boolean(), | ||
agreementId: z.string(), | ||
signatureImageUrl: z.string(), | ||
}), | ||
}, | ||
}); | ||
|
||
export { rootDigitalSignatureContract }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { queryOptions } from "@tanstack/react-query"; | ||
|
||
import { apiClient } from "@/lib/api"; | ||
|
||
import { isEnabled, makeQueryKey } from "./helpers"; | ||
import type { Auth, Enabled } from "./helpers"; | ||
|
||
const SEGMENT = "digital_signature"; | ||
|
||
export function fetchDigitalSignatureDriversList( | ||
options: { | ||
agreementId?: string; | ||
reservationId?: string; | ||
} & Auth & | ||
Enabled | ||
) { | ||
const { enabled = true } = options; | ||
|
||
return queryOptions({ | ||
queryKey: makeQueryKey(options, [ | ||
SEGMENT, | ||
options.agreementId | ||
? `agreement_${options.agreementId}` | ||
: `reservation_${options.reservationId}`, | ||
]), | ||
queryFn: () => | ||
apiClient.digitalSignature | ||
.getDriversList({ | ||
query: { | ||
agreementId: options.agreementId, | ||
reservationId: options.reservationId, | ||
}, | ||
}) | ||
.then((res) => ({ ...res, headers: null })), | ||
enabled: isEnabled(options) && enabled, | ||
}); | ||
} | ||
|
||
export function fetchAgreementDigitalSignatureUrl( | ||
options: { | ||
agreementId: string; | ||
driverId: string | null; | ||
isCheckin: boolean; | ||
signatureImageUrl: string; | ||
} & Auth & | ||
Enabled | ||
) { | ||
const { enabled = true } = options; | ||
|
||
return queryOptions({ | ||
queryKey: makeQueryKey(options, [ | ||
SEGMENT, | ||
`agreement_${options.agreementId}`, | ||
options.driverId || "no-driver-id", | ||
`checkin_${options.isCheckin}`, | ||
]), | ||
queryFn: () => | ||
apiClient.digitalSignature | ||
.getDigitalSignatureImageUrl({ | ||
body: { | ||
agreementId: options.agreementId, | ||
isCheckin: options.isCheckin, | ||
signatureImageUrl: options.signatureImageUrl, | ||
}, | ||
}) | ||
.then((res) => ({ ...res, headers: null })), | ||
enabled: isEnabled(options) && enabled, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { z } from "zod"; | ||
|
||
export const DigitalSignatureDriverSchema = z.object({ | ||
driverId: z.number(), | ||
agreementId: z.number().nullable(), | ||
customerId: z.number().nullable(), | ||
driverName: z.string().nullable(), | ||
firstName: z.string().nullable(), | ||
lastName: z.string().nullable(), | ||
dateOfBirth: z.string().nullable(), | ||
driverType: z.number(), | ||
createdBy: z.coerce.string().nullable(), | ||
licenseNumber: z.string().nullable(), | ||
licenseCategory: z.string().nullable(), | ||
licenseExpiryDate: z.string().nullable(), | ||
email: z.string().nullable(), | ||
licenseIssueDate: z.string().nullable(), | ||
licenseIssueState: z.string().nullable(), | ||
hPhone: z.string().nullable(), | ||
bPhone: z.string().nullable(), | ||
cPhone: z.string().nullable(), | ||
address: z.string().nullable(), | ||
city: z.string().nullable(), | ||
stateId: z.number().nullable(), | ||
zipCode: z.string().nullable(), | ||
countryId: z.number().nullable(), | ||
signatureName: z.string().nullable(), | ||
signatureImageUrl: z.string().nullable(), | ||
reservationId: z.number().nullable(), | ||
insuranceCompany: z.string().nullable(), | ||
checkForDelete: z.number().nullable(), | ||
dateofBirth: z.string().nullable(), | ||
dateofBirthStr: z.string().nullable(), | ||
createdDate: z.string().nullable(), | ||
updatedDate: z.string().nullable(), | ||
updateBy: z.coerce.string().nullable(), | ||
driverLicenseNumber: z.string().nullable(), | ||
driverLicenseCategory: z.string().nullable(), | ||
driverLicenseExpiryDate: z.string().nullable(), | ||
isDelete: z.boolean(), | ||
isFromCustomer: z.boolean(), | ||
phone: z.string().nullable(), | ||
signatureImageUrlString: z.string().nullable(), | ||
startDate: z.string().nullable(), | ||
endDate: z.string().nullable(), | ||
referenceType: z.string().nullable(), | ||
referenceId: z.coerce.string().nullable(), | ||
countryName: z.string().nullable(), | ||
signatureDate: z.string().nullable(), | ||
}); | ||
export type DigitalSignatureDriver = z.infer< | ||
typeof DigitalSignatureDriverSchema | ||
>; |
Oops, something went wrong.