Files
edr-platform/apps/edr-freight-web/backoffice/src/services/signatures.service.ts

41 lines
1.3 KiB
TypeScript

import { api as client } from "../auth/http";
import { unwrap } from "@/utils/endpoint";
const SIGNATURE_URL = "/me/signature";
export interface SavedSignature {
signerDisplayName: string;
signatureImageUrl?: string | null;
stampImageUrl?: string | null;
}
/**
* Signature only. A backoffice employee has no personal stamp — EDR seals with
* the one global company stamp managed under Settings — so the stamp half of
* PUT /me/signature is deliberately not exposed here, even though the shared
* endpoint still accepts it for portal (customer) users.
*/
export interface SaveSignaturePayload {
signerDisplayName: string;
/** Omit to keep the existing saved signature. */
signatureImageBase64?: string;
}
export const signaturesService = {
/** Returns the current user's reusable signature, or null if none saved. */
getMySignature: async (): Promise<SavedSignature | null> => {
const response = await client.get<SavedSignature | null>(SIGNATURE_URL);
return (unwrap(response.data) as SavedSignature | null) ?? null;
},
saveMySignature: async (
payload: SaveSignaturePayload,
): Promise<SavedSignature | null> => {
const response = await client.put<SavedSignature | null>(
SIGNATURE_URL,
payload,
);
return (unwrap(response.data) as SavedSignature | null) ?? null;
},
};