From c636737718272abb7a2ee7b1012fa6f4f88d17fa Mon Sep 17 00:00:00 2001 From: Carter Date: Wed, 19 Feb 2025 13:56:30 -0600 Subject: [PATCH] can now to npm run start-dev to run local front end with the development database --- package.json | 3 ++- src/group/GroupSettings.tsx | 8 +++++++- src/pages/Device.tsx | 9 --------- src/pages/Devices.tsx | 3 ++- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 969ed75..3210f7f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "start": "vite", "start-local": "VITE_APP_API_URL=http://localhost:50052/v1 VITE_APP_WS_URL=ws://localhost:50052/v1/live VITE_APP_BILLING_URL=http://localhost:50053/v1 VITE_APP_RECLUSE_URL=http://localhost:50054/v1 VITE_APP_GITLAB_URL=http://localhost:50055/v1 vite", - "start-dev": "VITE_APP_API_URL=https://bxt-dev.adaptiveagriculture.ca/v1 VITE_APP_WS_URL=ws://bxt-dev.adapticeagriculture.ca/v1/live vite", + "start-dev": "VITE_AUTH0_CLIENT_DOMAIN=brandxtech.auth0.com VITE_AUTH0_AUDIENCE=bxt-dev.api.adaptiveagriculture.ca VITE_AUTH0_DEV_CLIENT_ID=dzJTpqIeMA4Rwk4xujtwPbAO3TY32bM1 vite", + "start-staging": "REACT_APP_API_URL=https://stagingapi.brandxtech.ca/v1 REACT_APP_WS_URL=ws://stagingapi.brandxtech.ca/v1/live REACT_APP_AUTH0_CLIENT_DOMAIN=adaptivestaging.us.auth0.com REACT_APP_AUTH0_AUDIENCE=stagingapi.brandxtech.ca react-scripts start", "build": "tsc -b && vite build", "lint": "eslint .", "preview": "vite preview", diff --git a/src/group/GroupSettings.tsx b/src/group/GroupSettings.tsx index 9a00bd3..a289afb 100644 --- a/src/group/GroupSettings.tsx +++ b/src/group/GroupSettings.tsx @@ -116,6 +116,7 @@ export default function GroupSettings(props: Props) { } if (prevTabIndex !== 1 && tabIndex === 1) { + console.log("loading?") loadDevices(); } }, [initialGroup, loadDevices, prevInitialGroup, prevTabIndex, props, tabIndex, groupDevices]); @@ -310,7 +311,8 @@ export default function GroupSettings(props: Props) { changeDevices(device.id())} - checked={group.settings.devices.includes(device.id())} + // checked={group.settings.devices.includes(device.id())} + checked={groupDevices?.some(dev => dev.id() === device.id())} inputProps={{ "aria-labelledby": label }} disabled={!canEdit} /> @@ -331,12 +333,16 @@ export default function GroupSettings(props: Props) { const addDevice = (device: number) => { console.log("adding device?????") groupAPI.addDevice(group.id(), device).then(() => { + console.log("successfully added") refreshCallback(); + }).catch(() => { + console.log("Error adding") }); }; const removeDevice = (device: number) => { groupAPI.removeDevice(group.id(), device).then(() => { + console.log("successfully removed") refreshCallback(); }); }; diff --git a/src/pages/Device.tsx b/src/pages/Device.tsx index b289a44..2d3541b 100644 --- a/src/pages/Device.tsx +++ b/src/pages/Device.tsx @@ -42,15 +42,6 @@ export default function DevicePage() { const loadDevice = () => { if (loading) return - // if (state?.device && parseInt(state.device.settings.deviceId) === device.id()) return - // deviceAPI.get(deviceID, false, getContextKeys(), getContextTypes()).then(resp => { - // setDevice(Device.create(resp.data)) - // console.log(resp.data) - // }).catch(() => { - // snackbar.error("Error loading device.") - // }).finally(() => { - // setLoading(false) - // }) setLoading(true) deviceAPI.getPageData(deviceID, getContextKeys(), getContextTypes()).then(resp => { diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx index e0f2870..8d27f79 100644 --- a/src/pages/Devices.tsx +++ b/src/pages/Devices.tsx @@ -182,6 +182,7 @@ export default function Devices() { } const loadDevices = () => { + console.log("loading devices") setDevicesLoading(true) deviceAPI.list( limit, @@ -408,7 +409,7 @@ export default function Devices() { mode={groupSettingsMode} isDialogOpen={groupSettingsIsOpen} closeDialogCallback={closeGroupSettings} - refreshCallback={loadGroups} + refreshCallback={loadDevices} canEdit={true} />