refactor: Update response message checks and improve zone name duplication logic across components
This commit is contained in:
parent
60064f095a
commit
d80d5ae161
|
@ -33,9 +33,6 @@ const SideBarLeft: React.FC = () => {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('isVersionSaved: ', isVersionSaved);
|
|
||||||
console.log('toggleUILeft: ', toggleUILeft);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`sidebar-left-wrapper ${toggleUILeft && (!isVersionSaved || activeModule !== "simulation") ? "open" : "closed"
|
className={`sidebar-left-wrapper ${toggleUILeft && (!isVersionSaved || activeModule !== "simulation") ? "open" : "closed"
|
||||||
|
|
|
@ -37,7 +37,7 @@ const ZoneProperties: React.FC = () => {
|
||||||
|
|
||||||
let response = await zoneCameraUpdate(zonesdata, organization,projectId);
|
let response = await zoneCameraUpdate(zonesdata, organization,projectId);
|
||||||
console.log('response: ', response);
|
console.log('response: ', response);
|
||||||
if (response.message === "updated successfully") {
|
if (response.message === "zone updated") {
|
||||||
setEdit(false);
|
setEdit(false);
|
||||||
} else {
|
} else {
|
||||||
// console.log(response);
|
// console.log(response);
|
||||||
|
@ -60,9 +60,8 @@ const ZoneProperties: React.FC = () => {
|
||||||
};
|
};
|
||||||
// Call your API to update the zone
|
// Call your API to update the zone
|
||||||
let response = await zoneCameraUpdate(zonesdata, organization,projectId);
|
let response = await zoneCameraUpdate(zonesdata, organization,projectId);
|
||||||
console.log('response: ', response);
|
setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
|
||||||
// console.log("response: ", response);
|
if (response.message === "zone updated") {
|
||||||
if (response.message === "updated successfully") {
|
|
||||||
setZones((prevZones: any[]) =>
|
setZones((prevZones: any[]) =>
|
||||||
prevZones.map((zone) =>
|
prevZones.map((zone) =>
|
||||||
zone.zoneUuid === selectedZone.zoneUuid
|
zone.zoneUuid === selectedZone.zoneUuid
|
||||||
|
@ -83,7 +82,7 @@ const ZoneProperties: React.FC = () => {
|
||||||
const checkZoneNameDuplicate = (name: string) => {
|
const checkZoneNameDuplicate = (name: string) => {
|
||||||
return zones.some(
|
return zones.some(
|
||||||
(zone: any) =>
|
(zone: any) =>
|
||||||
zone.zoneName.trim().toLowerCase() === name.trim().toLowerCase() &&
|
zone.zoneName?.trim().toLowerCase() === name?.trim().toLowerCase() &&
|
||||||
zone.zoneUuid !== selectedZone.zoneUuid
|
zone.zoneUuid !== selectedZone.zoneUuid
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,6 @@ import {
|
||||||
} from "../../../store/builder/store";
|
} from "../../../store/builder/store";
|
||||||
import { zoneCameraUpdate } from "../../../services/visulization/zone/zoneCameraUpdation";
|
import { zoneCameraUpdate } from "../../../services/visulization/zone/zoneCameraUpdation";
|
||||||
import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
|
import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
|
||||||
import OuterClick from "../../../utils/outerClick";
|
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { useAssetsStore } from "../../../store/builder/useAssetStore";
|
import { useAssetsStore } from "../../../store/builder/useAssetStore";
|
||||||
|
|
||||||
|
@ -111,7 +110,7 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
||||||
|
|
||||||
const isDuplicate = zones.some(
|
const isDuplicate = zones.some(
|
||||||
(zone: any) =>
|
(zone: any) =>
|
||||||
zone.zoneName.trim().toLowerCase() === newName.trim().toLowerCase() &&
|
zone.zoneName?.trim().toLowerCase() === newName?.trim().toLowerCase() &&
|
||||||
zone.zoneUuid !== selectedZone.zoneUuid
|
zone.zoneUuid !== selectedZone.zoneUuid
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
||||||
|
|
||||||
const response = await zoneCameraUpdate(zonesdata, organization,projectId);
|
const response = await zoneCameraUpdate(zonesdata, organization,projectId);
|
||||||
console.log('response: ', response);
|
console.log('response: ', response);
|
||||||
if (response.message === "updated successfully") {
|
if (response.message === "zone updated") {
|
||||||
setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
|
setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
|
||||||
|
|
||||||
setZones((prevZones: any[]) =>
|
setZones((prevZones: any[]) =>
|
||||||
|
@ -158,7 +157,7 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
||||||
const checkZoneNameDuplicate = (name: string) => {
|
const checkZoneNameDuplicate = (name: string) => {
|
||||||
return zones.some(
|
return zones.some(
|
||||||
(zone: any) =>
|
(zone: any) =>
|
||||||
zone.zoneName.trim().toLowerCase() === name.trim().toLowerCase() &&
|
zone.zoneName?.trim().toLowerCase() === name?.trim().toLowerCase() &&
|
||||||
zone.zoneUuid !== selectedZone.zoneUuid
|
zone.zoneUuid !== selectedZone.zoneUuid
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue