From 58611908218c474e40bdced6ddb9eca51269369d Mon Sep 17 00:00:00 2001 From: Donkie Date: Wed, 20 Nov 2024 20:15:46 +0100 Subject: [PATCH] Fixed being able to create multiple locs of same name --- client/src/pages/locations/index.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/client/src/pages/locations/index.tsx b/client/src/pages/locations/index.tsx index 7083d7e..e8c61ba 100644 --- a/client/src/pages/locations/index.tsx +++ b/client/src/pages/locations/index.tsx @@ -305,6 +305,20 @@ function LocationMetaContainer() { return
Failed to load spools
; } + const addNewLocation = () => { + let newLocationName = "New Location"; + + const newLocs = [...locationsList]; + let i = 1; + while (newLocs.includes(newLocationName)) { + newLocationName = "New Location " + i; + i++; + } + newLocs.push(newLocationName); + + setLocationsSetting.mutate(newLocs); + }; + return (
{containers} @@ -317,7 +331,7 @@ function LocationMetaContainer() { style={{ margin: "1em", }} - onClick={() => setLocationsSetting.mutate([...settingsLocations, "New Location"])} + onClick={addNewLocation} />