Skip to content

Commit

Permalink
hideAssetType
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamprakash123 committed Feb 7, 2024
1 parent d858690 commit 086b6a3
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 138 deletions.
2 changes: 0 additions & 2 deletions cypress/e2e/assets_spec/asset_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ describe("Asset Tab", () => {
it("Filter Asset", () => {
assetFilters.filterAssets(
"Dummy Facility 40",
"INTERNAL",
"ACTIVE",
"ONVIF Camera",
"Camera Loc"
);
assetFilters.clickadvancefilter();
assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters
assetFilters.assertFacilityText("Dummy Facility 40");
assetFilters.assertAssetTypeText("INTERNAL");
assetFilters.assertAssetClassText("ONVIF");
assetFilters.assertStatusText("ACTIVE");
assetFilters.assertLocationText("Camera Loc");
Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/assets_spec/assets_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe("Asset", () => {
assetPage.clickCreateAsset();

assetPage.verifyEmptyAssetNameError();
assetPage.verifyEmptyAssetTypeError();
assetPage.verifyEmptyLocationError();
assetPage.verifyEmptyStatusError();
assetPage.verifyEmptyPhoneError();
Expand All @@ -41,7 +40,6 @@ describe("Asset", () => {
assetPage.createAsset();
assetPage.selectFacility("Dummy Facility 40");
assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("ONVIF Camera");

const qr_id_1 = uuidv4();
Expand All @@ -68,7 +66,6 @@ describe("Asset", () => {
const qr_id_2 = uuidv4();

assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("ONVIF Camera");
assetPage.enterAssetDetails(
"New Test Asset 2",
Expand Down Expand Up @@ -141,7 +138,6 @@ describe("Asset", () => {
assetPage.createAsset();
assetPage.selectFacility("Dummy Facility 40");
assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("HL7 Vitals Monitor");

const qr_id_1 = uuidv4();
Expand Down
7 changes: 0 additions & 7 deletions cypress/e2e/sample_test_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ describe("Sample Filter", () => {
.click();
});

it("Filter by Asset Type", () => {
cy.get("#result").click();
cy.get("li[role='option']")
.contains(/^POSITIVE$/)
.click();
});

it("Filter by sample type", () => {
cy.get("#sample_type").click();
cy.get("li[role='option']")
Expand Down
15 changes: 0 additions & 15 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ export class AssetPage {
});
}

selectAssetType(assetType: string) {
cy.get("[data-testid=asset-type-input] button")
.click()
.then(() => {
cy.get("[role='option']").contains(assetType).click();
});
}

selectAssetClass(assetClass: string) {
cy.get("[data-testid=asset-class-input] button")
.click()
Expand Down Expand Up @@ -205,13 +197,6 @@ export class AssetPage {
);
}

verifyEmptyAssetTypeError() {
cy.get("[data-testid=asset-type-input] span").should(
"contain",
"Select an asset type"
);
}

verifyEmptyStatusError() {
cy.get("[data-testid=asset-working-status-input] span").should(
"contain",
Expand Down
9 changes: 0 additions & 9 deletions cypress/pageobject/Asset/AssetFilters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export class AssetFilters {
filterAssets(
facilityName: string,
assetType: string,
assetStatus: string,
assetClass: string,
assetLocation: string
Expand All @@ -13,11 +12,6 @@ export class AssetFilters {
.then(() => {
cy.get("[role='option']").contains(facilityName).click();
});
cy.get("#asset-type")
.click()
.then(() => {
cy.get("[role='option']").contains(assetType).click();
});
cy.get("#asset-status")
.click()
.then(() => {
Expand Down Expand Up @@ -65,9 +59,6 @@ export class AssetFilters {
assertFacilityText(text) {
cy.get("[data-testid=Facility]").should("contain", text);
}
assertAssetTypeText(text) {
cy.get("[data-testid='Asset Type']").should("contain", text);
}
assertAssetClassText(text) {
cy.get("[data-testid='Asset Class']").should("contain", text);
}
Expand Down
16 changes: 0 additions & 16 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const getDate = (value: any) =>
function AssetFilter(props: any) {
const { filter, onChange, closeFilter, removeFilters } = props;
const [facility, setFacility] = useState<FacilityModel | null>(null);
const [asset_type, setAssetType] = useState<string>(
filter.asset_type ? filter.asset_type : ""
);
const [asset_status, setAssetStatus] = useState<string>(filter.status || "");
const [asset_class, setAssetClass] = useState<string>(
filter.asset_class || ""
Expand Down Expand Up @@ -61,7 +58,6 @@ function AssetFilter(props: any) {
const applyFilter = () => {
const data = {
facility: facilityId,
asset_type: asset_type ?? "",
asset_class: asset_class ?? "",
status: asset_status ?? "",
location: locationId ?? "",
Expand Down Expand Up @@ -125,18 +121,6 @@ function AssetFilter(props: any) {
</div>
)}

<SelectFormField
label="Asset Type"
errorClassName="hidden"
id="asset-type"
name="asset_type"
options={["EXTERNAL", "INTERNAL"]}
optionLabel={(o) => o}
optionValue={(o) => o}
value={asset_type}
onChange={({ value }) => setAssetType(value)}
/>

<SelectFormField
id="asset-status"
name="asset_status"
Expand Down
5 changes: 0 additions & 5 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,6 @@ const AssetManage = (props: AssetManageProps) => {
{asset?.description}
</div>
<div className="flex flex-wrap gap-2">
{asset?.asset_type === "INTERNAL" ? (
<Chip text="Internal" startIcon="l-building" />
) : (
<Chip text="External" startIcon="l-globe" />
)}
{asset?.status === "ACTIVE" ? (
<Chip text="Active" startIcon="l-check" />
) : (
Expand Down
7 changes: 0 additions & 7 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const AssetsList = () => {
const [isScannerActive, setIsScannerActive] = useState(false);
const [totalCount, setTotalCount] = useState(0);
const [facility, setFacility] = useState<FacilityModel>();
const [asset_type, setAssetType] = useState<string>();
const [status, setStatus] = useState<string>();
const [asset_class, setAssetClass] = useState<string>();
const [importAssetModalOpen, setImportAssetModalOpen] = useState(false);
Expand All @@ -60,7 +59,6 @@ const AssetsList = () => {
offset: (qParams.page ? qParams.page - 1 : 0) * resultsPerPage,
search_text: qParams.search || "",
facility: qParams.facility || "",
asset_type: qParams.asset_type || "",
asset_class: qParams.asset_class || "",
location: qParams.facility ? qParams.location || "" : "",
status: qParams.status || "",
Expand Down Expand Up @@ -91,10 +89,6 @@ const AssetsList = () => {
prefetch: !!qParams.facility,
});

useEffect(() => {
setAssetType(qParams.asset_type);
}, [qParams.asset_type]);

useEffect(() => {
setStatus(qParams.status);
}, [qParams.status]);
Expand Down Expand Up @@ -380,7 +374,6 @@ const AssetsList = () => {
qParams.facility && facilityObject?.name
),
badge("Name/Serial No./QR ID", "search"),
value("Asset Type", "asset_type", asset_type ?? ""),
value("Asset Class", "asset_class", asset_class ?? ""),
value("Status", "status", status?.replace(/_/g, " ") ?? ""),
value(
Expand Down
101 changes: 28 additions & 73 deletions src/Components/Facility/AssetCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const Loading = lazy(() => import("../Common/Loading"));

const formErrorKeys = [
"name",
"asset_type",
"asset_class",
"description",
"is_working",
Expand Down Expand Up @@ -103,12 +102,10 @@ const AssetCreate = (props: AssetProps) => {
const { goBack } = useAppHistory();
const { facilityId, assetId } = props;

let assetTypeInitial: AssetType;
let assetClassInitial: AssetClass;

const [state, dispatch] = useReducer(asset_create_reducer, initialState);
const [name, setName] = useState("");
const [asset_type, setAssetType] = useState<AssetType>();
const [asset_class, setAssetClass] = useState<AssetClass>();
const [not_working_reason, setNotWorkingReason] = useState("");
const [description, setDescription] = useState("");
Expand Down Expand Up @@ -177,7 +174,6 @@ const AssetCreate = (props: AssetProps) => {
setName(asset.name);
setDescription(asset.description);
setLocation(asset.location_object.id!);
setAssetType(asset.asset_type);
setAssetClass(asset.asset_class);
setIsWorking(String(asset.is_working));
setNotWorkingReason(asset.not_working_reason);
Expand Down Expand Up @@ -219,12 +215,6 @@ const AssetCreate = (props: AssetProps) => {
invalidForm = true;
}
return;
case "asset_type":
if (!asset_type || asset_type == "NONE") {
errors[field] = "Select an asset type";
invalidForm = true;
}
return;
case "support_phone": {
if (!support_phone) {
errors[field] = "Field is required";
Expand Down Expand Up @@ -282,7 +272,6 @@ const AssetCreate = (props: AssetProps) => {
setName("");
setDescription("");
setLocation("");
setAssetType(assetTypeInitial);
setAssetClass(assetClassInitial);
setIsWorking(undefined);
setNotWorkingReason("");
Expand All @@ -307,7 +296,7 @@ const AssetCreate = (props: AssetProps) => {
setIsLoading(true);
const data: any = {
name: name,
asset_type: asset_type,
asset_type: AssetType.INTERNAL,
asset_class: asset_class || "",
description: description,
is_working: is_working,
Expand Down Expand Up @@ -547,68 +536,34 @@ const AssetCreate = (props: AssetProps) => {
errors={state.errors.location}
/>
</div>
{/* Asset Type */}
<div className="col-span-6 flex flex-col gap-x-12 transition-all lg:flex-row xl:gap-x-16">
<div
ref={fieldRef["asset_type"]}
className="flex-1"
data-testid="asset-type-input"
>
<SelectFormField
label={t("asset_type")}
name="asset_type"
required
options={[
{
title: "Internal",
description:
"Asset is inside the facility premises.",
value: AssetType.INTERNAL,
},
{
title: "External",
description:
"Asset is outside the facility premises.",
value: AssetType.EXTERNAL,
},
]}
value={asset_type}
optionLabel={({ title }) => title}
optionDescription={({ description }) => description}
optionValue={({ value }) => value}
onChange={({ value }) => setAssetType(value)}
error={state.errors.asset_type}
/>
</div>

{/* Asset Class */}
<div
ref={fieldRef["asset_class"]}
className="flex-1"
data-testid="asset-class-input"
>
<SelectFormField
disabled={!!(props.assetId && asset_class)}
name="asset_class"
label={t("asset_class")}
value={asset_class}
options={[
{ title: "ONVIF Camera", value: AssetClass.ONVIF },
{
title: "HL7 Vitals Monitor",
value: AssetClass.HL7MONITOR,
},
{
title: "Ventilator",
value: AssetClass.VENTILATOR,
},
]}
optionLabel={({ title }) => title}
optionValue={({ value }) => value}
onChange={({ value }) => setAssetClass(value)}
error={state.errors.asset_class}
/>
</div>
{/* Asset Class */}
<div
ref={fieldRef["asset_class"]}
className="col-span-6"
data-testid="asset-class-input"
>
<SelectFormField
disabled={!!(props.assetId && asset_class)}
name="asset_class"
label={t("asset_class")}
value={asset_class}
options={[
{ title: "ONVIF Camera", value: AssetClass.ONVIF },
{
title: "HL7 Vitals Monitor",
value: AssetClass.HL7MONITOR,
},
{
title: "Ventilator",
value: AssetClass.VENTILATOR,
},
]}
optionLabel={({ title }) => title}
optionValue={({ value }) => value}
onChange={({ value }) => setAssetClass(value)}
error={state.errors.asset_class}
/>
</div>
{/* Description */}
<div
Expand Down

0 comments on commit 086b6a3

Please sign in to comment.