Skip to content

Commit

Permalink
adding suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkurPrabhu committed May 4, 2024
1 parent 9548c38 commit 5292ed9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ const AssetsList = () => {
return data?.results[0].id;
} else {
Notification.Error({
msg: t("Oops! The asset ID you entered does not appear to be valid."),
msg: t("invalid_asset_id_msg"),
});
}
} catch (err) {
console.log(err);
Notification.Error({
msg: t("Oops! The asset ID you entered does not appear to be valid."),
msg: t("invalid_asset_id_msg"),
});
} finally {
setIsLoading(false);
Expand All @@ -139,7 +139,7 @@ const AssetsList = () => {
try {
if (assetData) {
navigate(
`/facility/${assetData.location_object.facility?.id}/assets/${assetId}`
`/facility/${assetData.location_object.facility?.id}/assets/${assetId}`,
);
}
} catch (err) {
Expand All @@ -152,7 +152,7 @@ const AssetsList = () => {
};

const authorizedForImportExport = useIsAuthorized(
AuthorizeFor(["DistrictAdmin", "StateAdmin"])
AuthorizeFor(["DistrictAdmin", "StateAdmin"]),
);

if (isScannerActive)
Expand Down Expand Up @@ -401,25 +401,25 @@ const AssetsList = () => {
value(
"Facility",
"facility",
qParams.facility && facilityObject?.name
qParams.facility && facilityObject?.name,
),
badge("Name/Serial No./QR ID", "search"),
value("Asset Class", "asset_class", asset_class ?? ""),
value("Status", "status", status?.replace(/_/g, " ") ?? ""),
value(
"Location",
"location",
qParams.location && locationObject?.name
qParams.location && locationObject?.name,
),
value(
"Warranty AMC End Of Validity Before",
"warranty_amc_end_of_validity_before",
qParams.warranty_amc_end_of_validity_before ?? ""
qParams.warranty_amc_end_of_validity_before ?? "",
),
value(
"Warranty AMC End Of Validity After",
"warranty_amc_end_of_validity_after",
qParams.warranty_amc_end_of_validity_after ?? ""
qParams.warranty_amc_end_of_validity_after ?? "",
),
]}
/>
Expand Down Expand Up @@ -479,15 +479,16 @@ const AssetsList = () => {
};

export const warrantyAmcValidityChip = (
warranty_amc_end_of_validity: string
warranty_amc_end_of_validity: string,
) => {
if (warranty_amc_end_of_validity === "" || !warranty_amc_end_of_validity)
return;
const today = new Date();
const warrantyAmcEndDate = new Date(warranty_amc_end_of_validity);

const days = Math.ceil(
Math.abs(Number(warrantyAmcEndDate) - Number(today)) / (1000 * 60 * 60 * 24)
Math.abs(Number(warrantyAmcEndDate) - Number(today)) /
(1000 * 60 * 60 * 24),
);

if (warrantyAmcEndDate < today) {
Expand Down
3 changes: 2 additions & 1 deletion src/Locale/en/Notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"unsubscribe_failed": "Unsubscribe failed.",
"unsubscribe": "Unsubscribe",
"escape": "Escape",
"loading": "Loading..."
"loading": "Loading...",
"invalid_asset_id_msg": "Oops! The asset ID you entered does not appear to be valid."
}

0 comments on commit 5292ed9

Please sign in to comment.