create-croissant 0.1.49 → 0.1.51

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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/template/apps/desktop/electron.vite.config.ts +11 -1
  3. package/template/apps/desktop/package.json +15 -1
  4. package/template/apps/desktop/src/renderer/index.html +1 -1
  5. package/template/apps/desktop/src/renderer/src/components/app-sidebar.tsx +186 -0
  6. package/template/apps/desktop/src/renderer/src/components/login-form.tsx +158 -0
  7. package/template/apps/desktop/src/renderer/src/components/signup-form.tsx +205 -0
  8. package/template/apps/desktop/src/renderer/src/env.d.ts +5 -0
  9. package/template/apps/desktop/src/renderer/src/lib/auth-client.ts +3 -0
  10. package/template/apps/desktop/src/renderer/src/lib/orpc.ts +12 -0
  11. package/template/apps/desktop/src/renderer/src/main.tsx +15 -4
  12. package/template/apps/desktop/src/renderer/src/routeTree.gen.ts +240 -0
  13. package/template/apps/desktop/src/renderer/src/routes/__root.tsx +29 -0
  14. package/template/apps/desktop/src/renderer/src/routes/_auth/account.tsx +267 -0
  15. package/template/apps/desktop/src/renderer/src/routes/_auth/dashboard.tsx +46 -0
  16. package/template/apps/desktop/src/renderer/src/routes/_auth/examples/client-orpc-auth.tsx +35 -0
  17. package/template/apps/desktop/src/renderer/src/routes/_auth.tsx +35 -0
  18. package/template/apps/desktop/src/renderer/src/routes/_public/examples/client-orpc.tsx +310 -0
  19. package/template/apps/desktop/src/renderer/src/routes/_public/index.tsx +54 -0
  20. package/template/apps/desktop/src/renderer/src/routes/_public/login.tsx +16 -0
  21. package/template/apps/desktop/src/renderer/src/routes/_public/signup.tsx +16 -0
  22. package/template/apps/desktop/src/renderer/src/routes/_public.tsx +23 -0
  23. package/template/apps/desktop/tsconfig.web.json +1 -0
  24. package/template/apps/mobile/package.json +4 -3
  25. package/template/apps/platform/package.json +5 -8
  26. package/template/apps/platform/src/components/login-form.tsx +9 -5
  27. package/template/apps/platform/src/components/signup-form.tsx +12 -8
  28. package/template/apps/platform/src/routes/_public/examples/client-orpc.tsx +13 -12
  29. package/template/apps/platform/src/routes/_public/examples/ssr-orpc.tsx +12 -8
  30. package/template/package.json +11 -10
  31. package/template/packages/auth/package.json +1 -2
  32. package/template/packages/orpc/package.json +2 -0
  33. package/template/packages/ui/package.json +3 -2
  34. package/template/packages/ui/src/components/input-otp.tsx +14 -3
  35. package/template/apps/desktop/src/renderer/src/App.tsx +0 -35
@@ -0,0 +1,310 @@
1
+ import * as React from "react";
2
+ import { createFileRoute } from "@tanstack/react-router";
3
+ import { Check, Pencil, Plus, Trash2 } from "lucide-react";
4
+ import { toast } from "sonner";
5
+ import { useForm } from "@tanstack/react-form";
6
+ import { z } from "zod";
7
+
8
+ import { Button } from "@workspace/ui/components/button";
9
+ import { Input } from "@workspace/ui/components/input";
10
+ import { Field, FieldError, FieldLabel } from "@workspace/ui/components/field";
11
+
12
+ import type { router } from "@workspace/orpc/router";
13
+ import type { InferRouterOutputs } from "@orpc/server";
14
+ import { usePlanets, useCreatePlanet, useUpdatePlanet, useDeletePlanet } from "@workspace/orpc/react";
15
+
16
+ type Outputs = InferRouterOutputs<typeof router>;
17
+ type Planet = Outputs["planets"]["getPlanets"][number];
18
+
19
+ const planetSchema = z.object({
20
+ name: z.string().min(1),
21
+ description: z.string(),
22
+ distance: z.string().refine((val) => !isNaN(parseFloat(val)), {
23
+ message: "Must be a number",
24
+ }),
25
+ diameter: z.string().refine((val) => !isNaN(parseFloat(val)), {
26
+ message: "Must be a number",
27
+ }),
28
+ });
29
+
30
+ export const Route = createFileRoute("/_public/examples/client-orpc")({
31
+ component: ClientORPC,
32
+ });
33
+
34
+ function ClientORPC() {
35
+ const [editingId, setEditingId] = React.useState<number | null>(null);
36
+
37
+ const { data: planets = [], isLoading } = usePlanets();
38
+
39
+ const form = useForm({
40
+ defaultValues: {
41
+ name: "",
42
+ description: "",
43
+ distance: "0",
44
+ diameter: "0",
45
+ },
46
+ validators: {
47
+ onChange: planetSchema,
48
+ },
49
+ onSubmit: async ({ value }) => {
50
+ if (editingId) {
51
+ await updateMutation.mutateAsync({
52
+ id: editingId,
53
+ name: value.name,
54
+ description: value.description,
55
+ distanceFromSun: parseFloat(value.distance),
56
+ diameter: parseFloat(value.diameter),
57
+ hasRings: false,
58
+ });
59
+ } else {
60
+ await createMutation.mutateAsync({
61
+ name: value.name,
62
+ description: value.description,
63
+ distanceFromSun: parseFloat(value.distance),
64
+ diameter: parseFloat(value.diameter),
65
+ hasRings: false,
66
+ });
67
+ }
68
+ },
69
+ });
70
+
71
+ const resetForm = () => {
72
+ form.reset();
73
+ setEditingId(null);
74
+ };
75
+
76
+ const createMutation = useCreatePlanet({
77
+ onSuccess: () => {
78
+ resetForm();
79
+ toast.success("Planet added successfully");
80
+ },
81
+ onError: (err) => {
82
+ toast.error(err.message || "Failed to add planet");
83
+ },
84
+ });
85
+
86
+ const updateMutation = useUpdatePlanet({
87
+ onSuccess: () => {
88
+ resetForm();
89
+ toast.success("Planet updated successfully");
90
+ },
91
+ onError: (err) => {
92
+ toast.error(err.message || "Failed to update planet");
93
+ },
94
+ });
95
+
96
+ const deleteMutation = useDeletePlanet({
97
+ onSuccess: () => {
98
+ toast.success("Planet deleted successfully");
99
+ },
100
+ onError: (err) => {
101
+ toast.error(err.message || "Failed to delete planet");
102
+ },
103
+ });
104
+
105
+ const handleDelete = async (id: number) => {
106
+ if (!confirm("Are you sure you want to delete this planet?")) return;
107
+ await deleteMutation.mutateAsync({ id });
108
+ };
109
+
110
+ const startEdit = (planet: Planet) => {
111
+ setEditingId(planet.id);
112
+ form.setFieldValue("name", planet.name);
113
+ form.setFieldValue("description", planet.description || "");
114
+ form.setFieldValue("distance", planet.distanceFromSun.toString());
115
+ form.setFieldValue("diameter", planet.diameter.toString());
116
+ };
117
+
118
+ return (
119
+ <div className="flex flex-col gap-8">
120
+ <div>
121
+ <h1 className="text-2xl font-bold mb-2">Client + oRPC CRUD</h1>
122
+ <p className="text-muted-foreground">
123
+ Manage planets directly from the client using TanStack Query, TanStack Form and oRPC.
124
+ </p>
125
+ </div>
126
+
127
+ <div className="rounded-lg border p-6 bg-muted/30 dark:bg-zinc-900/30">
128
+ <h2 className="font-semibold mb-4 flex items-center gap-2">
129
+ {editingId ? <Pencil className="h-4 w-4" /> : <Plus className="h-4 w-4" />}
130
+ {editingId ? "Edit Planet" : "Add New Planet"}
131
+ </h2>
132
+ <form
133
+ onSubmit={(e) => {
134
+ e.preventDefault();
135
+ e.stopPropagation();
136
+ form.handleSubmit();
137
+ }}
138
+ >
139
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
140
+ <form.Field
141
+ name="name"
142
+ children={(field) => (
143
+ <Field
144
+ data-invalid={field.state.meta.isTouched && field.state.meta.errors.length > 0}
145
+ >
146
+ <FieldLabel htmlFor={field.name}>Name</FieldLabel>
147
+ <Input
148
+ id={field.name}
149
+ name={field.name}
150
+ value={field.state.value}
151
+ onBlur={field.handleBlur}
152
+ onChange={(e) => field.handleChange(e.target.value)}
153
+ placeholder="Mars"
154
+ />
155
+ {field.state.meta.isTouched && <FieldError errors={field.state.meta.errors} />}
156
+ </Field>
157
+ )}
158
+ />
159
+ <form.Field
160
+ name="description"
161
+ children={(field) => (
162
+ <Field
163
+ data-invalid={field.state.meta.isTouched && field.state.meta.errors.length > 0}
164
+ >
165
+ <FieldLabel htmlFor={field.name}>Description</FieldLabel>
166
+ <Input
167
+ id={field.name}
168
+ name={field.name}
169
+ value={field.state.value}
170
+ onBlur={field.handleBlur}
171
+ onChange={(e) => field.handleChange(e.target.value)}
172
+ placeholder="The red planet"
173
+ />
174
+ {field.state.meta.isTouched && <FieldError errors={field.state.meta.errors} />}
175
+ </Field>
176
+ )}
177
+ />
178
+ <form.Field
179
+ name="distance"
180
+ children={(field) => (
181
+ <Field
182
+ data-invalid={field.state.meta.isTouched && field.state.meta.errors.length > 0}
183
+ >
184
+ <FieldLabel htmlFor={field.name}>Distance (M km)</FieldLabel>
185
+ <Input
186
+ id={field.name}
187
+ name={field.name}
188
+ type="number"
189
+ value={field.state.value}
190
+ onBlur={field.handleBlur}
191
+ onChange={(e) => field.handleChange(e.target.value)}
192
+ />
193
+ {field.state.meta.isTouched && <FieldError errors={field.state.meta.errors} />}
194
+ </Field>
195
+ )}
196
+ />
197
+ <form.Field
198
+ name="diameter"
199
+ children={(field) => (
200
+ <Field
201
+ data-invalid={field.state.meta.isTouched && field.state.meta.errors.length > 0}
202
+ >
203
+ <FieldLabel htmlFor={field.name}>Diameter (km)</FieldLabel>
204
+ <Input
205
+ id={field.name}
206
+ name={field.name}
207
+ type="number"
208
+ value={field.state.value}
209
+ onBlur={field.handleBlur}
210
+ onChange={(e) => field.handleChange(e.target.value)}
211
+ />
212
+ {field.state.meta.isTouched && <FieldError errors={field.state.meta.errors} />}
213
+ </Field>
214
+ )}
215
+ />
216
+ </div>
217
+ <div className="mt-6 flex gap-2">
218
+ <form.Subscribe
219
+ selector={(state) => ({
220
+ canSubmit: state.canSubmit,
221
+ isSubmitting: state.isSubmitting,
222
+ })}
223
+ >
224
+ {(state: { canSubmit: boolean; isSubmitting: boolean }) => (
225
+ <>
226
+ {editingId ? (
227
+ <>
228
+ <Button
229
+ type="submit"
230
+ className="flex items-center gap-2"
231
+ disabled={!state.canSubmit || state.isSubmitting || updateMutation.isPending}
232
+ >
233
+ <Check className="h-4 w-4" />{" "}
234
+ {state.isSubmitting || updateMutation.isPending ? "Saving..." : "Save Changes"}
235
+ </Button>
236
+ <Button
237
+ variant="outline"
238
+ type="button"
239
+ onClick={resetForm}
240
+ disabled={state.isSubmitting || updateMutation.isPending}
241
+ >
242
+ Cancel
243
+ </Button>
244
+ </>
245
+ ) : (
246
+ <Button
247
+ type="submit"
248
+ className="flex items-center gap-2"
249
+ disabled={!state.canSubmit || state.isSubmitting || createMutation.isPending}
250
+ >
251
+ <Plus className="h-4 w-4" />{" "}
252
+ {state.isSubmitting || createMutation.isPending ? "Adding..." : "Add Planet"}
253
+ </Button>
254
+ )}
255
+ </>
256
+ )}
257
+ </form.Subscribe>
258
+ </div>
259
+ </form>
260
+ </div>
261
+
262
+ <div className="space-y-4">
263
+ <h2 className="font-semibold text-lg">Current Planets</h2>
264
+ {isLoading ? (
265
+ <p>Loading planets...</p>
266
+ ) : planets.length === 0 ? (
267
+ <p className="text-gray-500 italic">No planets found.</p>
268
+ ) : (
269
+ <div className="grid grid-cols-1 gap-3">
270
+ {planets.map((planet) => (
271
+ <div
272
+ key={planet.id}
273
+ className="flex items-center justify-between rounded-lg border p-4 bg-background shadow-sm hover:shadow-md transition-shadow dark:bg-zinc-900"
274
+ >
275
+ <div className="flex-1">
276
+ <div className="flex items-center gap-2">
277
+ <span className="font-bold text-lg">{planet.name}</span>
278
+ <span className="text-xs bg-muted px-2 py-0.5 rounded-full text-muted-foreground">
279
+ ID: {planet.id}
280
+ </span>
281
+ </div>
282
+ <p className="text-sm text-muted-foreground">
283
+ {planet.description || "No description provided."}
284
+ </p>
285
+ <div className="mt-2 flex gap-4 text-xs text-muted-foreground font-mono">
286
+ <span>Distance: {planet.distanceFromSun} M km</span>
287
+ <span>Diameter: {planet.diameter} km</span>
288
+ </div>
289
+ </div>
290
+ <div className="flex gap-2 ml-4">
291
+ <Button variant="outline" size="icon" onClick={() => startEdit(planet)}>
292
+ <Pencil className="h-4 w-4" />
293
+ </Button>
294
+ <Button
295
+ variant="destructive"
296
+ size="icon"
297
+ onClick={() => handleDelete(planet.id)}
298
+ disabled={deleteMutation.isPending}
299
+ >
300
+ <Trash2 className="h-4 w-4" />
301
+ </Button>
302
+ </div>
303
+ </div>
304
+ ))}
305
+ </div>
306
+ )}
307
+ </div>
308
+ </div>
309
+ );
310
+ }
@@ -0,0 +1,54 @@
1
+ import { Link, createFileRoute } from "@tanstack/react-router";
2
+ import { Button } from "@workspace/ui/components/button";
3
+ import { useHello, usePlanets } from "@workspace/orpc/react";
4
+
5
+ export const Route = createFileRoute("/_public/")({
6
+ component: App,
7
+ });
8
+
9
+ function App() {
10
+ const { data: helloData, isLoading: helloLoading } = useHello("Croissant Desktop");
11
+ const { data: planets, isLoading: planetsLoading } = usePlanets();
12
+
13
+ return (
14
+ <div className="flex min-h-svh p-6">
15
+ <div className="flex max-w-lg min-w-0 flex-col gap-4 text-sm leading-loose">
16
+ <div>
17
+ <h1 className="font-medium text-2xl mb-4">Desktop Project ready!</h1>
18
+ <p>
19
+ oRPC integration: <span className="font-bold">{helloLoading ? "Loading..." : helloData?.message}</span>
20
+ </p>
21
+
22
+ <div className="mt-8">
23
+ <h2 className="text-xl font-semibold mb-2">Planets from Database:</h2>
24
+ {planetsLoading ? (
25
+ <p className="text-gray-500 italic">Loading planets...</p>
26
+ ) : !planets || planets.length === 0 ? (
27
+ <p className="text-gray-500 italic">
28
+ No planets found in the database.
29
+ </p>
30
+ ) : (
31
+ <ul className="grid grid-cols-1 gap-2">
32
+ {planets.map((planet) => (
33
+ <li key={planet.id} className="rounded-md border p-3 shadow-sm">
34
+ <span className="font-bold">{planet.name}</span> - {planet.description}
35
+ </li>
36
+ ))}
37
+ </ul>
38
+ )}
39
+ </div>
40
+
41
+ <div className="mt-8 flex gap-2">
42
+ <Link to="/login">
43
+ <Button>Go to Login</Button>
44
+ </Link>
45
+ <Link to="/dashboard">
46
+ <Button variant="outline">Go to Dashboard</Button>
47
+ </Link>
48
+ </div>
49
+ <p className="mt-4 text-gray-500">You may now add components and start building.</p>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ );
54
+ }
@@ -0,0 +1,16 @@
1
+ import { createFileRoute } from "@tanstack/react-router";
2
+ import { LoginForm } from "@/components/login-form";
3
+
4
+ export const Route = createFileRoute("/_public/login")({
5
+ component: Login,
6
+ });
7
+
8
+ function Login() {
9
+ return (
10
+ <div className="flex min-h-svh items-center justify-center p-6">
11
+ <div className="w-full max-w-sm">
12
+ <LoginForm />
13
+ </div>
14
+ </div>
15
+ );
16
+ }
@@ -0,0 +1,16 @@
1
+ import { createFileRoute } from "@tanstack/react-router";
2
+ import { SignupForm } from "@/components/signup-form";
3
+
4
+ export const Route = createFileRoute("/_public/signup")({
5
+ component: Signup,
6
+ });
7
+
8
+ function Signup() {
9
+ return (
10
+ <div className="flex min-h-svh items-center justify-center p-6">
11
+ <div className="w-full max-w-sm">
12
+ <SignupForm />
13
+ </div>
14
+ </div>
15
+ );
16
+ }
@@ -0,0 +1,23 @@
1
+ import { Outlet, createFileRoute } from "@tanstack/react-router";
2
+ import { SidebarProvider, SidebarTrigger } from "@workspace/ui/components/sidebar";
3
+ import { PublicSidebar } from "@/components/app-sidebar";
4
+
5
+ export const Route = createFileRoute("/_public")({
6
+ component: PublicLayout,
7
+ });
8
+
9
+ function PublicLayout() {
10
+ return (
11
+ <SidebarProvider>
12
+ <PublicSidebar />
13
+ <main className="flex flex-1 flex-col overflow-hidden">
14
+ <header className="flex h-16 shrink-0 items-center gap-2 border-b px-4">
15
+ <SidebarTrigger />
16
+ </header>
17
+ <div className="flex-1 overflow-auto p-4">
18
+ <Outlet />
19
+ </div>
20
+ </main>
21
+ </SidebarProvider>
22
+ );
23
+ }
@@ -10,6 +10,7 @@
10
10
  "compilerOptions": {
11
11
  "composite": true,
12
12
  "paths": {
13
+ "@/*": ["./src/renderer/src/*"],
13
14
  "@renderer/*": ["./src/renderer/src/*"],
14
15
  "@main/*": ["./src/main/src/*"],
15
16
  "@preload/*": ["./src/preload/src/*"]
@@ -27,8 +27,8 @@
27
27
  "expo-symbols": "~1.0.8",
28
28
  "expo-system-ui": "~6.0.9",
29
29
  "expo-web-browser": "~15.0.10",
30
- "react": "19.1.0",
31
- "react-dom": "19.1.0",
30
+ "react": "19.2.5",
31
+ "react-dom": "19.2.5",
32
32
  "react-native": "0.81.5",
33
33
  "react-native-gesture-handler": "~2.28.0",
34
34
  "react-native-worklets": "0.5.1",
@@ -39,7 +39,8 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@workspace/config-typescript": "workspace:*",
42
- "@types/react": "~19.1.0"
42
+ "@types/react": "19.2.14",
43
+ "@types/react-dom": "19.2.3"
43
44
  },
44
45
  "private": true
45
46
  }
@@ -13,28 +13,25 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@noble/ciphers": "^2.2.0",
16
- "@orpc/client": "^1.14.0",
17
- "@orpc/server": "^1.14.0",
18
- "@orpc/tanstack-query": "^1.14.0",
19
16
  "@tailwindcss/vite": "^4.2.4",
20
- "@tanstack/react-form": "^1.29.1",
21
- "@tanstack/react-query": "^5.100.5",
22
17
  "@tanstack/react-router": "^1.168.24",
23
18
  "@tanstack/react-start": "^1.167.49",
24
19
  "@tanstack/router-plugin": "^1.167.27",
25
20
  "@workspace/auth": "workspace:*",
26
21
  "@workspace/orpc": "workspace:*",
27
22
  "@workspace/ui": "workspace:*",
28
- "better-auth": "^1.6.9",
29
23
  "lucide-react": "^1.11.0",
30
24
  "nitro": "latest",
31
25
  "sonner": "^2.0.7",
26
+ "react": "19.2.5",
27
+ "react-dom": "19.2.5",
32
28
  "tailwindcss": "^4.2.4",
33
- "vite-tsconfig-paths": "^6.1.1",
34
- "zod": "4.3.6"
29
+ "vite-tsconfig-paths": "^6.1.1"
35
30
  },
36
31
  "devDependencies": {
37
32
  "@types/node": "^25.6.0",
33
+ "@types/react": "^19.2.14",
34
+ "@types/react-dom": "^19.2.3",
38
35
  "@vitejs/plugin-react": "^6.0.1",
39
36
  "@workspace/config-typescript": "workspace:*",
40
37
  "dotenv": "^17.4.2",
@@ -126,13 +126,17 @@ export function LoginForm({ className, ...props }: React.ComponentProps<"div">)
126
126
  />
127
127
  <Field>
128
128
  <form.Subscribe
129
- selector={(state) => [state.canSubmit, state.isSubmitting]}
130
- children={([canSubmit, isSubmitting]) => (
131
- <Button type="submit" disabled={!canSubmit || isSubmitting || loading}>
132
- {isSubmitting || loading ? "Logging in..." : "Login"}
129
+ selector={(state) => ({
130
+ canSubmit: state.canSubmit,
131
+ isSubmitting: state.isSubmitting,
132
+ })}
133
+ >
134
+ {(state: { canSubmit: boolean; isSubmitting: boolean }) => (
135
+ <Button type="submit" disabled={!state.canSubmit || state.isSubmitting || loading}>
136
+ {state.isSubmitting || loading ? "Logging in..." : "Login"}
133
137
  </Button>
134
138
  )}
135
- />
139
+ </form.Subscribe>
136
140
  <Button variant="outline" type="button" disabled={loading}>
137
141
  Login with Google
138
142
  </Button>
@@ -172,14 +172,18 @@ export function SignupForm({ ...props }: React.ComponentProps<typeof Card>) {
172
172
  />
173
173
  <FieldGroup>
174
174
  <Field>
175
- <form.Subscribe
176
- selector={(state) => [state.canSubmit, state.isSubmitting]}
177
- children={([canSubmit, isSubmitting]) => (
178
- <Button type="submit" disabled={!canSubmit || isSubmitting || loading}>
179
- {isSubmitting || loading ? "Creating..." : "Create Account"}
180
- </Button>
181
- )}
182
- />
175
+ <form.Subscribe
176
+ selector={(state) => ({
177
+ canSubmit: state.canSubmit,
178
+ isSubmitting: state.isSubmitting,
179
+ })}
180
+ >
181
+ {(state: { canSubmit: boolean; isSubmitting: boolean }) => (
182
+ <Button type="submit" disabled={!state.canSubmit || state.isSubmitting || loading}>
183
+ {state.isSubmitting || loading ? "Creating..." : "Create Account"}
184
+ </Button>
185
+ )}
186
+ </form.Subscribe>
183
187
  <Button variant="outline" type="button" disabled={loading}>
184
188
  Sign up with Google
185
189
  </Button>
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import { createFileRoute } from "@tanstack/react-router";
3
3
  import { Check, Pencil, Plus, Trash2 } from "lucide-react";
4
4
  import { toast } from "sonner";
5
- import { useQueryClient } from "@tanstack/react-query";
6
5
  import { useForm } from "@tanstack/react-form";
7
6
  import { z } from "zod";
8
7
 
@@ -11,10 +10,9 @@ import { Input } from "@workspace/ui/components/input";
11
10
  import { Field, FieldError, FieldLabel } from "@workspace/ui/components/field";
12
11
 
13
12
  import type { router } from "@workspace/orpc/router";
14
- import type { InferRouterInputs, InferRouterOutputs } from "@orpc/server";
13
+ import type { InferRouterOutputs } from "@orpc/server";
15
14
  import { usePlanets, useCreatePlanet, useUpdatePlanet, useDeletePlanet } from "@workspace/orpc/react";
16
15
 
17
- type Inputs = InferRouterInputs<typeof router>;
18
16
  type Outputs = InferRouterOutputs<typeof router>;
19
17
  type Planet = Outputs["planets"]["getPlanets"][number];
20
18
 
@@ -45,7 +43,6 @@ export const Route = createFileRoute("/_public/examples/client-orpc")({
45
43
  });
46
44
 
47
45
  function ClientORPC() {
48
- const queryClient = useQueryClient();
49
46
  const [editingId, setEditingId] = React.useState<number | null>(null);
50
47
 
51
48
  const { data: planets = [], isLoading } = usePlanets();
@@ -230,24 +227,28 @@ function ClientORPC() {
230
227
  </div>
231
228
  <div className="mt-6 flex gap-2">
232
229
  <form.Subscribe
233
- selector={(state) => [state.canSubmit, state.isSubmitting]}
234
- children={([canSubmit, isSubmitting]) => (
230
+ selector={(state) => ({
231
+ canSubmit: state.canSubmit,
232
+ isSubmitting: state.isSubmitting,
233
+ })}
234
+ >
235
+ {(state: { canSubmit: boolean; isSubmitting: boolean }) => (
235
236
  <>
236
237
  {editingId ? (
237
238
  <>
238
239
  <Button
239
240
  type="submit"
240
241
  className="flex items-center gap-2"
241
- disabled={!canSubmit || isSubmitting || updateMutation.isPending}
242
+ disabled={!state.canSubmit || state.isSubmitting || updateMutation.isPending}
242
243
  >
243
244
  <Check className="h-4 w-4" />{" "}
244
- {isSubmitting || updateMutation.isPending ? "Saving..." : "Save Changes"}
245
+ {state.isSubmitting || updateMutation.isPending ? "Saving..." : "Save Changes"}
245
246
  </Button>
246
247
  <Button
247
248
  variant="outline"
248
249
  type="button"
249
250
  onClick={resetForm}
250
- disabled={isSubmitting || updateMutation.isPending}
251
+ disabled={state.isSubmitting || updateMutation.isPending}
251
252
  >
252
253
  Cancel
253
254
  </Button>
@@ -256,15 +257,15 @@ function ClientORPC() {
256
257
  <Button
257
258
  type="submit"
258
259
  className="flex items-center gap-2"
259
- disabled={!canSubmit || isSubmitting || createMutation.isPending}
260
+ disabled={!state.canSubmit || state.isSubmitting || createMutation.isPending}
260
261
  >
261
262
  <Plus className="h-4 w-4" />{" "}
262
- {isSubmitting || createMutation.isPending ? "Adding..." : "Add Planet"}
263
+ {state.isSubmitting || createMutation.isPending ? "Adding..." : "Add Planet"}
263
264
  </Button>
264
265
  )}
265
266
  </>
266
267
  )}
267
- />
268
+ </form.Subscribe>
268
269
  </div>
269
270
  </form>
270
271
  </div>
@@ -223,23 +223,27 @@ function SSRORPC() {
223
223
  </div>
224
224
  <div className="mt-6 flex gap-2">
225
225
  <form.Subscribe
226
- selector={(state) => [state.canSubmit, state.isSubmitting]}
227
- children={([canSubmit, isSubmitting]) => (
226
+ selector={(state) => ({
227
+ canSubmit: state.canSubmit,
228
+ isSubmitting: state.isSubmitting,
229
+ })}
230
+ >
231
+ {(state: { canSubmit: boolean; isSubmitting: boolean }) => (
228
232
  <>
229
233
  {editingId ? (
230
234
  <>
231
235
  <Button
232
236
  type="submit"
233
237
  className="flex items-center gap-2"
234
- disabled={!canSubmit || isSubmitting}
238
+ disabled={!state.canSubmit || state.isSubmitting}
235
239
  >
236
- <Check className="h-4 w-4" /> {isSubmitting ? "Saving..." : "Save Changes"}
240
+ <Check className="h-4 w-4" /> {state.isSubmitting ? "Saving..." : "Save Changes"}
237
241
  </Button>
238
242
  <Button
239
243
  variant="outline"
240
244
  type="button"
241
245
  onClick={resetForm}
242
- disabled={isSubmitting}
246
+ disabled={state.isSubmitting}
243
247
  >
244
248
  Cancel
245
249
  </Button>
@@ -248,14 +252,14 @@ function SSRORPC() {
248
252
  <Button
249
253
  type="submit"
250
254
  className="flex items-center gap-2"
251
- disabled={!canSubmit || isSubmitting}
255
+ disabled={!state.canSubmit || state.isSubmitting}
252
256
  >
253
- <Plus className="h-4 w-4" /> {isSubmitting ? "Adding..." : "Add Planet"}
257
+ <Plus className="h-4 w-4" /> {state.isSubmitting ? "Adding..." : "Add Planet"}
254
258
  </Button>
255
259
  )}
256
260
  </>
257
261
  )}
258
- />
262
+ </form.Subscribe>
259
263
  </div>
260
264
  </form>
261
265
  </div>