@korajs/cli 0.4.0 → 0.5.0
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/dist/bin.cjs +1609 -643
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1086 -139
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-CMSX76KM.js → chunk-3WNFM3QB.js} +103 -96
- package/dist/chunk-3WNFM3QB.js.map +1 -0
- package/dist/{chunk-MVP5PDT4.js → chunk-PSRM56B7.js} +2 -2
- package/dist/{chunk-YGVO4POI.js → chunk-SOTZIWIF.js} +27 -15
- package/dist/chunk-SOTZIWIF.js.map +1 -0
- package/dist/create.cjs +54 -47
- package/dist/create.cjs.map +1 -1
- package/dist/create.js +2 -2
- package/dist/index.cjs +78 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -2
- package/package.json +9 -3
- package/templates/react-basic/README.md.hbs +10 -1
- package/templates/react-basic/src/App.tsx +112 -126
- package/templates/react-basic/src/index.css +165 -159
- package/templates/react-basic/src/kora-worker.ts +0 -1
- package/templates/react-basic/src/main.tsx +12 -12
- package/templates/react-basic/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/react-basic/src/modules/todos/todo.queries.ts +5 -0
- package/templates/react-basic/src/modules/todos/todo.schema.ts +10 -0
- package/templates/react-basic/src/modules/todos/useTodos.ts +31 -0
- package/templates/react-basic/src/schema.ts +6 -12
- package/templates/react-basic/src/vite-env.d.ts +17 -0
- package/templates/react-basic/{tsconfig.json → tsconfig.json.hbs} +1 -2
- package/templates/react-basic/vite.config.ts +57 -50
- package/templates/react-sync/.env.example +19 -0
- package/templates/react-sync/README.md.hbs +43 -1
- package/templates/react-sync/package.json.hbs +3 -0
- package/templates/react-sync/server.ts +90 -26
- package/templates/react-sync/src/App.tsx +132 -130
- package/templates/react-sync/src/auth.ts +25 -0
- package/templates/react-sync/src/index.css +212 -165
- package/templates/react-sync/src/kora-worker.ts +0 -1
- package/templates/react-sync/src/main.tsx +34 -18
- package/templates/react-sync/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/react-sync/src/modules/todos/todo.queries.ts +5 -0
- package/templates/react-sync/src/modules/todos/todo.schema.ts +10 -0
- package/templates/react-sync/src/modules/todos/useTodos.ts +31 -0
- package/templates/react-sync/src/schema.ts +6 -12
- package/templates/react-sync/src/vite-env.d.ts +17 -0
- package/templates/react-sync/{tsconfig.json → tsconfig.json.hbs} +1 -2
- package/templates/react-sync/vite.config.ts +67 -60
- package/templates/react-tailwind/README.md.hbs +10 -1
- package/templates/react-tailwind/src/App.tsx +186 -197
- package/templates/react-tailwind/src/index.css +3 -3
- package/templates/react-tailwind/src/kora-worker.ts +0 -1
- package/templates/react-tailwind/src/main.tsx +19 -12
- package/templates/react-tailwind/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/react-tailwind/src/modules/todos/todo.queries.ts +5 -0
- package/templates/react-tailwind/src/modules/todos/todo.schema.ts +10 -0
- package/templates/react-tailwind/src/modules/todos/useTodos.ts +31 -0
- package/templates/react-tailwind/src/schema.ts +6 -12
- package/templates/react-tailwind/src/vite-env.d.ts +17 -0
- package/templates/react-tailwind/{tsconfig.json → tsconfig.json.hbs} +1 -2
- package/templates/react-tailwind/vite.config.ts +57 -50
- package/templates/react-tailwind-sync/.env.example +19 -0
- package/templates/react-tailwind-sync/README.md.hbs +43 -1
- package/templates/react-tailwind-sync/package.json.hbs +3 -0
- package/templates/react-tailwind-sync/server.ts +90 -26
- package/templates/react-tailwind-sync/src/App.tsx +246 -222
- package/templates/react-tailwind-sync/src/auth.ts +25 -0
- package/templates/react-tailwind-sync/src/index.css +3 -3
- package/templates/react-tailwind-sync/src/kora-worker.ts +0 -1
- package/templates/react-tailwind-sync/src/main.tsx +48 -18
- package/templates/react-tailwind-sync/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/react-tailwind-sync/src/modules/todos/todo.queries.ts +5 -0
- package/templates/react-tailwind-sync/src/modules/todos/todo.schema.ts +10 -0
- package/templates/react-tailwind-sync/src/modules/todos/useTodos.ts +31 -0
- package/templates/react-tailwind-sync/src/schema.ts +6 -12
- package/templates/react-tailwind-sync/src/vite-env.d.ts +17 -0
- package/templates/react-tailwind-sync/{tsconfig.json → tsconfig.json.hbs} +1 -2
- package/templates/react-tailwind-sync/vite.config.ts +67 -60
- package/templates/tauri-react/.env.example +20 -0
- package/templates/tauri-react/README.md.hbs +36 -1
- package/templates/tauri-react/dev.ts +11 -11
- package/templates/tauri-react/package.json.hbs +2 -0
- package/templates/tauri-react/server.ts +86 -12
- package/templates/tauri-react/src/App.tsx +769 -544
- package/templates/tauri-react/src/AppShell.tsx +125 -83
- package/templates/tauri-react/src/SetupScreen.tsx +257 -208
- package/templates/tauri-react/src/auth.ts +45 -0
- package/templates/tauri-react/src/main.tsx +3 -3
- package/templates/tauri-react/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/tauri-react/src/modules/todos/todo.queries.ts +5 -0
- package/templates/tauri-react/src/modules/todos/todo.schema.ts +10 -0
- package/templates/tauri-react/src/modules/todos/useTodos.ts +31 -0
- package/templates/tauri-react/src/schema.ts +6 -12
- package/templates/tauri-react/src/sync-config.ts +47 -47
- package/templates/tauri-react/src/updater.ts +15 -15
- package/templates/tauri-react/src/vite-env.d.ts +17 -0
- package/templates/tauri-react/src-tauri/tauri.conf.json +1 -1
- package/templates/tauri-react/tsconfig.json.hbs +14 -0
- package/templates/tauri-react/vite.config.ts +9 -9
- package/dist/chunk-CMSX76KM.js.map +0 -1
- package/dist/chunk-YGVO4POI.js.map +0 -1
- package/templates/tauri-react/tsconfig.json +0 -15
- /package/dist/{chunk-MVP5PDT4.js.map → chunk-PSRM56B7.js.map} +0 -0
|
@@ -1,278 +1,397 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useQuery, useMutation, useCollection } from '@korajs/react'
|
|
1
|
+
import { useAuth } from '@korajs/auth/react'
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
AlertTriangle,
|
|
4
|
+
CheckCircle2,
|
|
5
|
+
Circle,
|
|
6
|
+
Loader2,
|
|
7
|
+
Monitor,
|
|
8
|
+
Plus,
|
|
9
|
+
Settings,
|
|
10
|
+
Trash2,
|
|
11
|
+
Wifi,
|
|
12
|
+
WifiOff,
|
|
14
13
|
} from 'lucide-react'
|
|
14
|
+
import { useState } from 'react'
|
|
15
|
+
import { useTodos } from './modules/todos/useTodos'
|
|
15
16
|
import { testConnection } from './sync-config'
|
|
16
17
|
|
|
17
18
|
type Filter = 'all' | 'active' | 'completed'
|
|
18
19
|
|
|
19
20
|
interface AppProps {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
syncUrl: string | null
|
|
22
|
+
onChangeServer: (newUrl: string | null) => void
|
|
23
|
+
onFactoryReset: () => void
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export function App({ syncUrl, onChangeServer, onFactoryReset }: AppProps) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
27
|
+
const { allTodos, activeTodos, completedTodos, addTodo, toggleTodo, deleteTodo } = useTodos()
|
|
28
|
+
const { user, isAuthenticated, signOut, error } = useAuth()
|
|
29
|
+
const isAdding = addTodo.isLoading
|
|
30
|
+
|
|
31
|
+
const [filter, setFilter] = useState<Filter>('all')
|
|
32
|
+
const [input, setInput] = useState('')
|
|
33
|
+
const [showSettings, setShowSettings] = useState(false)
|
|
34
|
+
|
|
35
|
+
const filteredTodos =
|
|
36
|
+
filter === 'active' ? activeTodos : filter === 'completed' ? completedTodos : allTodos
|
|
37
|
+
|
|
38
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
39
|
+
e.preventDefault()
|
|
40
|
+
const title = input.trim()
|
|
41
|
+
if (title) {
|
|
42
|
+
addTodo.mutate({ title })
|
|
43
|
+
setInput('')
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const clearCompleted = () => {
|
|
48
|
+
for (const todo of completedTodos) {
|
|
49
|
+
deleteTodo.mutate(todo.id)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div style={{ minHeight: '100vh', background: '#0a0a0a', color: '#f3f4f6' }}>
|
|
55
|
+
<div style={{ maxWidth: '640px', margin: '0 auto', padding: '48px 16px' }}>
|
|
56
|
+
{/* Header */}
|
|
57
|
+
<div
|
|
58
|
+
style={{
|
|
59
|
+
display: 'flex',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
justifyContent: 'space-between',
|
|
62
|
+
marginBottom: '32px',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
|
|
66
|
+
<Monitor style={{ width: '32px', height: '32px', color: '#818cf8' }} />
|
|
67
|
+
<h1 style={{ fontSize: '24px', fontWeight: 'bold' }}>Desktop Tasks</h1>
|
|
68
|
+
</div>
|
|
69
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
70
|
+
<span
|
|
71
|
+
style={{
|
|
72
|
+
display: 'flex',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
gap: '6px',
|
|
75
|
+
fontSize: '12px',
|
|
76
|
+
color: syncUrl ? '#34d399' : '#6b7280',
|
|
77
|
+
background: '#1f2937',
|
|
78
|
+
padding: '4px 12px',
|
|
79
|
+
borderRadius: '9999px',
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
{syncUrl ? (
|
|
83
|
+
<Wifi style={{ width: '12px', height: '12px' }} />
|
|
84
|
+
) : (
|
|
85
|
+
<WifiOff style={{ width: '12px', height: '12px' }} />
|
|
86
|
+
)}
|
|
87
|
+
{syncUrl ? 'Syncing' : 'Local only'}
|
|
88
|
+
</span>
|
|
89
|
+
<AuthButton
|
|
90
|
+
isAuthenticated={isAuthenticated}
|
|
91
|
+
label={user?.email || 'Sign out'}
|
|
92
|
+
onSignOut={signOut}
|
|
93
|
+
/>
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
onClick={() => setShowSettings(!showSettings)}
|
|
97
|
+
style={{
|
|
98
|
+
background: showSettings ? '#374151' : '#1f2937',
|
|
99
|
+
border: 'none',
|
|
100
|
+
borderRadius: '9999px',
|
|
101
|
+
padding: '6px',
|
|
102
|
+
cursor: 'pointer',
|
|
103
|
+
color: showSettings ? '#f3f4f6' : '#6b7280',
|
|
104
|
+
display: 'flex',
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<Settings style={{ width: '14px', height: '14px' }} />
|
|
108
|
+
</button>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
{/* Settings panel */}
|
|
113
|
+
{showSettings && (
|
|
114
|
+
<SettingsPanel
|
|
115
|
+
syncUrl={syncUrl}
|
|
116
|
+
onChangeServer={onChangeServer}
|
|
117
|
+
onFactoryReset={onFactoryReset}
|
|
118
|
+
onClose={() => setShowSettings(false)}
|
|
119
|
+
/>
|
|
120
|
+
)}
|
|
121
|
+
|
|
122
|
+
{error && (
|
|
123
|
+
<div
|
|
124
|
+
style={{
|
|
125
|
+
border: '1px solid rgba(248, 113, 113, 0.35)',
|
|
126
|
+
borderRadius: '8px',
|
|
127
|
+
color: '#fca5a5',
|
|
128
|
+
fontSize: '13px',
|
|
129
|
+
marginBottom: '16px',
|
|
130
|
+
padding: '10px 12px',
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
{error}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
|
|
137
|
+
{/* Stats */}
|
|
138
|
+
<div
|
|
139
|
+
style={{
|
|
140
|
+
display: 'grid',
|
|
141
|
+
gridTemplateColumns: '1fr 1fr 1fr',
|
|
142
|
+
gap: '16px',
|
|
143
|
+
marginBottom: '32px',
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<StatCard label="Total" value={allTodos.length} color="#d1d5db" />
|
|
147
|
+
<StatCard label="Remaining" value={activeTodos.length} color="#fbbf24" />
|
|
148
|
+
<StatCard label="Done" value={completedTodos.length} color="#34d399" />
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
{/* Add form */}
|
|
152
|
+
<form
|
|
153
|
+
onSubmit={handleSubmit}
|
|
154
|
+
style={{ display: 'flex', gap: '12px', marginBottom: '32px' }}
|
|
155
|
+
>
|
|
156
|
+
<input
|
|
157
|
+
type="text"
|
|
158
|
+
value={input}
|
|
159
|
+
onChange={(e) => setInput(e.target.value)}
|
|
160
|
+
placeholder="What needs to be done?"
|
|
161
|
+
style={{
|
|
162
|
+
flex: 1,
|
|
163
|
+
borderRadius: '8px',
|
|
164
|
+
border: '1px solid #374151',
|
|
165
|
+
background: '#111827',
|
|
166
|
+
padding: '12px 16px',
|
|
167
|
+
color: '#f3f4f6',
|
|
168
|
+
outline: 'none',
|
|
169
|
+
fontSize: '14px',
|
|
170
|
+
}}
|
|
171
|
+
/>
|
|
172
|
+
<button
|
|
173
|
+
type="submit"
|
|
174
|
+
disabled={isAdding || !input.trim()}
|
|
175
|
+
style={{
|
|
176
|
+
display: 'flex',
|
|
177
|
+
alignItems: 'center',
|
|
178
|
+
gap: '8px',
|
|
179
|
+
borderRadius: '8px',
|
|
180
|
+
background: '#4f46e5',
|
|
181
|
+
padding: '12px 20px',
|
|
182
|
+
fontWeight: '500',
|
|
183
|
+
color: 'white',
|
|
184
|
+
border: 'none',
|
|
185
|
+
cursor: 'pointer',
|
|
186
|
+
opacity: isAdding || !input.trim() ? 0.5 : 1,
|
|
187
|
+
fontSize: '14px',
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
{isAdding ? (
|
|
191
|
+
<Loader2
|
|
192
|
+
style={{ width: '16px', height: '16px', animation: 'spin 1s linear infinite' }}
|
|
193
|
+
/>
|
|
194
|
+
) : (
|
|
195
|
+
<Plus style={{ width: '16px', height: '16px' }} />
|
|
196
|
+
)}
|
|
197
|
+
Add
|
|
198
|
+
</button>
|
|
199
|
+
</form>
|
|
200
|
+
|
|
201
|
+
{/* Filter tabs */}
|
|
202
|
+
<div style={{ display: 'flex', gap: '8px', marginBottom: '24px' }}>
|
|
203
|
+
{(['all', 'active', 'completed'] as const).map((f) => {
|
|
204
|
+
const count =
|
|
205
|
+
f === 'all'
|
|
206
|
+
? allTodos.length
|
|
207
|
+
: f === 'active'
|
|
208
|
+
? activeTodos.length
|
|
209
|
+
: completedTodos.length
|
|
210
|
+
const isActive = filter === f
|
|
211
|
+
return (
|
|
212
|
+
<button
|
|
213
|
+
key={f}
|
|
214
|
+
onClick={() => setFilter(f)}
|
|
215
|
+
style={{
|
|
216
|
+
display: 'flex',
|
|
217
|
+
alignItems: 'center',
|
|
218
|
+
gap: '8px',
|
|
219
|
+
borderRadius: '8px',
|
|
220
|
+
padding: '8px 16px',
|
|
221
|
+
fontSize: '14px',
|
|
222
|
+
fontWeight: '500',
|
|
223
|
+
border: 'none',
|
|
224
|
+
cursor: 'pointer',
|
|
225
|
+
background: isActive ? '#4f46e5' : '#1f2937',
|
|
226
|
+
color: isActive ? 'white' : '#9ca3af',
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
{f.charAt(0).toUpperCase() + f.slice(1)}
|
|
230
|
+
<span
|
|
231
|
+
style={{
|
|
232
|
+
borderRadius: '9999px',
|
|
233
|
+
padding: '2px 8px',
|
|
234
|
+
fontSize: '12px',
|
|
235
|
+
background: isActive ? '#4338ca' : '#374151',
|
|
236
|
+
color: isActive ? 'white' : '#9ca3af',
|
|
237
|
+
}}
|
|
238
|
+
>
|
|
239
|
+
{count}
|
|
240
|
+
</span>
|
|
241
|
+
</button>
|
|
242
|
+
)
|
|
243
|
+
})}
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
{/* Todo list */}
|
|
247
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
|
248
|
+
{filteredTodos.length === 0 ? (
|
|
249
|
+
<div
|
|
250
|
+
style={{
|
|
251
|
+
borderRadius: '8px',
|
|
252
|
+
border: '1px dashed #1f2937',
|
|
253
|
+
padding: '48px 0',
|
|
254
|
+
textAlign: 'center',
|
|
255
|
+
color: '#4b5563',
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
258
|
+
{filter === 'all'
|
|
259
|
+
? 'No tasks yet. Add one above!'
|
|
260
|
+
: filter === 'active'
|
|
261
|
+
? 'All caught up!'
|
|
262
|
+
: 'No completed tasks yet.'}
|
|
263
|
+
</div>
|
|
264
|
+
) : (
|
|
265
|
+
filteredTodos.map((todo) => (
|
|
266
|
+
<div
|
|
267
|
+
key={todo.id}
|
|
268
|
+
style={{
|
|
269
|
+
display: 'flex',
|
|
270
|
+
alignItems: 'center',
|
|
271
|
+
gap: '12px',
|
|
272
|
+
borderRadius: '8px',
|
|
273
|
+
border: '1px solid #1f2937',
|
|
274
|
+
background: '#111827',
|
|
275
|
+
padding: '12px 16px',
|
|
276
|
+
}}
|
|
277
|
+
>
|
|
278
|
+
<button
|
|
279
|
+
onClick={() => toggleTodo.mutate(todo.id, { completed: !todo.completed })}
|
|
280
|
+
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
|
|
281
|
+
>
|
|
282
|
+
{todo.completed ? (
|
|
283
|
+
<CheckCircle2 style={{ width: '20px', height: '20px', color: '#34d399' }} />
|
|
284
|
+
) : (
|
|
285
|
+
<Circle style={{ width: '20px', height: '20px', color: '#6b7280' }} />
|
|
286
|
+
)}
|
|
287
|
+
</button>
|
|
288
|
+
<span
|
|
289
|
+
style={{
|
|
290
|
+
flex: 1,
|
|
291
|
+
color: todo.completed ? '#6b7280' : '#f3f4f6',
|
|
292
|
+
textDecoration: todo.completed ? 'line-through' : 'none',
|
|
293
|
+
}}
|
|
294
|
+
>
|
|
295
|
+
{String(todo.title)}
|
|
296
|
+
</span>
|
|
297
|
+
{todo.createdAt && (
|
|
298
|
+
<span style={{ fontSize: '12px', color: '#374151' }}>
|
|
299
|
+
{formatTime(Number(todo.createdAt))}
|
|
300
|
+
</span>
|
|
301
|
+
)}
|
|
302
|
+
<button
|
|
303
|
+
onClick={() => deleteTodo.mutate(todo.id)}
|
|
304
|
+
style={{
|
|
305
|
+
background: 'none',
|
|
306
|
+
border: 'none',
|
|
307
|
+
cursor: 'pointer',
|
|
308
|
+
padding: 0,
|
|
309
|
+
color: '#4b5563',
|
|
310
|
+
}}
|
|
311
|
+
>
|
|
312
|
+
<Trash2 style={{ width: '16px', height: '16px' }} />
|
|
313
|
+
</button>
|
|
314
|
+
</div>
|
|
315
|
+
))
|
|
316
|
+
)}
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
{/* Footer */}
|
|
320
|
+
{allTodos.length > 0 && (
|
|
321
|
+
<div
|
|
322
|
+
style={{
|
|
323
|
+
marginTop: '24px',
|
|
324
|
+
display: 'flex',
|
|
325
|
+
justifyContent: 'space-between',
|
|
326
|
+
fontSize: '14px',
|
|
327
|
+
color: '#6b7280',
|
|
328
|
+
}}
|
|
329
|
+
>
|
|
330
|
+
<span>
|
|
331
|
+
{activeTodos.length} item{activeTodos.length !== 1 ? 's' : ''} left
|
|
332
|
+
</span>
|
|
333
|
+
{completedTodos.length > 0 && (
|
|
334
|
+
<button
|
|
335
|
+
onClick={clearCompleted}
|
|
336
|
+
style={{
|
|
337
|
+
background: 'none',
|
|
338
|
+
border: 'none',
|
|
339
|
+
cursor: 'pointer',
|
|
340
|
+
color: '#6b7280',
|
|
341
|
+
fontSize: '14px',
|
|
342
|
+
}}
|
|
343
|
+
>
|
|
344
|
+
Clear completed
|
|
345
|
+
</button>
|
|
346
|
+
)}
|
|
347
|
+
</div>
|
|
348
|
+
)}
|
|
349
|
+
|
|
350
|
+
<p style={{ marginTop: '48px', textAlign: 'center', fontSize: '12px', color: '#374151' }}>
|
|
351
|
+
Powered by Kora — native SQLite, offline-first
|
|
352
|
+
</p>
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function AuthButton({
|
|
359
|
+
isAuthenticated,
|
|
360
|
+
label,
|
|
361
|
+
onSignOut,
|
|
362
|
+
}: {
|
|
363
|
+
isAuthenticated: boolean
|
|
364
|
+
label: string
|
|
365
|
+
onSignOut: () => Promise<void>
|
|
366
|
+
}) {
|
|
367
|
+
const { getOAuthAuthorizationUrl } = useAuth()
|
|
368
|
+
|
|
369
|
+
const handleSignIn = async () => {
|
|
370
|
+
const { url } = await getOAuthAuthorizationUrl('google')
|
|
371
|
+
window.open(url, '_blank', 'noopener,noreferrer')
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return (
|
|
375
|
+
<button
|
|
376
|
+
type="button"
|
|
377
|
+
onClick={() => (isAuthenticated ? onSignOut() : handleSignIn())}
|
|
378
|
+
style={{
|
|
379
|
+
background: '#1f2937',
|
|
380
|
+
border: '1px solid #374151',
|
|
381
|
+
borderRadius: '9999px',
|
|
382
|
+
color: '#d1d5db',
|
|
383
|
+
cursor: 'pointer',
|
|
384
|
+
fontSize: '12px',
|
|
385
|
+
maxWidth: '160px',
|
|
386
|
+
overflow: 'hidden',
|
|
387
|
+
padding: '4px 12px',
|
|
388
|
+
textOverflow: 'ellipsis',
|
|
389
|
+
whiteSpace: 'nowrap',
|
|
390
|
+
}}
|
|
391
|
+
>
|
|
392
|
+
{isAuthenticated ? label : 'Sign in'}
|
|
393
|
+
</button>
|
|
394
|
+
)
|
|
276
395
|
}
|
|
277
396
|
|
|
278
397
|
// ---------------------------------------------------------------------------
|
|
@@ -280,279 +399,378 @@ export function App({ syncUrl, onChangeServer, onFactoryReset }: AppProps) {
|
|
|
280
399
|
// ---------------------------------------------------------------------------
|
|
281
400
|
|
|
282
401
|
interface SettingsPanelProps {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
402
|
+
syncUrl: string | null
|
|
403
|
+
onChangeServer: (newUrl: string | null) => void
|
|
404
|
+
onFactoryReset: () => void
|
|
405
|
+
onClose: () => void
|
|
287
406
|
}
|
|
288
407
|
|
|
289
408
|
function SettingsPanel({ syncUrl, onChangeServer, onFactoryReset, onClose }: SettingsPanelProps) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
409
|
+
const [editing, setEditing] = useState(false)
|
|
410
|
+
const [newUrl, setNewUrl] = useState(syncUrl ?? '')
|
|
411
|
+
const [testing, setTesting] = useState(false)
|
|
412
|
+
const [testResult, setTestResult] = useState<'success' | 'failure' | null>(null)
|
|
413
|
+
const [showResetConfirm, setShowResetConfirm] = useState(false)
|
|
414
|
+
const [showChangeConfirm, setShowChangeConfirm] = useState(false)
|
|
415
|
+
|
|
416
|
+
const handleTestConnection = async () => {
|
|
417
|
+
const url = editing ? newUrl.trim() : syncUrl
|
|
418
|
+
if (!url) return
|
|
419
|
+
setTesting(true)
|
|
420
|
+
setTestResult(null)
|
|
421
|
+
const ok = await testConnection(url)
|
|
422
|
+
setTestResult(ok ? 'success' : 'failure')
|
|
423
|
+
setTesting(false)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const handleSaveUrl = () => {
|
|
427
|
+
const trimmed = newUrl.trim()
|
|
428
|
+
if (trimmed === syncUrl) {
|
|
429
|
+
setEditing(false)
|
|
430
|
+
return
|
|
431
|
+
}
|
|
432
|
+
// If there's existing data and the URL is changing, warn about data isolation
|
|
433
|
+
setShowChangeConfirm(true)
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const confirmChangeServer = (keepData: boolean) => {
|
|
437
|
+
setShowChangeConfirm(false)
|
|
438
|
+
if (keepData) {
|
|
439
|
+
onChangeServer(newUrl.trim() || null)
|
|
440
|
+
} else {
|
|
441
|
+
// Factory reset + change server
|
|
442
|
+
// Store the new URL so it's picked up after reload
|
|
443
|
+
if (newUrl.trim()) {
|
|
444
|
+
localStorage.setItem('kora-sync-url', newUrl.trim())
|
|
445
|
+
localStorage.setItem('kora-sync-configured', 'true')
|
|
446
|
+
}
|
|
447
|
+
onFactoryReset()
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const handleDisconnect = () => {
|
|
452
|
+
onChangeServer(null)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const handleConnect = () => {
|
|
456
|
+
setEditing(true)
|
|
457
|
+
setNewUrl('')
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return (
|
|
461
|
+
<div
|
|
462
|
+
style={{
|
|
463
|
+
marginBottom: '24px',
|
|
464
|
+
borderRadius: '8px',
|
|
465
|
+
border: '1px solid #1f2937',
|
|
466
|
+
background: '#111827',
|
|
467
|
+
overflow: 'hidden',
|
|
468
|
+
}}
|
|
469
|
+
>
|
|
470
|
+
{/* Server URL section */}
|
|
471
|
+
<div style={{ padding: '16px' }}>
|
|
472
|
+
<div
|
|
473
|
+
style={{
|
|
474
|
+
display: 'flex',
|
|
475
|
+
justifyContent: 'space-between',
|
|
476
|
+
alignItems: 'flex-start',
|
|
477
|
+
marginBottom: '12px',
|
|
478
|
+
}}
|
|
479
|
+
>
|
|
480
|
+
<p style={{ fontSize: '14px', fontWeight: '500', color: '#d1d5db' }}>Sync Server</p>
|
|
481
|
+
<button
|
|
482
|
+
onClick={onClose}
|
|
483
|
+
style={{
|
|
484
|
+
fontSize: '12px',
|
|
485
|
+
color: '#6b7280',
|
|
486
|
+
background: 'none',
|
|
487
|
+
border: 'none',
|
|
488
|
+
cursor: 'pointer',
|
|
489
|
+
}}
|
|
490
|
+
>
|
|
491
|
+
Close
|
|
492
|
+
</button>
|
|
493
|
+
</div>
|
|
494
|
+
|
|
495
|
+
{editing ? (
|
|
496
|
+
<div>
|
|
497
|
+
<input
|
|
498
|
+
type="text"
|
|
499
|
+
value={newUrl}
|
|
500
|
+
onChange={(e) => {
|
|
501
|
+
setNewUrl(e.target.value)
|
|
502
|
+
setTestResult(null)
|
|
503
|
+
}}
|
|
504
|
+
placeholder="wss://your-server.example.com/kora-sync"
|
|
505
|
+
style={{
|
|
506
|
+
width: '100%',
|
|
507
|
+
borderRadius: '6px',
|
|
508
|
+
border: '1px solid #374151',
|
|
509
|
+
background: '#0a0a0a',
|
|
510
|
+
padding: '8px 12px',
|
|
511
|
+
color: '#f3f4f6',
|
|
512
|
+
outline: 'none',
|
|
513
|
+
fontSize: '13px',
|
|
514
|
+
boxSizing: 'border-box',
|
|
515
|
+
marginBottom: '8px',
|
|
516
|
+
}}
|
|
517
|
+
/>
|
|
518
|
+
<div style={{ display: 'flex', gap: '8px' }}>
|
|
519
|
+
<button
|
|
520
|
+
onClick={handleSaveUrl}
|
|
521
|
+
disabled={!newUrl.trim()}
|
|
522
|
+
style={btnStyle('#4f46e5', !newUrl.trim())}
|
|
523
|
+
>
|
|
524
|
+
Save
|
|
525
|
+
</button>
|
|
526
|
+
<button
|
|
527
|
+
onClick={handleTestConnection}
|
|
528
|
+
disabled={testing || !newUrl.trim()}
|
|
529
|
+
style={btnStyle('#374151', testing || !newUrl.trim())}
|
|
530
|
+
>
|
|
531
|
+
{testing ? 'Testing...' : 'Test'}
|
|
532
|
+
</button>
|
|
533
|
+
<button
|
|
534
|
+
onClick={() => {
|
|
535
|
+
setEditing(false)
|
|
536
|
+
setTestResult(null)
|
|
537
|
+
}}
|
|
538
|
+
style={btnStyle('#374151', false)}
|
|
539
|
+
>
|
|
540
|
+
Cancel
|
|
541
|
+
</button>
|
|
542
|
+
</div>
|
|
543
|
+
</div>
|
|
544
|
+
) : (
|
|
545
|
+
<div>
|
|
546
|
+
<p
|
|
547
|
+
style={{
|
|
548
|
+
fontSize: '13px',
|
|
549
|
+
color: '#9ca3af',
|
|
550
|
+
marginBottom: '8px',
|
|
551
|
+
wordBreak: 'break-all',
|
|
552
|
+
}}
|
|
553
|
+
>
|
|
554
|
+
{syncUrl ?? 'Not connected — running in local-only mode'}
|
|
555
|
+
</p>
|
|
556
|
+
<div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap' }}>
|
|
557
|
+
{syncUrl ? (
|
|
558
|
+
<>
|
|
559
|
+
<button
|
|
560
|
+
onClick={() => {
|
|
561
|
+
setEditing(true)
|
|
562
|
+
setNewUrl(syncUrl)
|
|
563
|
+
}}
|
|
564
|
+
style={btnStyle('#374151', false)}
|
|
565
|
+
>
|
|
566
|
+
Change URL
|
|
567
|
+
</button>
|
|
568
|
+
<button
|
|
569
|
+
onClick={handleTestConnection}
|
|
570
|
+
disabled={testing}
|
|
571
|
+
style={btnStyle('#374151', testing)}
|
|
572
|
+
>
|
|
573
|
+
{testing ? 'Testing...' : 'Test Connection'}
|
|
574
|
+
</button>
|
|
575
|
+
<button onClick={handleDisconnect} style={btnStyle('#7f1d1d', false, '#ef4444')}>
|
|
576
|
+
Disconnect
|
|
577
|
+
</button>
|
|
578
|
+
</>
|
|
579
|
+
) : (
|
|
580
|
+
<button onClick={handleConnect} style={btnStyle('#4f46e5', false)}>
|
|
581
|
+
Connect to Server
|
|
582
|
+
</button>
|
|
583
|
+
)}
|
|
584
|
+
</div>
|
|
585
|
+
</div>
|
|
586
|
+
)}
|
|
587
|
+
|
|
588
|
+
{/* Test result */}
|
|
589
|
+
{testResult && (
|
|
590
|
+
<p
|
|
591
|
+
style={{
|
|
592
|
+
fontSize: '12px',
|
|
593
|
+
marginTop: '8px',
|
|
594
|
+
color: testResult === 'success' ? '#34d399' : '#fbbf24',
|
|
595
|
+
}}
|
|
596
|
+
>
|
|
597
|
+
{testResult === 'success'
|
|
598
|
+
? 'Connection successful'
|
|
599
|
+
: 'Server unreachable — it may be down temporarily'}
|
|
600
|
+
</p>
|
|
601
|
+
)}
|
|
602
|
+
</div>
|
|
603
|
+
|
|
604
|
+
{/* Danger zone */}
|
|
605
|
+
<div style={{ padding: '12px 16px', borderTop: '1px solid #1f2937', background: '#0a0a0a' }}>
|
|
606
|
+
{showResetConfirm ? (
|
|
607
|
+
<div>
|
|
608
|
+
<div
|
|
609
|
+
style={{ display: 'flex', gap: '8px', alignItems: 'flex-start', marginBottom: '8px' }}
|
|
610
|
+
>
|
|
611
|
+
<AlertTriangle
|
|
612
|
+
style={{
|
|
613
|
+
width: '16px',
|
|
614
|
+
height: '16px',
|
|
615
|
+
color: '#ef4444',
|
|
616
|
+
flexShrink: 0,
|
|
617
|
+
marginTop: '1px',
|
|
618
|
+
}}
|
|
619
|
+
/>
|
|
620
|
+
<p style={{ fontSize: '13px', color: '#fca5a5' }}>
|
|
621
|
+
This will delete all local data and reset the app to its initial state. This cannot
|
|
622
|
+
be undone.
|
|
623
|
+
</p>
|
|
624
|
+
</div>
|
|
625
|
+
<div style={{ display: 'flex', gap: '8px' }}>
|
|
626
|
+
<button onClick={onFactoryReset} style={btnStyle('#7f1d1d', false, '#ef4444')}>
|
|
627
|
+
Confirm Reset
|
|
628
|
+
</button>
|
|
629
|
+
<button onClick={() => setShowResetConfirm(false)} style={btnStyle('#374151', false)}>
|
|
630
|
+
Cancel
|
|
631
|
+
</button>
|
|
632
|
+
</div>
|
|
633
|
+
</div>
|
|
634
|
+
) : (
|
|
635
|
+
<button
|
|
636
|
+
onClick={() => setShowResetConfirm(true)}
|
|
637
|
+
style={{
|
|
638
|
+
fontSize: '13px',
|
|
639
|
+
color: '#6b7280',
|
|
640
|
+
background: 'none',
|
|
641
|
+
border: 'none',
|
|
642
|
+
cursor: 'pointer',
|
|
643
|
+
}}
|
|
644
|
+
>
|
|
645
|
+
Reset app (clear all local data)
|
|
646
|
+
</button>
|
|
647
|
+
)}
|
|
648
|
+
</div>
|
|
649
|
+
|
|
650
|
+
{/* Server change confirmation dialog */}
|
|
651
|
+
{showChangeConfirm && (
|
|
652
|
+
<div
|
|
653
|
+
style={{
|
|
654
|
+
position: 'fixed',
|
|
655
|
+
inset: 0,
|
|
656
|
+
background: 'rgba(0,0,0,0.7)',
|
|
657
|
+
display: 'flex',
|
|
658
|
+
alignItems: 'center',
|
|
659
|
+
justifyContent: 'center',
|
|
660
|
+
zIndex: 100,
|
|
661
|
+
}}
|
|
662
|
+
>
|
|
663
|
+
<div
|
|
664
|
+
style={{
|
|
665
|
+
maxWidth: '420px',
|
|
666
|
+
width: '100%',
|
|
667
|
+
margin: '0 16px',
|
|
668
|
+
borderRadius: '12px',
|
|
669
|
+
border: '1px solid #374151',
|
|
670
|
+
background: '#111827',
|
|
671
|
+
padding: '24px',
|
|
672
|
+
}}
|
|
673
|
+
>
|
|
674
|
+
<div
|
|
675
|
+
style={{
|
|
676
|
+
display: 'flex',
|
|
677
|
+
gap: '12px',
|
|
678
|
+
alignItems: 'flex-start',
|
|
679
|
+
marginBottom: '16px',
|
|
680
|
+
}}
|
|
681
|
+
>
|
|
682
|
+
<AlertTriangle
|
|
683
|
+
style={{
|
|
684
|
+
width: '20px',
|
|
685
|
+
height: '20px',
|
|
686
|
+
color: '#fbbf24',
|
|
687
|
+
flexShrink: 0,
|
|
688
|
+
marginTop: '2px',
|
|
689
|
+
}}
|
|
690
|
+
/>
|
|
691
|
+
<div>
|
|
692
|
+
<p
|
|
693
|
+
style={{
|
|
694
|
+
fontSize: '15px',
|
|
695
|
+
fontWeight: '500',
|
|
696
|
+
color: '#f3f4f6',
|
|
697
|
+
marginBottom: '8px',
|
|
698
|
+
}}
|
|
699
|
+
>
|
|
700
|
+
Changing sync servers
|
|
701
|
+
</p>
|
|
702
|
+
<p style={{ fontSize: '13px', color: '#9ca3af', lineHeight: '1.6' }}>
|
|
703
|
+
Existing local data was created for the current server. Keeping it and connecting
|
|
704
|
+
to a different server may sync this data to the wrong place.
|
|
705
|
+
</p>
|
|
706
|
+
</div>
|
|
707
|
+
</div>
|
|
708
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
|
709
|
+
<button
|
|
710
|
+
onClick={() => confirmChangeServer(false)}
|
|
711
|
+
style={{
|
|
712
|
+
width: '100%',
|
|
713
|
+
padding: '10px',
|
|
714
|
+
borderRadius: '8px',
|
|
715
|
+
border: '1px solid #374151',
|
|
716
|
+
background: '#4f46e5',
|
|
717
|
+
color: 'white',
|
|
718
|
+
fontSize: '14px',
|
|
719
|
+
cursor: 'pointer',
|
|
720
|
+
fontWeight: '500',
|
|
721
|
+
}}
|
|
722
|
+
>
|
|
723
|
+
Clear data and switch (recommended)
|
|
724
|
+
</button>
|
|
725
|
+
<button
|
|
726
|
+
onClick={() => confirmChangeServer(true)}
|
|
727
|
+
style={{
|
|
728
|
+
width: '100%',
|
|
729
|
+
padding: '10px',
|
|
730
|
+
borderRadius: '8px',
|
|
731
|
+
border: '1px solid #374151',
|
|
732
|
+
background: '#1f2937',
|
|
733
|
+
color: '#9ca3af',
|
|
734
|
+
fontSize: '14px',
|
|
735
|
+
cursor: 'pointer',
|
|
736
|
+
}}
|
|
737
|
+
>
|
|
738
|
+
Keep data and switch
|
|
739
|
+
</button>
|
|
740
|
+
<button
|
|
741
|
+
onClick={() => setShowChangeConfirm(false)}
|
|
742
|
+
style={{
|
|
743
|
+
width: '100%',
|
|
744
|
+
padding: '10px',
|
|
745
|
+
borderRadius: '8px',
|
|
746
|
+
border: 'none',
|
|
747
|
+
background: 'transparent',
|
|
748
|
+
color: '#6b7280',
|
|
749
|
+
fontSize: '14px',
|
|
750
|
+
cursor: 'pointer',
|
|
751
|
+
}}
|
|
752
|
+
>
|
|
753
|
+
Cancel
|
|
754
|
+
</button>
|
|
755
|
+
</div>
|
|
756
|
+
</div>
|
|
757
|
+
</div>
|
|
758
|
+
)}
|
|
759
|
+
</div>
|
|
760
|
+
)
|
|
543
761
|
}
|
|
544
762
|
|
|
545
763
|
function btnStyle(bg: string, disabled: boolean, color = '#d1d5db'): React.CSSProperties {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
764
|
+
return {
|
|
765
|
+
fontSize: '13px',
|
|
766
|
+
color,
|
|
767
|
+
background: bg,
|
|
768
|
+
border: 'none',
|
|
769
|
+
borderRadius: '6px',
|
|
770
|
+
padding: '6px 12px',
|
|
771
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
772
|
+
opacity: disabled ? 0.5 : 1,
|
|
773
|
+
}
|
|
556
774
|
}
|
|
557
775
|
|
|
558
776
|
// ---------------------------------------------------------------------------
|
|
@@ -560,19 +778,26 @@ function btnStyle(bg: string, disabled: boolean, color = '#d1d5db'): React.CSSPr
|
|
|
560
778
|
// ---------------------------------------------------------------------------
|
|
561
779
|
|
|
562
780
|
function StatCard({ label, value, color }: { label: string; value: number; color: string }) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
781
|
+
return (
|
|
782
|
+
<div
|
|
783
|
+
style={{
|
|
784
|
+
borderRadius: '8px',
|
|
785
|
+
border: '1px solid #1f2937',
|
|
786
|
+
background: '#111827',
|
|
787
|
+
padding: '16px',
|
|
788
|
+
}}
|
|
789
|
+
>
|
|
790
|
+
<p style={{ fontSize: '14px', color: '#6b7280' }}>{label}</p>
|
|
791
|
+
<p style={{ fontSize: '24px', fontWeight: 'bold', color }}>{value}</p>
|
|
792
|
+
</div>
|
|
793
|
+
)
|
|
569
794
|
}
|
|
570
795
|
|
|
571
796
|
function formatTime(timestamp: number): string {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
797
|
+
const date = new Date(timestamp)
|
|
798
|
+
const now = new Date()
|
|
799
|
+
if (date.toDateString() === now.toDateString()) {
|
|
800
|
+
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
|
801
|
+
}
|
|
802
|
+
return date.toLocaleDateString([], { month: 'short', day: 'numeric' })
|
|
578
803
|
}
|