Skip to content

Commit

Permalink
HideAssetType
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamprakash123 committed Dec 9, 2023
1 parent 1e37ee4 commit 1341137
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 66 deletions.
17 changes: 0 additions & 17 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 } = props;
const [facility, setFacility] = useState<FacilityModel>({ name: "" });
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 @@ -55,7 +52,6 @@ function AssetFilter(props: any) {

const clearFilter = useCallback(() => {
setFacility({ name: "" });
setAssetType("");
setAssetStatus("");
setAssetClass("");
setFacilityId("");
Expand All @@ -69,7 +65,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 @@ -133,18 +128,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
45 changes: 1 addition & 44 deletions src/Components/Facility/AssetCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,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 @@ -199,7 +197,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 @@ -241,12 +238,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 @@ -304,7 +295,6 @@ const AssetCreate = (props: AssetProps) => {
setName("");
setDescription("");
setLocation("");
setAssetType(assetTypeInitial);
setAssetClass(assetClassInitial);
setIsWorking(undefined);
setNotWorkingReason("");
Expand All @@ -329,7 +319,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 @@ -567,40 +557,7 @@ 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"]}
Expand Down

0 comments on commit 1341137

Please sign in to comment.