diff --git a/src/App.tsx b/src/App.tsx index c2e03c8..88f2c79 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -29,67 +29,70 @@ export const App : React.FC = () => { const formSubmit = async () => { const newst = addEntry(store, {variant: "eats", date: new Date().toString(), item: input} ); console.log("newstore is", newst); - await API.write(JSON.stringify(store)) - const fromserver = await API.read(); - setStore({...fromserver} ); - setInput(""); - }; - const [input, setInput] = useState(""); - - - return ( -
-

SHULNEFF

-
-
-

{e.preventDefault(); setShowAPIField(!showAPIField);}}>I ate ...

- {showAPIField? - { - localStorage.setItem("apikey", e.target.value); - }}/> - :null} -
-
- { - setInput(e.target.value);} - } onKeyDown={async (e) =>{ - if (e.key === "Enter") { - await formSubmit(); - } - }} value={input} /> - -
-
-
-
- -
-
-
- {store ? -
- -
- :null} -
-
- Raw Store -
-        {JSON.stringify(store, null, 4)}
-        
-
-
- ); + API.write(JSON.stringify(store)).then(async () => { + setTimeout(async () => { + const fromserver = await API.read(); + setStore({...fromserver} ); + setInput(""); + }, 150); + }) + }; + const [input, setInput] = useState(""); + + + return ( +
+

SHULNEFF

+
+
+

{e.preventDefault(); setShowAPIField(!showAPIField);}}>I ate ...

+ {showAPIField? + { + localStorage.setItem("apikey", e.target.value); + }}/> + :null} +
+
+ { + setInput(e.target.value);} + } onKeyDown={async (e) =>{ + if (e.key === "Enter") { + await formSubmit(); + } + }} value={input} /> + +
+
+
+
+ +
+
+
+ {store ? +
+ +
+ :null} +
+
+ Raw Store +
+         {JSON.stringify(store, null, 4)}
+         
+
+
+ ); }; const DATEFORMAT = "YYYY MM DD HH:mm"; @@ -139,10 +142,12 @@ export const RenderTable : React.FC<{API: APIEndPoint, store: Store, setStore: ( if (isSelected) { const newst = removeEntry(store, item ); console.log("newstore is", newst); - await API.write(JSON.stringify(store)) - const fromserver = await API.read(); - setStore({...fromserver} ); - } + API.write(JSON.stringify(store)).then(async () => { + setTimeout(async () => { + const fromserver = await API.read(); + setStore({...fromserver} ); + }, 150); + } }} key={index} className="reacts">{datestring} {isSelected ?