Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Asset tab facility and location badges are malfunctioning #6474

Merged
merged 9 commits into from
Oct 26, 2023
11 changes: 10 additions & 1 deletion src/Components/Assets/AssetsList.tsx
Pranshu1902 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const AssetsList = () => {
const [asset_type, setAssetType] = useState<string>();
const [status, setStatus] = useState<string>();
const [facilityName, setFacilityName] = useState<string>();
const [facility_location, setLocation] = useState("");
const [asset_class, setAssetClass] = useState<string>();
const [importAssetModalOpen, setImportAssetModalOpen] = useState(false);
const assetsExist = assets.length > 0 && Object.keys(assets[0]).length > 0;
Expand Down Expand Up @@ -88,6 +89,10 @@ const AssetsList = () => {
prefetch: !!qParams.facility,
});

useEffect(() => {
setFacilityName(qParams.facility);
}, [qParams.facility]);

useEffect(() => {
setAssetType(qParams.asset_type);
}, [qParams.asset_type]);
Expand All @@ -108,6 +113,10 @@ const AssetsList = () => {
prefetch: !!(qParams.facility && qParams.location),
});

useEffect(() => {
setLocation(location?.name ?? "");
}, [location]);
Pranshu1902 marked this conversation as resolved.
Show resolved Hide resolved

const getAssetIdFromQR = async (assetUrl: string) => {
try {
setIsLoading(true);
Expand Down Expand Up @@ -370,7 +379,7 @@ const AssetsList = () => {
value("Asset Type", "asset_type", asset_type ?? ""),
value("Asset Class", "asset_class", asset_class ?? ""),
value("Status", "status", status?.replace(/_/g, " ") ?? ""),
value("Location", "location", location?.name ?? ""),
value("Location", "location", facility_location ?? ""),
value(
"Warranty AMC End Of Validity Before",
"warranty_amc_end_of_validity_before",
Expand Down
Loading