forked from Yara724/api
update the 2 new apis for getting expertise and files of the request
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { ClaimCaseStatus } from "src/Types&Enums/claim-request-management/claim-case-status.enum";
|
||||
import {
|
||||
fanavaranAttachmentStatus,
|
||||
type FanavaranAttachmentStage,
|
||||
} from "./fanavaran-attachment-status";
|
||||
|
||||
export type FanavaranClaimReferences = {
|
||||
claimId?: number;
|
||||
@@ -12,10 +16,12 @@ export type FanavaranClaimReferences = {
|
||||
plaqueSampleId?: number;
|
||||
accidentVehicleUsedId?: number;
|
||||
insuranceCorpId?: number;
|
||||
fileIds?: number[];
|
||||
attachments?: ReturnType<typeof fanavaranAttachmentStatus>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fanavaran ids for v2 claim GET. Only on COMPLETED; each field is omitted when missing.
|
||||
* Claim reference codes appear on COMPLETED. Upload receipts/status are visible earlier.
|
||||
*/
|
||||
export function fanavaranClaimReferences(claim: {
|
||||
status?: string;
|
||||
@@ -26,13 +32,20 @@ export function fanavaranClaimReferences(claim: {
|
||||
fanavaranSync?: {
|
||||
baseClaim?: FanavaranReferenceStage | null;
|
||||
damageCase?: FanavaranReferenceStage | null;
|
||||
attachments?: FanavaranAttachmentStage | null;
|
||||
} | null;
|
||||
}): FanavaranClaimReferences | undefined {
|
||||
if (claim.status !== ClaimCaseStatus.COMPLETED) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const refs: FanavaranClaimReferences = {};
|
||||
const attachments = fanavaranAttachmentStatus(
|
||||
claim.fanavaranSync?.attachments,
|
||||
);
|
||||
if (attachments) {
|
||||
refs.fileIds = [...new Set(attachments.files.map((file) => file.fileId))];
|
||||
refs.attachments = attachments;
|
||||
}
|
||||
if (claim.status !== ClaimCaseStatus.COMPLETED) {
|
||||
return attachments ? refs : undefined;
|
||||
}
|
||||
if (claim.claimId != null) refs.claimId = claim.claimId;
|
||||
if (claim.claimNo != null) refs.claimNo = claim.claimNo;
|
||||
if (claim.dmgCaseId != null) refs.dmgCaseId = claim.dmgCaseId;
|
||||
@@ -45,8 +58,7 @@ export function fanavaranClaimReferences(claim: {
|
||||
refs.driverId = damageCase?.driverId ?? baseClaim?.driverId;
|
||||
}
|
||||
if ((damageCase?.vehicleKindId ?? baseClaim?.vehicleKindId) != null) {
|
||||
refs.vehicleKindId =
|
||||
damageCase?.vehicleKindId ?? baseClaim?.vehicleKindId;
|
||||
refs.vehicleKindId = damageCase?.vehicleKindId ?? baseClaim?.vehicleKindId;
|
||||
}
|
||||
if (damageCase?.plaqueKindId != null) {
|
||||
refs.plaqueKindId = damageCase.plaqueKindId;
|
||||
|
||||
Reference in New Issue
Block a user