From 855de50022bd785313f14bd02fa4a9efb31a7438 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:14:44 +0530 Subject: [PATCH] fixes to warranty_amc_end_of_validity --- src/Common/constants.tsx | 8 ++++++-- src/Components/Assets/AssetImportModal.tsx | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 5e104972a2a..e51494f6bac 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -966,7 +966,9 @@ export const XLSXAssetImportSchema = { type: String, parse: (date: string) => { if (!date) return null; - const parsed = new Date(date); + const parts = date.split("-"); + const reformattedDateStr = `${parts[2]}-${parts[1]}-${parts[0]}`; + const parsed = new Date(reformattedDateStr); if (String(parsed) === "Invalid Date") { throw new Error("Invalid Warranty End Date:" + date); @@ -980,7 +982,9 @@ export const XLSXAssetImportSchema = { type: String, parse: (date: string) => { if (!date) return null; - const parsed = new Date(date); + const parts = date.split("-"); + const reformattedDateStr = `${parts[2]}-${parts[1]}-${parts[0]}`; + const parsed = new Date(reformattedDateStr); if (String(parsed) === "Invalid Date") { throw new Error("Invalid Last Service Date:" + date); diff --git a/src/Components/Assets/AssetImportModal.tsx b/src/Components/Assets/AssetImportModal.tsx index aa9547bd649..7382c7eff4f 100644 --- a/src/Components/Assets/AssetImportModal.tsx +++ b/src/Components/Assets/AssetImportModal.tsx @@ -129,13 +129,16 @@ const AssetImportModal = ({ open, onClose, facility }: Props) => { qr_code_id: asset.qr_code_id, manufacturer: asset.manufacturer, meta: { ...asset.meta }, - warranty_amc_end_of_validity: asset.warranty_amc_end_of_validity, note: asset.notes, }; if (asset.last_serviced_on) asset_data["last_serviced_on"] = asset.last_serviced_on; + if (asset.warranty_amc_end_of_validity) + asset_data["warranty_amc_end_of_validity"] = + asset.warranty_amc_end_of_validity; + const response = await fetch("/api/v1/asset/", { method: "POST", headers: {