create-aron-app 0.1.6 → 0.1.8
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/README.md +24 -31
- package/dist/index.js +39 -115
- package/package.json +7 -4
- package/templates/.cursor/rules/backend.mdc +112 -0
- package/templates/.cursor/rules/coding_standards.mdc +145 -0
- package/templates/.cursor/rules/frontend_architecture.mdc +334 -0
- package/templates/.github/workflows/ci.yml +40 -0
- package/templates/apps/api/_generated/api.d.ts +57 -0
- package/templates/apps/api/_generated/api.js +23 -0
- package/templates/apps/api/_generated/dataModel.d.ts +60 -0
- package/templates/apps/api/_generated/server.d.ts +143 -0
- package/templates/apps/api/_generated/server.js +93 -0
- package/templates/apps/api/http.ts +16 -0
- package/templates/apps/web/.env.example +10 -0
- package/templates/apps/web/.react-router/types/+future.ts +9 -0
- package/templates/apps/web/.react-router/types/+routes.ts +76 -0
- package/templates/apps/web/.react-router/types/+server-build.d.ts +18 -0
- package/templates/apps/web/.react-router/types/src/+types/root.ts +59 -0
- package/templates/apps/web/.react-router/types/src/routes/(auth)/+types/layout.ts +62 -0
- package/templates/apps/web/.react-router/types/src/routes/(auth)/sign-in/+types/index.ts +65 -0
- package/templates/apps/web/.react-router/types/src/routes/(dashboard)/(todos)/+types/[id].ts +68 -0
- package/templates/apps/web/.react-router/types/src/routes/(dashboard)/(todos)/+types/index.ts +68 -0
- package/templates/apps/web/.react-router/types/src/routes/(dashboard)/(todos)/+types/layout.ts +65 -0
- package/templates/apps/web/.react-router/types/src/routes/(dashboard)/+types/index.ts +65 -0
- package/templates/apps/web/.react-router/types/src/routes/(dashboard)/+types/layout.ts +62 -0
- package/templates/{react-router → apps/web}/project.json +9 -2
- package/templates/{react-router → apps/web}/react-router.config.ts +1 -1
- package/templates/apps/web/src/app.css +3 -0
- package/templates/{react-router → apps/web}/src/components/error_boundary.tsx +1 -1
- package/templates/apps/web/src/libs/convex_query_client.ts +11 -0
- package/templates/apps/web/src/libs/react_query_client.ts +17 -0
- package/templates/apps/web/src/libs/server/auth.ts +32 -0
- package/templates/apps/web/src/libs/server/protected.ts +17 -0
- package/templates/apps/web/src/providers/api_auth_provider.tsx +26 -0
- package/templates/apps/web/src/providers/global_provider.tsx +28 -0
- package/templates/apps/web/src/providers/navigation_loading_bar_provider.tsx +72 -0
- package/templates/apps/web/src/root.tsx +68 -0
- package/templates/{react-router/src/routes/auth → apps/web/src/routes/(auth)}/layout.tsx +1 -1
- package/templates/apps/web/src/routes/(dashboard)/(todos)/[id].tsx +33 -0
- package/templates/apps/web/src/routes/(dashboard)/(todos)/index.tsx +26 -0
- package/templates/apps/web/src/routes/(dashboard)/(todos)/layout.tsx +9 -0
- package/templates/apps/web/src/routes/(dashboard)/index.tsx +20 -0
- package/templates/apps/web/src/routes/(dashboard)/layout.tsx +20 -0
- package/templates/apps/web/src/routes.ts +14 -0
- package/templates/apps/web/src/surfaces/home/bootstrap.ts +9 -0
- package/templates/apps/web/src/surfaces/home/home.tsx +25 -0
- package/templates/apps/web/src/surfaces/home/install.tsx +17 -0
- package/templates/apps/web/src/surfaces/home/layout.tsx +35 -0
- package/templates/apps/web/src/surfaces/home/main/create.tsx +32 -0
- package/templates/apps/web/src/surfaces/sidebar/install.tsx +19 -0
- package/templates/apps/web/src/surfaces/sidebar/layout.tsx +119 -0
- package/templates/apps/web/src/surfaces/sidebar/nav_main/create.tsx +31 -0
- package/templates/apps/web/src/surfaces/sidebar/nav_main/nav_main.tsx +42 -0
- package/templates/apps/web/src/surfaces/sidebar/sidebar.tsx +18 -0
- package/templates/apps/web/src/surfaces/sidebar/user_menu/create.tsx +26 -0
- package/templates/{react-router/src/layouts/sidebar/sidebar_aside → apps/web/src/surfaces/sidebar/user_menu}/user_menu.tsx +13 -9
- package/templates/apps/web/src/surfaces/todos/all_todos/all_todos.tsx +25 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/all_todos_controller.ts +47 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/bootstrap.ts +21 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/header/create.tsx +21 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/install.tsx +20 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/layout.tsx +35 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/main/create.tsx +47 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/main/main.tsx +68 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/main/new_todo_sheet/create.tsx +54 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/main/new_todo_sheet/new_todo_sheet.tsx +97 -0
- package/templates/apps/web/src/surfaces/todos/all_todos/main/new_todo_sheet/schema.ts +11 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/bootstrap.ts +35 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/header/create.tsx +24 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/header/header.tsx +25 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/install.tsx +27 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/layout.tsx +45 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/main/create.tsx +35 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/main/main.tsx +47 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/single_todo.tsx +27 -0
- package/templates/apps/web/src/surfaces/todos/single_todo/single_todo_controller.ts +16 -0
- package/templates/{react-router → apps/web}/vite.config.ts +27 -3
- package/templates/{_base/biome.json → biome.json} +12 -0
- package/templates/bun.lock +1917 -0
- package/templates/{_base/emails → emails}/project.json +1 -1
- package/templates/package.json +91 -0
- package/templates/{_base/shared → shared}/assets/src/styles/global.css +14 -8
- package/templates/shared/ui/src/base/collapsible.tsx +31 -0
- package/templates/shared/ui/src/base/hover-card.tsx +42 -0
- package/templates/shared/ui/src/base/input-group.tsx +168 -0
- package/templates/shared/ui/src/base/panel.tsx +93 -0
- package/templates/{_base/shared → shared}/ui/src/hooks/use_mobile.tsx +1 -1
- package/templates/{_base/shared → shared}/ui/src/hooks/use_query_params.tsx +6 -7
- package/templates/{_base/shared → shared}/ui/tsconfig.json +1 -1
- package/templates/shared/utils/src/convex.ts +4 -0
- package/templates/{_base/tsconfig.base.json → tsconfig.base.json} +2 -1
- package/templates/_base/.cursor/commands/builder.md +0 -0
- package/templates/_base/.cursor/rules/api_architecture.mdc +0 -268
- package/templates/_base/.cursor/rules/coding_standards.mdc +0 -64
- package/templates/_base/.cursor/rules/convex_rules.mdc +0 -675
- package/templates/_base/.cursor/rules/frontend_rules.mdc +0 -268
- package/templates/_base/.env.convex.example +0 -3
- package/templates/_base/.github/workflows/ci.yml +0 -29
- package/templates/_base/_gitignore +0 -58
- package/templates/_base/package.json +0 -73
- package/templates/_base/shared/utils/src/convex.ts +0 -3
- package/templates/nextjs/.env.example +0 -8
- package/templates/nextjs/index.d.ts +0 -6
- package/templates/nextjs/next-env.d.ts +0 -5
- package/templates/nextjs/next.config.js +0 -22
- package/templates/nextjs/postcss.config.js +0 -17
- package/templates/nextjs/project.json +0 -22
- package/templates/nextjs/src/app/(auth)/layout.tsx +0 -21
- package/templates/nextjs/src/app/(auth)/not-allowed/page.tsx +0 -22
- package/templates/nextjs/src/app/(auth)/sign-in/[[...sign-in]]/page.tsx +0 -15
- package/templates/nextjs/src/app/(dashboard)/layout.tsx +0 -27
- package/templates/nextjs/src/app/(dashboard)/page.tsx +0 -5
- package/templates/nextjs/src/app/(dashboard)/todos/[id]/page.tsx +0 -23
- package/templates/nextjs/src/app/(dashboard)/todos/page.tsx +0 -16
- package/templates/nextjs/src/app/app.css +0 -3
- package/templates/nextjs/src/app/layout.tsx +0 -26
- package/templates/nextjs/src/convex.ts +0 -11
- package/templates/nextjs/src/middleware.ts +0 -18
- package/templates/nextjs/src/providers/convex_provider.tsx +0 -44
- package/templates/nextjs/src/surfaces/home_surface.tsx +0 -22
- package/templates/nextjs/src/surfaces/todos/all_todos_surface.tsx +0 -97
- package/templates/nextjs/src/surfaces/todos/create_todo_sheet.tsx +0 -107
- package/templates/nextjs/src/surfaces/todos/single_todo_surface.tsx +0 -90
- package/templates/nextjs/src/ui/sidebar/nav_link.tsx +0 -36
- package/templates/nextjs/src/ui/sidebar/sidebar.tsx +0 -125
- package/templates/nextjs/src/utils/font.ts +0 -9
- package/templates/nextjs/tsconfig.json +0 -42
- package/templates/react-router/.env.example +0 -8
- package/templates/react-router/src/app.css +0 -3
- package/templates/react-router/src/layouts/sidebar/sidebar_aside/sidebar_aside.tsx +0 -76
- package/templates/react-router/src/layouts/sidebar/sidebar_layout.tsx +0 -22
- package/templates/react-router/src/providers/api_auth_provider.tsx +0 -38
- package/templates/react-router/src/root.tsx +0 -37
- package/templates/react-router/src/routes/index.tsx +0 -9
- package/templates/react-router/src/routes/layout.tsx +0 -26
- package/templates/react-router/src/routes/todos/[id].tsx +0 -22
- package/templates/react-router/src/routes/todos/index.tsx +0 -13
- package/templates/react-router/src/routes.ts +0 -12
- package/templates/react-router/src/surfaces/home_surface.tsx +0 -20
- package/templates/react-router/src/surfaces/todos/all_todos_surface.tsx +0 -87
- package/templates/react-router/src/surfaces/todos/create_todo_sheet.tsx +0 -102
- package/templates/react-router/src/surfaces/todos/single_todo_surface.tsx +0 -81
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/SKILL.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-backend-api/SKILL.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-backend-api/scripts/api-specs-context.sh +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-backend-api/scripts/execute-request.sh +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-backend-api/scripts/extract-endpoint-detail.sh +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-backend-api/scripts/extract-tag-endpoints.sh +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-backend-api/scripts/extract-tags.js +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-custom-ui/SKILL.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-custom-ui/core-2/custom-sign-in.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-custom-ui/core-2/custom-sign-up.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-custom-ui/core-3/custom-sign-in.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-custom-ui/core-3/custom-sign-up.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-custom-ui/core-3/show-component.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-nextjs-patterns/SKILL.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-nextjs-patterns/references/api-routes.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-nextjs-patterns/references/caching-auth.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-nextjs-patterns/references/middleware-strategies.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-nextjs-patterns/references/server-actions.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-nextjs-patterns/references/server-vs-client.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/clerk/clerk-webhooks/SKILL.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/SKILL.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/agents/openai.yml +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/assets/shadcn-small.png +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/assets/shadcn.png +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/cli.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/customization.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/evals/evals.json +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/mcp.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/rules/base-vs-radix.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/rules/composition.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/rules/forms.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/rules/icons.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/agents/skills/shadcn/rules/styling.md +0 -0
- /package/templates/{_base/.cursor → .cursor}/commands/pr.md +0 -0
- /package/templates/{_base/.nvmrc → .nvmrc} +0 -0
- /package/templates/{_base/.vscode → .vscode}/settings.json +0 -0
- /package/templates/{_base/apps → apps}/api/auth.config.ts +0 -0
- /package/templates/{_base/apps → apps}/api/functions.ts +0 -0
- /package/templates/{_base/apps → apps}/api/project.json +0 -0
- /package/templates/{_base/apps → apps}/api/schema.ts +0 -0
- /package/templates/{_base/apps → apps}/api/todos/crud.ts +0 -0
- /package/templates/{_base/apps → apps}/api/todos/schema.ts +0 -0
- /package/templates/{_base/apps → apps}/api/todos/types.ts +0 -0
- /package/templates/{_base/apps → apps}/api/tsconfig.json +0 -0
- /package/templates/{_base/apps → apps}/api/types.ts +0 -0
- /package/templates/{react-router → apps/web}/postcss.config.js +0 -0
- /package/templates/{react-router → apps/web}/public/favicon.ico +0 -0
- /package/templates/{react-router/src/routes/auth/sign-in.tsx → apps/web/src/routes/(auth)/sign-in/index.tsx} +0 -0
- /package/templates/{react-router → apps/web}/tsconfig.json +0 -0
- /package/templates/{_base/convex.json → convex.json} +0 -0
- /package/templates/{_base/emails → emails}/tsconfig.json +0 -0
- /package/templates/{_base/emails → emails}/welcome_email.tsx +0 -0
- /package/templates/{_base/nx.json → nx.json} +0 -0
- /package/templates/{_base/scripts → scripts}/sync_convex_env.ts +0 -0
- /package/templates/{_base/shared → shared}/assets/image.d.ts +0 -0
- /package/templates/{_base/shared → shared}/assets/tsconfig.json +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/alert_dialog.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/badge.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/basic_data_table.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/button.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/button_group.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/card.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/checkbox.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/command.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/dialog.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/dropdown_menu.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/form.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/input.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/label.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/popover.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/radio_group.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/resizable.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/scroll_area.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/select.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/separator.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/sheet.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/side_bar.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/skeleton.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/spinner.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/switch.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/table.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/text_area.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/tooltip.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/base/utils.ts +0 -0
- /package/templates/{_base/shared → shared}/ui/src/hooks/use_keyboard_press.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/hooks/use_keyboard_release.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/hooks/use_mouse_click.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/hooks/use_mouse_location.tsx +0 -0
- /package/templates/{_base/shared → shared}/ui/src/hooks/use_outside_click.tsx +0 -0
- /package/templates/{_base/shared → shared}/utils/src/time.ts +0 -0
- /package/templates/{_base/shared → shared}/utils/tsconfig.json +0 -0
- /package/templates/{_base/skills-lock.json → skills-lock.json} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { action, observable } from "mobx";
|
|
6
|
+
|
|
7
|
+
import { api } from "@/api/_generated/api";
|
|
8
|
+
import type { TodoId } from "@/api/todos/types";
|
|
9
|
+
import { convex } from "@/web/libs/convex_query_client";
|
|
10
|
+
|
|
11
|
+
export class AllTodosController {
|
|
12
|
+
@observable
|
|
13
|
+
accessor createTodoPending = false;
|
|
14
|
+
|
|
15
|
+
@observable
|
|
16
|
+
accessor isNewTodoSheetOpen = false;
|
|
17
|
+
|
|
18
|
+
@action
|
|
19
|
+
openNewTodoSheet() {
|
|
20
|
+
this.isNewTodoSheetOpen = true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@action
|
|
24
|
+
closeNewTodoSheet() {
|
|
25
|
+
this.isNewTodoSheetOpen = false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@action
|
|
29
|
+
async updateTodo(args: { todoId: TodoId; isCompleted: boolean }) {
|
|
30
|
+
await convex.mutation(api.todos.crud.updateTodo, args);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@action
|
|
34
|
+
async deleteTodo(args: { todoId: TodoId }) {
|
|
35
|
+
await convex.mutation(api.todos.crud.deleteTodo, args);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@action
|
|
39
|
+
async createTodo(args: { title: string; description?: string }) {
|
|
40
|
+
this.createTodoPending = true;
|
|
41
|
+
try {
|
|
42
|
+
await convex.mutation(api.todos.crud.createTodo, args);
|
|
43
|
+
} finally {
|
|
44
|
+
this.createTodoPending = false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ConvexHttpClient } from "convex/browser";
|
|
6
|
+
|
|
7
|
+
import { api } from "@/api/_generated/api";
|
|
8
|
+
import type { Todo } from "@/api/todos/types";
|
|
9
|
+
|
|
10
|
+
export type AllTodosBootstrap = {
|
|
11
|
+
todos: Todo[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type AllTodosBootstrapArgs = {
|
|
15
|
+
client: ConvexHttpClient;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const bootstrapAllTodos = async ({ client }: AllTodosBootstrapArgs): Promise<AllTodosBootstrap> => {
|
|
19
|
+
const todos = await client.query(api.todos.crud.listTodos, {});
|
|
20
|
+
return { todos };
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { observer } from "mobx-react-lite";
|
|
6
|
+
import type { ComponentType } from "react";
|
|
7
|
+
|
|
8
|
+
export type CreateHeaderOpts = {
|
|
9
|
+
NewTodoSheet: ComponentType;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const createHeader = ({ NewTodoSheet }: CreateHeaderOpts) => {
|
|
13
|
+
return observer(() => {
|
|
14
|
+
return (
|
|
15
|
+
<div className="mb-6 flex items-center justify-between">
|
|
16
|
+
<h1 className="text-2xl font-semibold">Todos</h1>
|
|
17
|
+
<NewTodoSheet />
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AllTodosController } from "@/web/surfaces/todos/all_todos/all_todos_controller";
|
|
6
|
+
import type { AllTodosBootstrap } from "@/web/surfaces/todos/all_todos/bootstrap";
|
|
7
|
+
import type { AllTodosLayoutController } from "@/web/surfaces/todos/all_todos/layout";
|
|
8
|
+
|
|
9
|
+
export type InstallAllTodosOpts = {
|
|
10
|
+
layout: AllTodosLayoutController;
|
|
11
|
+
bootstrap: AllTodosBootstrap;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const installAllTodos = ({ layout, bootstrap }: InstallAllTodosOpts) => {
|
|
15
|
+
const controller = new AllTodosController();
|
|
16
|
+
|
|
17
|
+
import("@/web/surfaces/todos/all_todos/main/create").then(({ createMain }) => {
|
|
18
|
+
layout.setMain(createMain({ controller, bootstrap }));
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { action, observable } from "mobx";
|
|
6
|
+
import { observer } from "mobx-react-lite";
|
|
7
|
+
import type { ComponentType } from "react";
|
|
8
|
+
|
|
9
|
+
import { Skeleton } from "@/ui/base/skeleton";
|
|
10
|
+
|
|
11
|
+
export class AllTodosLayoutController {
|
|
12
|
+
@observable.ref
|
|
13
|
+
accessor Main: ComponentType | undefined = undefined;
|
|
14
|
+
|
|
15
|
+
@action
|
|
16
|
+
setMain(Main: ComponentType) {
|
|
17
|
+
this.Main = Main;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const createLayout = () => {
|
|
22
|
+
const layout = new AllTodosLayoutController();
|
|
23
|
+
return {
|
|
24
|
+
layout,
|
|
25
|
+
Layout: observer(() => {
|
|
26
|
+
const Main = layout.Main;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="flex w-full flex-1 flex-col">
|
|
30
|
+
{Main ? <Main /> : <Skeleton className="h-64 w-full rounded-md" />}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { convexQuery } from "@convex-dev/react-query";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
|
+
import { observer } from "mobx-react-lite";
|
|
8
|
+
|
|
9
|
+
import { api } from "@/api/_generated/api";
|
|
10
|
+
import type { AllTodosController } from "@/web/surfaces/todos/all_todos/all_todos_controller";
|
|
11
|
+
import type { AllTodosBootstrap } from "@/web/surfaces/todos/all_todos/bootstrap";
|
|
12
|
+
import { createHeader } from "@/web/surfaces/todos/all_todos/header/create";
|
|
13
|
+
import { Main } from "@/web/surfaces/todos/all_todos/main/main";
|
|
14
|
+
import { createNewTodoSheet } from "@/web/surfaces/todos/all_todos/main/new_todo_sheet/create";
|
|
15
|
+
|
|
16
|
+
export type CreateMainOpts = {
|
|
17
|
+
controller: AllTodosController;
|
|
18
|
+
bootstrap: AllTodosBootstrap;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const createMain = ({ controller, bootstrap }: CreateMainOpts) => {
|
|
22
|
+
const NewTodoSheet = createNewTodoSheet({ controller });
|
|
23
|
+
const Header = createHeader({ NewTodoSheet });
|
|
24
|
+
|
|
25
|
+
return observer(() => {
|
|
26
|
+
const { data: todos, isPending } = useQuery({
|
|
27
|
+
...convexQuery(api.todos.crud.listTodos, {}),
|
|
28
|
+
initialData: bootstrap.todos as never,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<main className="flex flex-1 flex-col overflow-auto p-6">
|
|
33
|
+
<Header />
|
|
34
|
+
<Main
|
|
35
|
+
todos={todos}
|
|
36
|
+
isPending={isPending}
|
|
37
|
+
onToggle={(todoId, isCompleted) => {
|
|
38
|
+
void controller.updateTodo({ todoId, isCompleted });
|
|
39
|
+
}}
|
|
40
|
+
onDelete={(todoId) => {
|
|
41
|
+
void controller.deleteTodo({ todoId });
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
</main>
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Trash2 } from "lucide-react";
|
|
6
|
+
import { Link } from "react-router";
|
|
7
|
+
|
|
8
|
+
import type { Todo, TodoId } from "@/api/todos/types";
|
|
9
|
+
import { Button } from "@/ui/base/button";
|
|
10
|
+
import { Checkbox } from "@/ui/base/checkbox";
|
|
11
|
+
import { Spinner } from "@/ui/base/spinner";
|
|
12
|
+
|
|
13
|
+
type MainProps = {
|
|
14
|
+
todos: Todo[] | undefined;
|
|
15
|
+
isPending: boolean;
|
|
16
|
+
onToggle: (todoId: TodoId, isCompleted: boolean) => void;
|
|
17
|
+
onDelete: (todoId: TodoId) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Main = ({ todos, isPending, onToggle, onDelete }: MainProps) => {
|
|
21
|
+
if (isPending) {
|
|
22
|
+
return (
|
|
23
|
+
<div className="flex flex-1 items-center justify-center">
|
|
24
|
+
<Spinner />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!todos?.length) {
|
|
30
|
+
return (
|
|
31
|
+
<div className="flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground">
|
|
32
|
+
<p>No todos yet.</p>
|
|
33
|
+
<p className="text-sm">Use New Todo above to add one.</p>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ul className="flex max-w-2xl flex-col gap-2">
|
|
40
|
+
{todos.map((todo) => (
|
|
41
|
+
<li key={todo._id} className="flex items-center gap-3 rounded-lg border bg-card px-4 py-3">
|
|
42
|
+
<Checkbox
|
|
43
|
+
checked={todo.isCompleted}
|
|
44
|
+
onCheckedChange={(checked) => onToggle(todo._id, !!checked)}
|
|
45
|
+
/>
|
|
46
|
+
<Link
|
|
47
|
+
to={`/todos/${todo._id}`}
|
|
48
|
+
className="flex-1 truncate text-sm hover:underline"
|
|
49
|
+
style={{
|
|
50
|
+
textDecoration: todo.isCompleted ? "line-through" : undefined,
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
{todo.title}
|
|
54
|
+
</Link>
|
|
55
|
+
<Button
|
|
56
|
+
variant="ghost"
|
|
57
|
+
size="icon"
|
|
58
|
+
className="size-7 shrink-0 text-muted-foreground hover:text-destructive"
|
|
59
|
+
type="button"
|
|
60
|
+
onClick={() => onDelete(todo._id)}
|
|
61
|
+
>
|
|
62
|
+
<Trash2 className="size-4" />
|
|
63
|
+
</Button>
|
|
64
|
+
</li>
|
|
65
|
+
))}
|
|
66
|
+
</ul>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
6
|
+
import { observer } from "mobx-react-lite";
|
|
7
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
8
|
+
|
|
9
|
+
import type { AllTodosController } from "@/web/surfaces/todos/all_todos/all_todos_controller";
|
|
10
|
+
import { NewTodoSheet } from "@/web/surfaces/todos/all_todos/main/new_todo_sheet/new_todo_sheet";
|
|
11
|
+
import { type NewTodoSchema, newTodoSchema } from "@/web/surfaces/todos/all_todos/main/new_todo_sheet/schema";
|
|
12
|
+
|
|
13
|
+
export type CreateNewTodoSheetOpts = {
|
|
14
|
+
controller: AllTodosController;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const createNewTodoSheet = ({ controller }: CreateNewTodoSheetOpts) => {
|
|
18
|
+
return observer(() => {
|
|
19
|
+
const form = useForm<NewTodoSchema>({
|
|
20
|
+
resolver: zodResolver(newTodoSchema),
|
|
21
|
+
defaultValues: {
|
|
22
|
+
title: "",
|
|
23
|
+
description: "",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const handleSubmit = form.handleSubmit(async (values) => {
|
|
28
|
+
await controller.createTodo({
|
|
29
|
+
title: values.title.trim(),
|
|
30
|
+
description: values.description?.trim() || undefined,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
form.reset();
|
|
34
|
+
controller.closeNewTodoSheet();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<FormProvider {...form}>
|
|
39
|
+
<NewTodoSheet
|
|
40
|
+
isPending={controller.createTodoPending}
|
|
41
|
+
onSubmit={handleSubmit}
|
|
42
|
+
open={controller.isNewTodoSheetOpen}
|
|
43
|
+
onOpenChange={(open) => {
|
|
44
|
+
if (open) {
|
|
45
|
+
controller.openNewTodoSheet();
|
|
46
|
+
} else {
|
|
47
|
+
controller.closeNewTodoSheet();
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
</FormProvider>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
};
|
package/templates/apps/web/src/surfaces/todos/all_todos/main/new_todo_sheet/new_todo_sheet.tsx
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PlusIcon } from "lucide-react";
|
|
6
|
+
import { useFormContext } from "react-hook-form";
|
|
7
|
+
|
|
8
|
+
import { Button } from "@/ui/base/button";
|
|
9
|
+
import { DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/ui/base/dialog";
|
|
10
|
+
import { FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/ui/base/form";
|
|
11
|
+
import { Input } from "@/ui/base/input";
|
|
12
|
+
import { Sheet, SheetContent, SheetTrigger } from "@/ui/base/sheet";
|
|
13
|
+
import { TextArea } from "@/ui/base/text_area";
|
|
14
|
+
import type { NewTodoSchema } from "@/web/surfaces/todos/all_todos/main/new_todo_sheet/schema";
|
|
15
|
+
|
|
16
|
+
type NewTodoSheetProps = {
|
|
17
|
+
isPending: boolean;
|
|
18
|
+
onSubmit: () => void;
|
|
19
|
+
open: boolean;
|
|
20
|
+
onOpenChange: (open: boolean) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const NewTodoSheet = ({
|
|
24
|
+
isPending,
|
|
25
|
+
onSubmit,
|
|
26
|
+
open,
|
|
27
|
+
onOpenChange,
|
|
28
|
+
}: NewTodoSheetProps) => {
|
|
29
|
+
const form = useFormContext<NewTodoSchema>();
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Sheet open={open} onOpenChange={onOpenChange}>
|
|
33
|
+
<SheetTrigger asChild>
|
|
34
|
+
<Button type="button">
|
|
35
|
+
<PlusIcon className="mr-2 size-4" />
|
|
36
|
+
New Todo
|
|
37
|
+
</Button>
|
|
38
|
+
</SheetTrigger>
|
|
39
|
+
<SheetContent className="sm:max-w-[440px]">
|
|
40
|
+
<DialogHeader>
|
|
41
|
+
<DialogTitle>Create Todo</DialogTitle>
|
|
42
|
+
<DialogDescription>Add a new item to your todo list.</DialogDescription>
|
|
43
|
+
</DialogHeader>
|
|
44
|
+
<form
|
|
45
|
+
onSubmit={(e) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
onSubmit();
|
|
48
|
+
}}
|
|
49
|
+
className="flex flex-col gap-4 pt-4"
|
|
50
|
+
onKeyDown={(e) => {
|
|
51
|
+
if (e.key === "Enter") {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
onSubmit();
|
|
54
|
+
}
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<FormField
|
|
58
|
+
control={form.control}
|
|
59
|
+
name="title"
|
|
60
|
+
render={({ field }) => (
|
|
61
|
+
<FormItem>
|
|
62
|
+
<FormLabel>Title</FormLabel>
|
|
63
|
+
<FormControl>
|
|
64
|
+
<Input placeholder="Buy groceries..." {...field} />
|
|
65
|
+
</FormControl>
|
|
66
|
+
<FormMessage />
|
|
67
|
+
</FormItem>
|
|
68
|
+
)}
|
|
69
|
+
/>
|
|
70
|
+
<FormField
|
|
71
|
+
control={form.control}
|
|
72
|
+
name="description"
|
|
73
|
+
render={({ field }) => (
|
|
74
|
+
<FormItem>
|
|
75
|
+
<FormLabel>Description</FormLabel>
|
|
76
|
+
<FormControl>
|
|
77
|
+
<TextArea
|
|
78
|
+
placeholder="Optional details..."
|
|
79
|
+
className="resize-none"
|
|
80
|
+
rows={3}
|
|
81
|
+
{...field}
|
|
82
|
+
/>
|
|
83
|
+
</FormControl>
|
|
84
|
+
<FormMessage />
|
|
85
|
+
</FormItem>
|
|
86
|
+
)}
|
|
87
|
+
/>
|
|
88
|
+
<DialogFooter>
|
|
89
|
+
<Button type="submit" disabled={isPending}>
|
|
90
|
+
{isPending ? "Creating..." : "Create Todo"}
|
|
91
|
+
</Button>
|
|
92
|
+
</DialogFooter>
|
|
93
|
+
</form>
|
|
94
|
+
</SheetContent>
|
|
95
|
+
</Sheet>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
export type NewTodoSchema = z.infer<typeof newTodoSchema>;
|
|
8
|
+
export const newTodoSchema = z.object({
|
|
9
|
+
title: z.string().min(1, "Title is required"),
|
|
10
|
+
description: z.string().optional(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ConvexHttpClient } from "convex/browser";
|
|
6
|
+
import { redirect } from "react-router";
|
|
7
|
+
|
|
8
|
+
import { api } from "@/api/_generated/api";
|
|
9
|
+
import type { Todo, TodoId } from "@/api/todos/types";
|
|
10
|
+
|
|
11
|
+
export type SingleTodoBootstrapArgs = {
|
|
12
|
+
params: { id?: string };
|
|
13
|
+
client: ConvexHttpClient;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type SingleTodoBootstrap = {
|
|
17
|
+
todoId: TodoId;
|
|
18
|
+
todo: Todo;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const bootstrapSingleTodo = async ({
|
|
22
|
+
params,
|
|
23
|
+
client,
|
|
24
|
+
}: SingleTodoBootstrapArgs): Promise<SingleTodoBootstrap> => {
|
|
25
|
+
if (!params.id) {
|
|
26
|
+
throw redirect("/todos");
|
|
27
|
+
}
|
|
28
|
+
const todoId = params.id as TodoId;
|
|
29
|
+
try {
|
|
30
|
+
const todo = await client.query(api.todos.crud.getTodo, { todoId });
|
|
31
|
+
return { todoId, todo };
|
|
32
|
+
} catch {
|
|
33
|
+
throw redirect("/todos");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { observer } from "mobx-react-lite";
|
|
6
|
+
import type { NavigateFunction } from "react-router";
|
|
7
|
+
|
|
8
|
+
import { Header } from "@/web/surfaces/todos/single_todo/header/header";
|
|
9
|
+
|
|
10
|
+
export type CreateHeaderOpts = {
|
|
11
|
+
navigate: NavigateFunction;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const createHeader = ({ navigate }: CreateHeaderOpts) => {
|
|
15
|
+
return observer(() => {
|
|
16
|
+
return (
|
|
17
|
+
<Header
|
|
18
|
+
onBack={() => {
|
|
19
|
+
navigate("/todos");
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ArrowLeft } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { Button } from "@/ui/base/button";
|
|
8
|
+
|
|
9
|
+
type HeaderProps = {
|
|
10
|
+
onBack: () => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Header = ({ onBack }: HeaderProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<Button
|
|
16
|
+
variant="ghost"
|
|
17
|
+
className="-ml-2 w-fit text-muted-foreground"
|
|
18
|
+
type="button"
|
|
19
|
+
onClick={onBack}
|
|
20
|
+
>
|
|
21
|
+
<ArrowLeft className="mr-2 size-4" />
|
|
22
|
+
Back
|
|
23
|
+
</Button>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { NavigateFunction } from "react-router";
|
|
6
|
+
|
|
7
|
+
import type { SingleTodoBootstrap } from "@/web/surfaces/todos/single_todo/bootstrap";
|
|
8
|
+
import type { SingleTodoLayoutController } from "@/web/surfaces/todos/single_todo/layout";
|
|
9
|
+
import { SingleTodoController } from "@/web/surfaces/todos/single_todo/single_todo_controller";
|
|
10
|
+
|
|
11
|
+
export type InstallSingleTodoOpts = {
|
|
12
|
+
layout: SingleTodoLayoutController;
|
|
13
|
+
bootstrap: SingleTodoBootstrap;
|
|
14
|
+
navigate: NavigateFunction;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const installSingleTodo = ({ layout, bootstrap, navigate }: InstallSingleTodoOpts) => {
|
|
18
|
+
const controller = new SingleTodoController();
|
|
19
|
+
|
|
20
|
+
import("@/web/surfaces/todos/single_todo/header/create").then(({ createHeader }) => {
|
|
21
|
+
layout.setHeader(createHeader({ navigate }));
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
import("@/web/surfaces/todos/single_todo/main/create").then(({ createMain }) => {
|
|
25
|
+
layout.setMain(createMain({ controller, bootstrap }));
|
|
26
|
+
});
|
|
27
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { action, observable } from "mobx";
|
|
6
|
+
import { observer } from "mobx-react-lite";
|
|
7
|
+
import type { ComponentType } from "react";
|
|
8
|
+
|
|
9
|
+
import { Skeleton } from "@/ui/base/skeleton";
|
|
10
|
+
|
|
11
|
+
export class SingleTodoLayoutController {
|
|
12
|
+
@observable.ref
|
|
13
|
+
accessor Header: ComponentType | undefined = undefined;
|
|
14
|
+
|
|
15
|
+
@observable.ref
|
|
16
|
+
accessor Main: ComponentType | undefined = undefined;
|
|
17
|
+
|
|
18
|
+
@action
|
|
19
|
+
setHeader(Header: ComponentType) {
|
|
20
|
+
this.Header = Header;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@action
|
|
24
|
+
setMain(Main: ComponentType) {
|
|
25
|
+
this.Main = Main;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const createLayout = () => {
|
|
30
|
+
const layout = new SingleTodoLayoutController();
|
|
31
|
+
return {
|
|
32
|
+
layout,
|
|
33
|
+
Layout: observer(() => {
|
|
34
|
+
const Header = layout.Header;
|
|
35
|
+
const Main = layout.Main;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className="flex w-full flex-1 flex-col gap-4">
|
|
39
|
+
{Header ? <Header /> : <Skeleton className="h-10 w-48 rounded-md" />}
|
|
40
|
+
{Main ? <Main /> : <Skeleton className="h-64 w-full max-w-2xl rounded-md" />}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { convexQuery } from "@convex-dev/react-query";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
|
+
import { observer } from "mobx-react-lite";
|
|
8
|
+
|
|
9
|
+
import { api } from "@/api/_generated/api";
|
|
10
|
+
import type { SingleTodoBootstrap } from "@/web/surfaces/todos/single_todo/bootstrap";
|
|
11
|
+
import type { SingleTodoController } from "@/web/surfaces/todos/single_todo/single_todo_controller";
|
|
12
|
+
import { Main } from "@/web/surfaces/todos/single_todo/main/main";
|
|
13
|
+
|
|
14
|
+
export type CreateMainOpts = {
|
|
15
|
+
controller: SingleTodoController;
|
|
16
|
+
bootstrap: SingleTodoBootstrap;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const createMain = ({ controller, bootstrap }: CreateMainOpts) => {
|
|
20
|
+
return observer(() => {
|
|
21
|
+
const { data: todo } = useQuery({
|
|
22
|
+
...convexQuery(api.todos.crud.getTodo, { todoId: bootstrap.todoId }),
|
|
23
|
+
initialData: bootstrap.todo as never,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Main
|
|
28
|
+
todo={todo}
|
|
29
|
+
onToggle={(todoId, isCompleted) => {
|
|
30
|
+
void controller.updateTodo({ todoId, isCompleted });
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Aron Weston 2026.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Todo, TodoId } from "@/api/todos/types";
|
|
6
|
+
import { Badge } from "@/ui/base/badge";
|
|
7
|
+
import { Checkbox } from "@/ui/base/checkbox";
|
|
8
|
+
|
|
9
|
+
type MainProps = {
|
|
10
|
+
todo: Todo | undefined;
|
|
11
|
+
onToggle: (todoId: TodoId, isCompleted: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const Main = ({ todo, onToggle }: MainProps) => {
|
|
15
|
+
if (!todo) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<main className="flex max-w-2xl flex-1 flex-col gap-6 overflow-auto p-6">
|
|
21
|
+
<div className="flex items-start gap-3">
|
|
22
|
+
<Checkbox
|
|
23
|
+
className="mt-1"
|
|
24
|
+
checked={todo.isCompleted}
|
|
25
|
+
onCheckedChange={(checked) =>
|
|
26
|
+
onToggle(todo._id, !!checked)
|
|
27
|
+
}
|
|
28
|
+
/>
|
|
29
|
+
<div className="flex flex-col gap-2">
|
|
30
|
+
<h1
|
|
31
|
+
className="text-2xl font-semibold"
|
|
32
|
+
style={{
|
|
33
|
+
textDecoration: todo.isCompleted ? "line-through" : undefined,
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
{todo.title}
|
|
37
|
+
</h1>
|
|
38
|
+
<Badge variant={todo.isCompleted ? "secondary" : "default"}>
|
|
39
|
+
{todo.isCompleted ? "Completed" : "In progress"}
|
|
40
|
+
</Badge>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
{todo.description ? <p className="text-muted-foreground">{todo.description}</p> : null}
|
|
45
|
+
</main>
|
|
46
|
+
);
|
|
47
|
+
};
|