Skip to content

Commit

Permalink
fixes to warranty_amc_end_of_validity
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 committed Oct 3, 2023
1 parent 12f9c6f commit 855de50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Assets/AssetImportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 855de50

Please sign in to comment.