From 08fba15feec21a2146746bb0cf4957a86677e32b Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Tue, 14 Jul 2026 12:24:40 -0400 Subject: [PATCH] fix https://github.com/donetick/frontend/issues/95 --- src/views/Things/ThingsView.jsx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/views/Things/ThingsView.jsx b/src/views/Things/ThingsView.jsx index 4964f6f..3ab615a 100644 --- a/src/views/Things/ThingsView.jsx +++ b/src/views/Things/ThingsView.jsx @@ -355,6 +355,31 @@ const ThingsView = () => { }) } + const handleSetThingState = thing => { + UpdateThingState(thing) + .then(result => { + result.json().then(data => { + const currentThings = [...things] + const thingIndex = currentThings.findIndex( + currentThing => currentThing.id === thing.id, + ) + currentThings[thingIndex] = data.res + setThings(currentThings) + showNotification({ + type: 'success', + title: 'Updated', + message: 'Thing state updated successfully', + }) + }) + }) + .catch(error => { + showError({ + title: 'Unable to update thing state', + message: 'An error occurred while updating the thing state', + }) + }) + } + return ( @@ -550,7 +575,7 @@ const ThingsView = () => { setIsShowEditStateModal(false) setCreateModalThing(null) }} - onSave={handleStateChangeRequest} + onSave={handleSetThingState} currentThing={createModalThing} /> )}