@atom.io/template-react-node-backend 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +13 -0
- package/dist/assets/index-C0R4Gha-.js +31 -0
- package/dist/index.html +1 -1
- package/package.json +7 -7
- package/src/App.tsx +29 -23
- package/dist/assets/index-CNf_2_tw.js +0 -31
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>vite-react</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-C0R4Gha-.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-CqTfTEH3.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atom.io/template-react-node-backend",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"react": "19.2.0",
|
|
10
10
|
"react-dom": "19.2.0",
|
|
11
11
|
"zod": "4.1.12",
|
|
12
|
-
"atom.io": "0.44.
|
|
12
|
+
"atom.io": "0.44.5"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@types/node": "24.10.
|
|
16
|
-
"@types/react": "19.2.
|
|
17
|
-
"@types/react-dom": "19.2.
|
|
18
|
-
"@vitejs/plugin-react": "5.1.
|
|
15
|
+
"@types/node": "24.10.1",
|
|
16
|
+
"@types/react": "19.2.4",
|
|
17
|
+
"@types/react-dom": "19.2.3",
|
|
18
|
+
"@vitejs/plugin-react": "5.1.1",
|
|
19
19
|
"babel-plugin-react-compiler": "1.0.0",
|
|
20
20
|
"concurrently": "9.2.1",
|
|
21
21
|
"eslint": "9.39.1",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"globals": "16.5.0",
|
|
25
25
|
"typescript": "5.9.3",
|
|
26
26
|
"typescript-eslint": "8.46.4",
|
|
27
|
-
"vite": "npm:rolldown-vite@7.2.
|
|
27
|
+
"vite": "npm:rolldown-vite@7.2.5"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"dev": "concurrently vite ./node/server.ts ./node/authenticator.ts",
|
package/src/App.tsx
CHANGED
|
@@ -93,19 +93,19 @@ async function addTodo() {
|
|
|
93
93
|
})
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
async function deleteTodo() {
|
|
96
|
+
async function deleteTodo(todoKey: number) {
|
|
97
97
|
const todoKeys = await getState(todoKeysAtom)
|
|
98
98
|
if (Error.isError(todoKeys)) return
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
99
|
+
const todoToDelete = todoKeys.find((key) => key === todoKey)
|
|
100
|
+
if (todoToDelete === undefined) return
|
|
101
101
|
setState(todoKeysAtom, async (loadable) => {
|
|
102
102
|
const prev = await loadable
|
|
103
103
|
if (Error.isError(prev)) return prev
|
|
104
|
-
return prev.filter((id) => id !==
|
|
104
|
+
return prev.filter((id) => id !== todoToDelete)
|
|
105
105
|
})
|
|
106
|
-
disposeState(todoAtoms,
|
|
106
|
+
disposeState(todoAtoms, todoToDelete)
|
|
107
107
|
const url = new URL(`/todos`, SERVER_URL)
|
|
108
|
-
url.searchParams.set(`id`,
|
|
108
|
+
url.searchParams.set(`id`, todoToDelete.toString())
|
|
109
109
|
await fetch(url, {
|
|
110
110
|
method: `DELETE`,
|
|
111
111
|
credentials: `include`,
|
|
@@ -179,35 +179,41 @@ export function App(): React.JSX.Element {
|
|
|
179
179
|
function Todo({ todoKey }: { todoKey: number }): React.JSX.Element {
|
|
180
180
|
const todo = useLoadable(todoAtoms, todoKey, TODO_FALLBACK)
|
|
181
181
|
const isSuspended = todo.loading || !Number.isInteger(todoKey)
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
const toggleDone = useCallback(
|
|
183
|
+
async (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
184
|
+
const url = new URL(`todos`, SERVER_URL)
|
|
185
|
+
url.searchParams.set(`id`, todo.value.id.toString())
|
|
186
|
+
const nowChecked = e.target.checked ? 1 : 0
|
|
187
|
+
setState(todoAtoms, todoKey, async (loadable) => {
|
|
188
|
+
const prev = await loadable
|
|
189
|
+
if (Error.isError(prev)) return prev
|
|
190
|
+
return { ...prev, done: nowChecked } satisfies Todo
|
|
191
|
+
})
|
|
192
|
+
await fetch(url, {
|
|
193
|
+
method: `PUT`,
|
|
194
|
+
credentials: `include`,
|
|
195
|
+
body: nowChecked.toString(),
|
|
196
|
+
})
|
|
197
|
+
resetState(todoAtoms, todoKey)
|
|
198
|
+
},
|
|
199
|
+
[],
|
|
200
|
+
)
|
|
201
|
+
const deleteThisTodo = useCallback(async () => {
|
|
202
|
+
await deleteTodo(todoKey)
|
|
197
203
|
}, [])
|
|
198
204
|
return (
|
|
199
205
|
<div className={cn(`todo`, isSuspended && `loading`)}>
|
|
200
206
|
<input
|
|
201
207
|
type="checkbox"
|
|
202
208
|
checked={Boolean(todo.value.done)}
|
|
203
|
-
onChange={
|
|
209
|
+
onChange={toggleDone}
|
|
204
210
|
disabled={isSuspended}
|
|
205
211
|
/>
|
|
206
212
|
<span>{todo.value.text}</span>
|
|
207
213
|
<button
|
|
208
214
|
type="button"
|
|
209
215
|
className="delete"
|
|
210
|
-
onClick={
|
|
216
|
+
onClick={deleteThisTodo}
|
|
211
217
|
disabled={isSuspended}
|
|
212
218
|
/>
|
|
213
219
|
</div>
|