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 => { const response = await client.get(SIGNATURE_URL); return (unwrap(response.data) as SavedSignature | null) ?? null; }, saveMySignature: async ( payload: SaveSignaturePayload, ): Promise => { const response = await client.put( SIGNATURE_URL, payload, ); return (unwrap(response.data) as SavedSignature | null) ?? null; }, };