tvi-cli 0.1.4
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 +147 -0
- package/dist/index.js +4315 -0
- package/package.json +75 -0
- package/templates/addons/biome/biome.json.hbs +83 -0
- package/templates/addons/husky/.husky/pre-commit +1 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/apple-touch-icon.png +0 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/favicon-96x96.png +0 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/favicon.svg +6 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/site.webmanifest.hbs +21 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/web-app-manifest-192x192.png +0 -0
- package/templates/addons/pwa/apps/web/next/public/favicon/web-app-manifest-512x512.png +0 -0
- package/templates/addons/pwa/apps/web/next/src/app/manifest.ts.hbs +26 -0
- package/templates/addons/pwa/apps/web/vite/public/logo.png +0 -0
- package/templates/addons/pwa/apps/web/vite/pwa-assets.config.ts.hbs +12 -0
- package/templates/addons/turborepo/turbo.json.hbs +43 -0
- package/templates/api/orpc/native/utils/orpc.ts.hbs +35 -0
- package/templates/api/orpc/server/base/src/lib/context.ts.hbs +125 -0
- package/templates/api/orpc/server/base/src/lib/orpc.ts.hbs +21 -0
- package/templates/api/orpc/server/next/src/app/rpc/[...all]/route.ts.hbs +23 -0
- package/templates/api/orpc/web/nuxt/app/plugins/orpc.ts.hbs +35 -0
- package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +42 -0
- package/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs +30 -0
- package/templates/api/orpc/web/svelte/src/lib/orpc.ts.hbs +31 -0
- package/templates/api/trpc/native/utils/trpc.ts.hbs +32 -0
- package/templates/api/trpc/server/base/src/lib/context.ts.hbs +127 -0
- package/templates/api/trpc/server/base/src/lib/trpc.ts.hbs +26 -0
- package/templates/api/trpc/server/next/src/app/trpc/[trpc]/route.ts +14 -0
- package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +97 -0
- package/templates/auth/native/native-base/lib/auth-client.ts.hbs +13 -0
- package/templates/auth/native/nativewind/app/(drawer)/index.tsx.hbs +95 -0
- package/templates/auth/native/nativewind/components/sign-in.tsx.hbs +93 -0
- package/templates/auth/native/nativewind/components/sign-up.tsx.hbs +104 -0
- package/templates/auth/native/unistyles/app/(drawer)/index.tsx.hbs +179 -0
- package/templates/auth/native/unistyles/components/sign-in.tsx.hbs +134 -0
- package/templates/auth/native/unistyles/components/sign-up.tsx.hbs +152 -0
- package/templates/auth/server/base/src/lib/auth.ts.hbs +141 -0
- package/templates/auth/server/db/drizzle/mysql/src/db/schema/auth.ts +58 -0
- package/templates/auth/server/db/drizzle/postgres/src/db/schema/auth.ts +47 -0
- package/templates/auth/server/db/drizzle/sqlite/src/db/schema/auth.ts +55 -0
- package/templates/auth/server/db/mongoose/mongodb/src/db/models/auth.model.ts +68 -0
- package/templates/auth/server/db/prisma/mongodb/prisma/schema/auth.prisma +59 -0
- package/templates/auth/server/db/prisma/mysql/prisma/schema/auth.prisma +59 -0
- package/templates/auth/server/db/prisma/postgres/prisma/schema/auth.prisma +59 -0
- package/templates/auth/server/db/prisma/sqlite/prisma/schema/auth.prisma +59 -0
- package/templates/auth/server/next/src/app/api/auth/[...all]/route.ts +4 -0
- package/templates/auth/web/nuxt/app/components/SignInForm.vue +77 -0
- package/templates/auth/web/nuxt/app/components/SignUpForm.vue +84 -0
- package/templates/auth/web/nuxt/app/components/UserMenu.vue +42 -0
- package/templates/auth/web/nuxt/app/middleware/auth.ts +12 -0
- package/templates/auth/web/nuxt/app/pages/dashboard.vue +27 -0
- package/templates/auth/web/nuxt/app/pages/login.vue +24 -0
- package/templates/auth/web/nuxt/app/plugins/auth-client.ts +16 -0
- package/templates/auth/web/react/base/src/lib/auth-client.ts.hbs +10 -0
- package/templates/auth/web/react/next/src/app/dashboard/page.tsx.hbs +47 -0
- package/templates/auth/web/react/next/src/app/login/page.tsx +16 -0
- package/templates/auth/web/react/next/src/components/sign-in-form.tsx +135 -0
- package/templates/auth/web/react/next/src/components/sign-up-form.tsx +160 -0
- package/templates/auth/web/react/next/src/components/theme-provider.tsx +11 -0
- package/templates/auth/web/react/next/src/components/user-menu.tsx +60 -0
- package/templates/auth/web/react/react-router/src/components/sign-in-form.tsx +135 -0
- package/templates/auth/web/react/react-router/src/components/sign-up-form.tsx +160 -0
- package/templates/auth/web/react/react-router/src/components/user-menu.tsx +60 -0
- package/templates/auth/web/react/react-router/src/routes/dashboard.tsx.hbs +40 -0
- package/templates/auth/web/react/react-router/src/routes/login.tsx +13 -0
- package/templates/auth/web/react/tanstack-router/src/components/sign-in-form.tsx +139 -0
- package/templates/auth/web/react/tanstack-router/src/components/sign-up-form.tsx +164 -0
- package/templates/auth/web/react/tanstack-router/src/components/user-menu.tsx +62 -0
- package/templates/auth/web/react/tanstack-router/src/routes/dashboard.tsx.hbs +47 -0
- package/templates/auth/web/react/tanstack-router/src/routes/login.tsx +18 -0
- package/templates/auth/web/react/tanstack-start/src/components/sign-in-form.tsx +139 -0
- package/templates/auth/web/react/tanstack-start/src/components/sign-up-form.tsx +164 -0
- package/templates/auth/web/react/tanstack-start/src/components/user-menu.tsx +62 -0
- package/templates/auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +51 -0
- package/templates/auth/web/react/tanstack-start/src/routes/login.tsx +18 -0
- package/templates/auth/web/solid/src/components/sign-in-form.tsx +132 -0
- package/templates/auth/web/solid/src/components/sign-up-form.tsx +158 -0
- package/templates/auth/web/solid/src/components/user-menu.tsx.hbs +55 -0
- package/templates/auth/web/solid/src/lib/auth-client.ts +5 -0
- package/templates/auth/web/solid/src/routes/dashboard.tsx +38 -0
- package/templates/auth/web/solid/src/routes/login.tsx +23 -0
- package/templates/auth/web/svelte/src/components/SignInForm.svelte +108 -0
- package/templates/auth/web/svelte/src/components/SignUpForm.svelte +142 -0
- package/templates/auth/web/svelte/src/components/UserMenu.svelte +54 -0
- package/templates/auth/web/svelte/src/lib/auth-client.ts +6 -0
- package/templates/auth/web/svelte/src/routes/dashboard/+page.svelte +31 -0
- package/templates/auth/web/svelte/src/routes/login/+page.svelte +12 -0
- package/templates/backend/convex/packages/backend/_gitignore +2 -0
- package/templates/backend/convex/packages/backend/convex/README.md +90 -0
- package/templates/backend/convex/packages/backend/convex/healthCheck.ts +7 -0
- package/templates/backend/convex/packages/backend/convex/schema.ts +9 -0
- package/templates/backend/convex/packages/backend/convex/todos.ts +42 -0
- package/templates/backend/convex/packages/backend/convex/tsconfig.json +25 -0
- package/templates/backend/convex/packages/backend/package.json.hbs +17 -0
- package/templates/backend/server/elysia/src/index.ts.hbs +72 -0
- package/templates/backend/server/express/src/index.ts.hbs +88 -0
- package/templates/backend/server/fastify/src/index.ts.hbs +155 -0
- package/templates/backend/server/hono/src/index.ts.hbs +133 -0
- package/templates/backend/server/next/next-env.d.ts +5 -0
- package/templates/backend/server/next/next.config.ts +7 -0
- package/templates/backend/server/next/package.json.hbs +24 -0
- package/templates/backend/server/next/src/app/route.ts +5 -0
- package/templates/backend/server/next/src/middleware.ts +19 -0
- package/templates/backend/server/next/tsconfig.json.hbs +33 -0
- package/templates/backend/server/server-base/_gitignore +52 -0
- package/templates/backend/server/server-base/package.json.hbs +28 -0
- package/templates/backend/server/server-base/src/routers/index.ts.hbs +53 -0
- package/templates/backend/server/server-base/tsconfig.json.hbs +39 -0
- package/templates/base/_gitignore +2 -0
- package/templates/base/package.json.hbs +11 -0
- package/templates/db/drizzle/mysql/drizzle.config.ts.hbs +10 -0
- package/templates/db/drizzle/mysql/src/db/index.ts.hbs +20 -0
- package/templates/db/drizzle/postgres/drizzle.config.ts.hbs +10 -0
- package/templates/db/drizzle/postgres/src/db/index.ts.hbs +12 -0
- package/templates/db/drizzle/sqlite/drizzle.config.ts.hbs +24 -0
- package/templates/db/drizzle/sqlite/src/db/index.ts.hbs +35 -0
- package/templates/db/mongoose/mongodb/src/db/index.ts.hbs +9 -0
- package/templates/db/prisma/mongodb/prisma/index.ts.hbs +5 -0
- package/templates/db/prisma/mongodb/prisma/schema/schema.prisma +10 -0
- package/templates/db/prisma/mongodb/prisma.config.ts.hbs +8 -0
- package/templates/db/prisma/mysql/prisma/index.ts +5 -0
- package/templates/db/prisma/mysql/prisma/schema/schema.prisma +10 -0
- package/templates/db/prisma/mysql/prisma.config.ts +8 -0
- package/templates/db/prisma/postgres/prisma/index.ts +5 -0
- package/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs +13 -0
- package/templates/db/prisma/postgres/prisma.config.ts.hbs +12 -0
- package/templates/db/prisma/sqlite/prisma/index.ts +5 -0
- package/templates/db/prisma/sqlite/prisma/schema/schema.prisma +10 -0
- package/templates/db/prisma/sqlite/prisma.config.ts +8 -0
- package/templates/examples/ai/native/nativewind/app/(drawer)/ai.tsx.hbs +155 -0
- package/templates/examples/ai/native/nativewind/polyfills.js +25 -0
- package/templates/examples/ai/native/unistyles/app/(drawer)/ai.tsx.hbs +279 -0
- package/templates/examples/ai/native/unistyles/polyfills.js +25 -0
- package/templates/examples/ai/server/next/src/app/ai/route.ts +15 -0
- package/templates/examples/ai/web/nuxt/app/pages/ai.vue +63 -0
- package/templates/examples/ai/web/react/next/src/app/ai/page.tsx +67 -0
- package/templates/examples/ai/web/react/react-router/src/routes/ai.tsx +64 -0
- package/templates/examples/ai/web/react/tanstack-router/src/routes/ai.tsx +69 -0
- package/templates/examples/ai/web/react/tanstack-start/src/routes/ai.tsx +69 -0
- package/templates/examples/ai/web/svelte/src/routes/ai/+page.svelte +98 -0
- package/templates/examples/todo/native/nativewind/app/(drawer)/todos.tsx.hbs +295 -0
- package/templates/examples/todo/native/unistyles/app/(drawer)/todos.tsx.hbs +340 -0
- package/templates/examples/todo/server/drizzle/base/src/routers/todo.ts.hbs +79 -0
- package/templates/examples/todo/server/drizzle/mysql/src/db/schema/todo.ts +7 -0
- package/templates/examples/todo/server/drizzle/postgres/src/db/schema/todo.ts +7 -0
- package/templates/examples/todo/server/drizzle/sqlite/src/db/schema/todo.ts +7 -0
- package/templates/examples/todo/server/mongoose/base/src/routers/todo.ts.hbs +66 -0
- package/templates/examples/todo/server/mongoose/mongodb/src/db/models/todo.model.ts +24 -0
- package/templates/examples/todo/server/prisma/base/src/routers/todo.ts.hbs +118 -0
- package/templates/examples/todo/server/prisma/mongodb/prisma/schema/todo.prisma +7 -0
- package/templates/examples/todo/server/prisma/mysql/prisma/schema/todo.prisma +7 -0
- package/templates/examples/todo/server/prisma/postgres/prisma/schema/todo.prisma +7 -0
- package/templates/examples/todo/server/prisma/sqlite/prisma/schema/todo.prisma +7 -0
- package/templates/examples/todo/web/nuxt/app/pages/todos.vue +108 -0
- package/templates/examples/todo/web/react/next/src/app/todos/page.tsx.hbs +245 -0
- package/templates/examples/todo/web/react/react-router/src/routes/todos.tsx.hbs +242 -0
- package/templates/examples/todo/web/react/tanstack-router/src/routes/todos.tsx.hbs +247 -0
- package/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs +268 -0
- package/templates/examples/todo/web/solid/src/routes/todos.tsx.hbs +132 -0
- package/templates/examples/todo/web/svelte/src/routes/todos/+page.svelte.hbs +317 -0
- package/templates/extras/_npmrc.hbs +5 -0
- package/templates/extras/pnpm-workspace.yaml +3 -0
- package/templates/frontend/native/native-base/assets/adaptive-icon.png +0 -0
- package/templates/frontend/native/native-base/assets/favicon.png +0 -0
- package/templates/frontend/native/native-base/assets/icon.png +0 -0
- package/templates/frontend/native/native-base/assets/splash.png +0 -0
- package/templates/frontend/native/nativewind/_gitignore +25 -0
- package/templates/frontend/native/nativewind/app/(drawer)/(tabs)/_layout.tsx +46 -0
- package/templates/frontend/native/nativewind/app/(drawer)/(tabs)/index.tsx +19 -0
- package/templates/frontend/native/nativewind/app/(drawer)/(tabs)/two.tsx +19 -0
- package/templates/frontend/native/nativewind/app/(drawer)/_layout.tsx.hbs +67 -0
- package/templates/frontend/native/nativewind/app/(drawer)/index.tsx.hbs +95 -0
- package/templates/frontend/native/nativewind/app/+html.tsx +47 -0
- package/templates/frontend/native/nativewind/app/+not-found.tsx +29 -0
- package/templates/frontend/native/nativewind/app/_layout.tsx.hbs +126 -0
- package/templates/frontend/native/nativewind/app/modal.tsx +14 -0
- package/templates/frontend/native/nativewind/app-env.d.ts +2 -0
- package/templates/frontend/native/nativewind/app.json +46 -0
- package/templates/frontend/native/nativewind/babel.config.js +11 -0
- package/templates/frontend/native/nativewind/components/container.tsx +8 -0
- package/templates/frontend/native/nativewind/components/header-button.tsx +26 -0
- package/templates/frontend/native/nativewind/components/tabbar-icon.tsx +8 -0
- package/templates/frontend/native/nativewind/global.css +50 -0
- package/templates/frontend/native/nativewind/lib/android-navigation-bar.tsx +11 -0
- package/templates/frontend/native/nativewind/lib/constants.ts +18 -0
- package/templates/frontend/native/nativewind/lib/use-color-scheme.ts +12 -0
- package/templates/frontend/native/nativewind/metro.config.js +59 -0
- package/templates/frontend/native/nativewind/package.json.hbs +49 -0
- package/templates/frontend/native/nativewind/tailwind.config.js +59 -0
- package/templates/frontend/native/nativewind/tsconfig.json.hbs +23 -0
- package/templates/frontend/native/unistyles/_gitignore +24 -0
- package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/_layout.tsx +39 -0
- package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/index.tsx +37 -0
- package/templates/frontend/native/unistyles/app/(drawer)/(tabs)/two.tsx +37 -0
- package/templates/frontend/native/unistyles/app/(drawer)/_layout.tsx.hbs +87 -0
- package/templates/frontend/native/unistyles/app/(drawer)/index.tsx.hbs +194 -0
- package/templates/frontend/native/unistyles/app/+html.tsx +48 -0
- package/templates/frontend/native/unistyles/app/+not-found.tsx +65 -0
- package/templates/frontend/native/unistyles/app/_layout.tsx.hbs +104 -0
- package/templates/frontend/native/unistyles/app/modal.tsx +33 -0
- package/templates/frontend/native/unistyles/app.json +44 -0
- package/templates/frontend/native/unistyles/babel.config.js +20 -0
- package/templates/frontend/native/unistyles/breakpoints.ts +9 -0
- package/templates/frontend/native/unistyles/components/container.tsx +15 -0
- package/templates/frontend/native/unistyles/components/header-button.tsx +36 -0
- package/templates/frontend/native/unistyles/components/tabbar-icon.tsx +8 -0
- package/templates/frontend/native/unistyles/expo-env.d.ts +3 -0
- package/templates/frontend/native/unistyles/index.js +2 -0
- package/templates/frontend/native/unistyles/metro.config.js +20 -0
- package/templates/frontend/native/unistyles/package.json.hbs +50 -0
- package/templates/frontend/native/unistyles/theme.ts +98 -0
- package/templates/frontend/native/unistyles/tsconfig.json.hbs +17 -0
- package/templates/frontend/native/unistyles/unistyles.ts +27 -0
- package/templates/frontend/nuxt/_gitignore +24 -0
- package/templates/frontend/nuxt/app/app.config.ts +15 -0
- package/templates/frontend/nuxt/app/app.vue +13 -0
- package/templates/frontend/nuxt/app/assets/css/main.css +2 -0
- package/templates/frontend/nuxt/app/components/Header.vue.hbs +45 -0
- package/templates/frontend/nuxt/app/components/Loader.vue +5 -0
- package/templates/frontend/nuxt/app/components/ModeToggle.vue +23 -0
- package/templates/frontend/nuxt/app/layouts/default.vue.hbs +11 -0
- package/templates/frontend/nuxt/app/pages/index.vue.hbs +57 -0
- package/templates/frontend/nuxt/app/plugins/vue-query.ts.hbs +44 -0
- package/templates/frontend/nuxt/nuxt.config.ts.hbs +19 -0
- package/templates/frontend/nuxt/package.json.hbs +25 -0
- package/templates/frontend/nuxt/public/favicon.ico +0 -0
- package/templates/frontend/nuxt/public/robots.txt +2 -0
- package/templates/frontend/nuxt/server/tsconfig.json +3 -0
- package/templates/frontend/nuxt/tsconfig.json.hbs +9 -0
- package/templates/frontend/react/next/next-env.d.ts.hbs +5 -0
- package/templates/frontend/react/next/next.config.ts.hbs +5 -0
- package/templates/frontend/react/next/package.json.hbs +34 -0
- package/templates/frontend/react/next/postcss.config.mjs.hbs +5 -0
- package/templates/frontend/react/next/src/app/favicon.ico +0 -0
- package/templates/frontend/react/next/src/app/layout.tsx.hbs +41 -0
- package/templates/frontend/react/next/src/app/page.tsx.hbs +68 -0
- package/templates/frontend/react/next/src/components/mode-toggle.tsx.hbs +39 -0
- package/templates/frontend/react/next/src/components/providers.tsx.hbs +56 -0
- package/templates/frontend/react/next/src/components/theme-provider.tsx.hbs +11 -0
- package/templates/frontend/react/next/tsconfig.json.hbs +33 -0
- package/templates/frontend/react/react-router/package.json.hbs +42 -0
- package/templates/frontend/react/react-router/public/favicon.ico +0 -0
- package/templates/frontend/react/react-router/react-router.config.ts +6 -0
- package/templates/frontend/react/react-router/src/components/mode-toggle.tsx +37 -0
- package/templates/frontend/react/react-router/src/components/theme-provider.tsx +73 -0
- package/templates/frontend/react/react-router/src/root.tsx.hbs +152 -0
- package/templates/frontend/react/react-router/src/routes/_index.tsx.hbs +74 -0
- package/templates/frontend/react/react-router/src/routes.ts +4 -0
- package/templates/frontend/react/react-router/tsconfig.json.hbs +32 -0
- package/templates/frontend/react/react-router/vite.config.ts.hbs +33 -0
- package/templates/frontend/react/tanstack-router/index.html +12 -0
- package/templates/frontend/react/tanstack-router/package.json.hbs +41 -0
- package/templates/frontend/react/tanstack-router/src/components/mode-toggle.tsx +37 -0
- package/templates/frontend/react/tanstack-router/src/components/theme-provider.tsx +73 -0
- package/templates/frontend/react/tanstack-router/src/main.tsx.hbs +66 -0
- package/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs +100 -0
- package/templates/frontend/react/tanstack-router/src/routes/index.tsx.hbs +74 -0
- package/templates/frontend/react/tanstack-router/tsconfig.json.hbs +23 -0
- package/templates/frontend/react/tanstack-router/vite.config.ts.hbs +39 -0
- package/templates/frontend/react/tanstack-start/package.json.hbs +44 -0
- package/templates/frontend/react/tanstack-start/public/robots.txt +3 -0
- package/templates/frontend/react/tanstack-start/src/router.tsx.hbs +144 -0
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +97 -0
- package/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs +74 -0
- package/templates/frontend/react/tanstack-start/tsconfig.json.hbs +33 -0
- package/templates/frontend/react/tanstack-start/vite.config.ts +8 -0
- package/templates/frontend/react/web-base/_gitignore +52 -0
- package/templates/frontend/react/web-base/components.json +21 -0
- package/templates/frontend/react/web-base/src/components/header.tsx.hbs +79 -0
- package/templates/frontend/react/web-base/src/components/loader.tsx +9 -0
- package/templates/frontend/react/web-base/src/components/ui/button.tsx +59 -0
- package/templates/frontend/react/web-base/src/components/ui/card.tsx +92 -0
- package/templates/frontend/react/web-base/src/components/ui/checkbox.tsx +30 -0
- package/templates/frontend/react/web-base/src/components/ui/dropdown-menu.tsx +257 -0
- package/templates/frontend/react/web-base/src/components/ui/input.tsx +21 -0
- package/templates/frontend/react/web-base/src/components/ui/label.tsx +22 -0
- package/templates/frontend/react/web-base/src/components/ui/skeleton.tsx +13 -0
- package/templates/frontend/react/web-base/src/components/ui/sonner.tsx +25 -0
- package/templates/frontend/react/web-base/src/index.css +134 -0
- package/templates/frontend/react/web-base/src/lib/utils.ts +6 -0
- package/templates/frontend/solid/_gitignore +7 -0
- package/templates/frontend/solid/index.html +13 -0
- package/templates/frontend/solid/package.json.hbs +27 -0
- package/templates/frontend/solid/public/robots.txt +3 -0
- package/templates/frontend/solid/src/components/header.tsx.hbs +38 -0
- package/templates/frontend/solid/src/components/loader.tsx +9 -0
- package/templates/frontend/solid/src/main.tsx.hbs +38 -0
- package/templates/frontend/solid/src/routes/__root.tsx.hbs +34 -0
- package/templates/frontend/solid/src/routes/index.tsx.hbs +61 -0
- package/templates/frontend/solid/src/styles.css +5 -0
- package/templates/frontend/solid/tsconfig.json.hbs +34 -0
- package/templates/frontend/solid/vite.config.js.hbs +39 -0
- package/templates/frontend/svelte/_gitignore +23 -0
- package/templates/frontend/svelte/_npmrc +1 -0
- package/templates/frontend/svelte/package.json.hbs +31 -0
- package/templates/frontend/svelte/src/app.css +5 -0
- package/templates/frontend/svelte/src/app.d.ts +13 -0
- package/templates/frontend/svelte/src/app.html +12 -0
- package/templates/frontend/svelte/src/components/Header.svelte.hbs +40 -0
- package/templates/frontend/svelte/src/lib/index.ts +1 -0
- package/templates/frontend/svelte/src/routes/+layout.svelte.hbs +54 -0
- package/templates/frontend/svelte/src/routes/+page.svelte.hbs +72 -0
- package/templates/frontend/svelte/static/favicon.png +0 -0
- package/templates/frontend/svelte/svelte.config.js +18 -0
- package/templates/frontend/svelte/tsconfig.json.hbs +24 -0
- package/templates/frontend/svelte/vite.config.ts +7 -0
- package/templates/runtime/workers/apps/server/wrangler.jsonc.hbs +34 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
<script setup lang="ts">
|
2
|
+
import { ref } from 'vue'
|
3
|
+
import { useQuery, useMutation, useQueryClient } from '@tanstack/vue-query'
|
4
|
+
|
5
|
+
const { $orpc } = useNuxtApp()
|
6
|
+
|
7
|
+
const newTodoText = ref('')
|
8
|
+
const queryClient = useQueryClient()
|
9
|
+
|
10
|
+
const todos = useQuery($orpc.todo.getAll.queryOptions())
|
11
|
+
|
12
|
+
const createMutation = useMutation($orpc.todo.create.mutationOptions({
|
13
|
+
onSuccess: () => {
|
14
|
+
queryClient.invalidateQueries()
|
15
|
+
newTodoText.value = ''
|
16
|
+
}
|
17
|
+
}))
|
18
|
+
|
19
|
+
const toggleMutation = useMutation($orpc.todo.toggle.mutationOptions({
|
20
|
+
onSuccess: () => queryClient.invalidateQueries()
|
21
|
+
}))
|
22
|
+
|
23
|
+
const deleteMutation = useMutation($orpc.todo.delete.mutationOptions({
|
24
|
+
onSuccess: () => queryClient.invalidateQueries()
|
25
|
+
}))
|
26
|
+
|
27
|
+
function handleAddTodo() {
|
28
|
+
if (newTodoText.value.trim()) {
|
29
|
+
createMutation.mutate({ text: newTodoText.value })
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
function handleToggleTodo(id: number, completed: boolean) {
|
34
|
+
toggleMutation.mutate({ id, completed: !completed })
|
35
|
+
}
|
36
|
+
|
37
|
+
function handleDeleteTodo(id: number) {
|
38
|
+
deleteMutation.mutate({ id })
|
39
|
+
}
|
40
|
+
</script>
|
41
|
+
|
42
|
+
<template>
|
43
|
+
<div class="mx-auto w-full max-w-md py-10">
|
44
|
+
<UCard>
|
45
|
+
<template #header>
|
46
|
+
<div>
|
47
|
+
<div class="text-xl font-bold">Todo List</div>
|
48
|
+
<div class="text-muted text-sm">Manage your tasks efficiently</div>
|
49
|
+
</div>
|
50
|
+
</template>
|
51
|
+
<form @submit.prevent="handleAddTodo" class="mb-6 flex items-center gap-2">
|
52
|
+
<UInput
|
53
|
+
v-model="newTodoText"
|
54
|
+
placeholder="Add a new task..."
|
55
|
+
autocomplete="off"
|
56
|
+
class="w-full"
|
57
|
+
/>
|
58
|
+
<UButton
|
59
|
+
type="submit"
|
60
|
+
icon="i-lucide-plus"
|
61
|
+
>
|
62
|
+
Add
|
63
|
+
</UButton>
|
64
|
+
</form>
|
65
|
+
|
66
|
+
<div v-if="todos.status.value === 'pending'" class="flex justify-center py-4">
|
67
|
+
<UIcon name="i-lucide-loader-2" class="animate-spin w-6 h-6" />
|
68
|
+
</div>
|
69
|
+
<p v-else-if="todos.status.value === 'error'" class="py-4 text-center text-red-500">
|
70
|
+
Error: {{ todos.error.value?.message || 'Failed to load todos' }}
|
71
|
+
</p>
|
72
|
+
<p v-else-if="todos.data.value?.length === 0" class="py-4 text-center">
|
73
|
+
No todos yet. Add one above!
|
74
|
+
</p>
|
75
|
+
<ul v-else class="space-y-2">
|
76
|
+
<li
|
77
|
+
v-for="todo in todos.data.value"
|
78
|
+
:key="todo.id"
|
79
|
+
class="flex items-center justify-between rounded-md border p-2"
|
80
|
+
>
|
81
|
+
<div class="flex items-center gap-2">
|
82
|
+
<UCheckbox
|
83
|
+
:model-value="todo.completed"
|
84
|
+
@update:model-value="() => handleToggleTodo(todo.id, todo.completed)"
|
85
|
+
:id="`todo-${todo.id}`"
|
86
|
+
/>
|
87
|
+
<label
|
88
|
+
:for="`todo-${todo.id}`"
|
89
|
+
:class="{ 'line-through text-muted': todo.completed }"
|
90
|
+
class="cursor-pointer"
|
91
|
+
>
|
92
|
+
{{ todo.text }}
|
93
|
+
</label>
|
94
|
+
</div>
|
95
|
+
<UButton
|
96
|
+
color="neutral"
|
97
|
+
variant="ghost"
|
98
|
+
size="sm"
|
99
|
+
square
|
100
|
+
@click="handleDeleteTodo(todo.id)"
|
101
|
+
aria-label="Delete todo"
|
102
|
+
icon="i-lucide-trash-2"
|
103
|
+
/>
|
104
|
+
</li>
|
105
|
+
</ul>
|
106
|
+
</UCard>
|
107
|
+
</div>
|
108
|
+
</template>
|
@@ -0,0 +1,245 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
import { Button } from "@/components/ui/button";
|
4
|
+
import {
|
5
|
+
Card,
|
6
|
+
CardContent,
|
7
|
+
CardDescription,
|
8
|
+
CardHeader,
|
9
|
+
CardTitle,
|
10
|
+
} from "@/components/ui/card";
|
11
|
+
import { Checkbox } from "@/components/ui/checkbox";
|
12
|
+
import { Input } from "@/components/ui/input";
|
13
|
+
import { Loader2, Trash2 } from "lucide-react";
|
14
|
+
import { useState } from "react";
|
15
|
+
|
16
|
+
{{#if (eq backend "convex")}}
|
17
|
+
import { useMutation, useQuery } from "convex/react";
|
18
|
+
import { api } from "@{{projectName}}/backend/convex/_generated/api";
|
19
|
+
import type { Id } from "@{{projectName}}/backend/convex/_generated/dataModel";
|
20
|
+
{{else}}
|
21
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
22
|
+
{{#if (eq api "orpc")}}
|
23
|
+
import { orpc } from "@/utils/orpc";
|
24
|
+
{{/if}}
|
25
|
+
{{#if (eq api "trpc")}}
|
26
|
+
import { trpc } from "@/utils/trpc";
|
27
|
+
{{/if}}
|
28
|
+
{{/if}}
|
29
|
+
|
30
|
+
|
31
|
+
export default function TodosPage() {
|
32
|
+
const [newTodoText, setNewTodoText] = useState("");
|
33
|
+
|
34
|
+
{{#if (eq backend "convex")}}
|
35
|
+
const todos = useQuery(api.todos.getAll);
|
36
|
+
const createTodoMutation = useMutation(api.todos.create);
|
37
|
+
const toggleTodoMutation = useMutation(api.todos.toggle);
|
38
|
+
const deleteTodoMutation = useMutation(api.todos.deleteTodo);
|
39
|
+
|
40
|
+
const handleAddTodo = async (e: React.FormEvent) => {
|
41
|
+
e.preventDefault();
|
42
|
+
const text = newTodoText.trim();
|
43
|
+
if (!text) return;
|
44
|
+
await createTodoMutation({ text });
|
45
|
+
setNewTodoText("");
|
46
|
+
};
|
47
|
+
|
48
|
+
const handleToggleTodo = (id: Id<"todos">, currentCompleted: boolean) => {
|
49
|
+
toggleTodoMutation({ id, completed: !currentCompleted });
|
50
|
+
};
|
51
|
+
|
52
|
+
const handleDeleteTodo = (id: Id<"todos">) => {
|
53
|
+
deleteTodoMutation({ id });
|
54
|
+
};
|
55
|
+
{{else}}
|
56
|
+
{{#if (eq api "orpc")}}
|
57
|
+
const todos = useQuery(orpc.todo.getAll.queryOptions());
|
58
|
+
const createMutation = useMutation(
|
59
|
+
orpc.todo.create.mutationOptions({
|
60
|
+
onSuccess: () => {
|
61
|
+
todos.refetch();
|
62
|
+
setNewTodoText("");
|
63
|
+
},
|
64
|
+
}),
|
65
|
+
);
|
66
|
+
const toggleMutation = useMutation(
|
67
|
+
orpc.todo.toggle.mutationOptions({
|
68
|
+
onSuccess: () => { todos.refetch() },
|
69
|
+
}),
|
70
|
+
);
|
71
|
+
const deleteMutation = useMutation(
|
72
|
+
orpc.todo.delete.mutationOptions({
|
73
|
+
onSuccess: () => { todos.refetch() },
|
74
|
+
}),
|
75
|
+
);
|
76
|
+
{{/if}}
|
77
|
+
{{#if (eq api "trpc")}}
|
78
|
+
const todos = useQuery(trpc.todo.getAll.queryOptions());
|
79
|
+
const createMutation = useMutation(
|
80
|
+
trpc.todo.create.mutationOptions({
|
81
|
+
onSuccess: () => {
|
82
|
+
todos.refetch();
|
83
|
+
setNewTodoText("");
|
84
|
+
},
|
85
|
+
}),
|
86
|
+
);
|
87
|
+
const toggleMutation = useMutation(
|
88
|
+
trpc.todo.toggle.mutationOptions({
|
89
|
+
onSuccess: () => { todos.refetch() },
|
90
|
+
}),
|
91
|
+
);
|
92
|
+
const deleteMutation = useMutation(
|
93
|
+
trpc.todo.delete.mutationOptions({
|
94
|
+
onSuccess: () => { todos.refetch() },
|
95
|
+
}),
|
96
|
+
);
|
97
|
+
{{/if}}
|
98
|
+
|
99
|
+
const handleAddTodo = (e: React.FormEvent) => {
|
100
|
+
e.preventDefault();
|
101
|
+
if (newTodoText.trim()) {
|
102
|
+
createMutation.mutate({ text: newTodoText });
|
103
|
+
}
|
104
|
+
};
|
105
|
+
|
106
|
+
const handleToggleTodo = (id: number, completed: boolean) => {
|
107
|
+
toggleMutation.mutate({ id, completed: !completed });
|
108
|
+
};
|
109
|
+
|
110
|
+
const handleDeleteTodo = (id: number) => {
|
111
|
+
deleteMutation.mutate({ id });
|
112
|
+
};
|
113
|
+
{{/if}}
|
114
|
+
|
115
|
+
return (
|
116
|
+
<div className="mx-auto w-full max-w-md py-10">
|
117
|
+
<Card>
|
118
|
+
<CardHeader>
|
119
|
+
<CardTitle>Todo List</CardTitle>
|
120
|
+
<CardDescription>Manage your tasks efficiently</CardDescription>
|
121
|
+
</CardHeader>
|
122
|
+
<CardContent>
|
123
|
+
<form
|
124
|
+
onSubmit={handleAddTodo}
|
125
|
+
className="mb-6 flex items-center space-x-2"
|
126
|
+
>
|
127
|
+
<Input
|
128
|
+
value={newTodoText}
|
129
|
+
onChange={(e) => setNewTodoText(e.target.value)}
|
130
|
+
placeholder="Add a new task..."
|
131
|
+
{{#if (eq backend "convex")}}
|
132
|
+
{{else}}
|
133
|
+
disabled={createMutation.isPending}
|
134
|
+
{{/if}}
|
135
|
+
/>
|
136
|
+
<Button
|
137
|
+
type="submit"
|
138
|
+
{{#if (eq backend "convex")}}
|
139
|
+
disabled={!newTodoText.trim()}
|
140
|
+
{{else}}
|
141
|
+
disabled={createMutation.isPending || !newTodoText.trim()}
|
142
|
+
{{/if}}
|
143
|
+
>
|
144
|
+
{{#if (eq backend "convex")}}
|
145
|
+
Add
|
146
|
+
{{else}}
|
147
|
+
{createMutation.isPending ? (
|
148
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
149
|
+
) : (
|
150
|
+
"Add"
|
151
|
+
)}
|
152
|
+
{{/if}}
|
153
|
+
</Button>
|
154
|
+
</form>
|
155
|
+
|
156
|
+
{{#if (eq backend "convex")}}
|
157
|
+
{todos === undefined ? (
|
158
|
+
<div className="flex justify-center py-4">
|
159
|
+
<Loader2 className="h-6 w-6 animate-spin" />
|
160
|
+
</div>
|
161
|
+
) : todos.length === 0 ? (
|
162
|
+
<p className="py-4 text-center">No todos yet. Add one above!</p>
|
163
|
+
) : (
|
164
|
+
<ul className="space-y-2">
|
165
|
+
{todos.map((todo) => (
|
166
|
+
<li
|
167
|
+
key={todo._id}
|
168
|
+
className="flex items-center justify-between rounded-md border p-2"
|
169
|
+
>
|
170
|
+
<div className="flex items-center space-x-2">
|
171
|
+
<Checkbox
|
172
|
+
checked={todo.completed}
|
173
|
+
onCheckedChange={() =>
|
174
|
+
handleToggleTodo(todo._id, todo.completed)
|
175
|
+
}
|
176
|
+
id={`todo-${todo._id}`}
|
177
|
+
/>
|
178
|
+
<label
|
179
|
+
htmlFor={`todo-${todo._id}`}
|
180
|
+
className={`${todo.completed ? "line-through text-muted-foreground" : ""}`}
|
181
|
+
>
|
182
|
+
{todo.text}
|
183
|
+
</label>
|
184
|
+
</div>
|
185
|
+
<Button
|
186
|
+
variant="ghost"
|
187
|
+
size="icon"
|
188
|
+
onClick={() => handleDeleteTodo(todo._id)}
|
189
|
+
aria-label="Delete todo"
|
190
|
+
>
|
191
|
+
<Trash2 className="h-4 w-4" />
|
192
|
+
</Button>
|
193
|
+
</li>
|
194
|
+
))}
|
195
|
+
</ul>
|
196
|
+
)}
|
197
|
+
{{else}}
|
198
|
+
{todos.isLoading ? (
|
199
|
+
<div className="flex justify-center py-4">
|
200
|
+
<Loader2 className="h-6 w-6 animate-spin" />
|
201
|
+
</div>
|
202
|
+
) : todos.data?.length === 0 ? (
|
203
|
+
<p className="py-4 text-center">
|
204
|
+
No todos yet. Add one above!
|
205
|
+
</p>
|
206
|
+
) : (
|
207
|
+
<ul className="space-y-2">
|
208
|
+
{todos.data?.map((todo) => (
|
209
|
+
<li
|
210
|
+
key={todo.id}
|
211
|
+
className="flex items-center justify-between rounded-md border p-2"
|
212
|
+
>
|
213
|
+
<div className="flex items-center space-x-2">
|
214
|
+
<Checkbox
|
215
|
+
checked={todo.completed}
|
216
|
+
onCheckedChange={() =>
|
217
|
+
handleToggleTodo(todo.id, todo.completed)
|
218
|
+
}
|
219
|
+
id={`todo-${todo.id}`}
|
220
|
+
/>
|
221
|
+
<label
|
222
|
+
htmlFor={`todo-${todo.id}`}
|
223
|
+
className={`${todo.completed ? "line-through text-muted-foreground" : ""}`}
|
224
|
+
>
|
225
|
+
{todo.text}
|
226
|
+
</label>
|
227
|
+
</div>
|
228
|
+
<Button
|
229
|
+
variant="ghost"
|
230
|
+
size="icon"
|
231
|
+
onClick={() => handleDeleteTodo(todo.id)}
|
232
|
+
aria-label="Delete todo"
|
233
|
+
>
|
234
|
+
<Trash2 className="h-4 w-4" />
|
235
|
+
</Button>
|
236
|
+
</li>
|
237
|
+
))}
|
238
|
+
</ul>
|
239
|
+
)}
|
240
|
+
{{/if}}
|
241
|
+
</CardContent>
|
242
|
+
</Card>
|
243
|
+
</div>
|
244
|
+
);
|
245
|
+
}
|
@@ -0,0 +1,242 @@
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
2
|
+
import {
|
3
|
+
Card,
|
4
|
+
CardContent,
|
5
|
+
CardDescription,
|
6
|
+
CardHeader,
|
7
|
+
CardTitle,
|
8
|
+
} from "@/components/ui/card";
|
9
|
+
import { Checkbox } from "@/components/ui/checkbox";
|
10
|
+
import { Input } from "@/components/ui/input";
|
11
|
+
import { Loader2, Trash2 } from "lucide-react";
|
12
|
+
import { useState } from "react";
|
13
|
+
|
14
|
+
{{#if (eq backend "convex")}}
|
15
|
+
import { useMutation, useQuery } from "convex/react";
|
16
|
+
import { api } from "@{{projectName}}/backend/convex/_generated/api";
|
17
|
+
import type { Id } from "@{{projectName}}/backend/convex/_generated/dataModel";
|
18
|
+
{{else}}
|
19
|
+
{{#if (eq api "orpc")}}
|
20
|
+
import { orpc } from "@/utils/orpc";
|
21
|
+
{{/if}}
|
22
|
+
{{#if (eq api "trpc")}}
|
23
|
+
import { trpc } from "@/utils/trpc";
|
24
|
+
{{/if}}
|
25
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
26
|
+
{{/if}}
|
27
|
+
|
28
|
+
export default function Todos() {
|
29
|
+
const [newTodoText, setNewTodoText] = useState("");
|
30
|
+
|
31
|
+
{{#if (eq backend "convex")}}
|
32
|
+
const todos = useQuery(api.todos.getAll);
|
33
|
+
const createTodo = useMutation(api.todos.create);
|
34
|
+
const toggleTodo = useMutation(api.todos.toggle);
|
35
|
+
const deleteTodo = useMutation(api.todos.deleteTodo);
|
36
|
+
|
37
|
+
const handleAddTodo = async (e: React.FormEvent) => {
|
38
|
+
e.preventDefault();
|
39
|
+
const text = newTodoText.trim();
|
40
|
+
if (!text) return;
|
41
|
+
await createTodo({ text });
|
42
|
+
setNewTodoText("");
|
43
|
+
};
|
44
|
+
|
45
|
+
const handleToggleTodo = (id: Id<"todos">, currentCompleted: boolean) => {
|
46
|
+
toggleTodo({ id, completed: !currentCompleted });
|
47
|
+
};
|
48
|
+
|
49
|
+
const handleDeleteTodo = (id: Id<"todos">) => {
|
50
|
+
deleteTodo({ id });
|
51
|
+
};
|
52
|
+
{{else}}
|
53
|
+
{{#if (eq api "orpc")}}
|
54
|
+
const todos = useQuery(orpc.todo.getAll.queryOptions());
|
55
|
+
const createMutation = useMutation(
|
56
|
+
orpc.todo.create.mutationOptions({
|
57
|
+
onSuccess: () => {
|
58
|
+
todos.refetch();
|
59
|
+
setNewTodoText("");
|
60
|
+
},
|
61
|
+
})
|
62
|
+
);
|
63
|
+
const toggleMutation = useMutation(
|
64
|
+
orpc.todo.toggle.mutationOptions({
|
65
|
+
onSuccess: () => { todos.refetch() },
|
66
|
+
})
|
67
|
+
);
|
68
|
+
const deleteMutation = useMutation(
|
69
|
+
orpc.todo.delete.mutationOptions({
|
70
|
+
onSuccess: () => { todos.refetch() },
|
71
|
+
})
|
72
|
+
);
|
73
|
+
{{/if}}
|
74
|
+
{{#if (eq api "trpc")}}
|
75
|
+
const todos = useQuery(trpc.todo.getAll.queryOptions());
|
76
|
+
const createMutation = useMutation(
|
77
|
+
trpc.todo.create.mutationOptions({
|
78
|
+
onSuccess: () => {
|
79
|
+
todos.refetch();
|
80
|
+
setNewTodoText("");
|
81
|
+
},
|
82
|
+
})
|
83
|
+
);
|
84
|
+
const toggleMutation = useMutation(
|
85
|
+
trpc.todo.toggle.mutationOptions({
|
86
|
+
onSuccess: () => { todos.refetch() },
|
87
|
+
})
|
88
|
+
);
|
89
|
+
const deleteMutation = useMutation(
|
90
|
+
trpc.todo.delete.mutationOptions({
|
91
|
+
onSuccess: () => { todos.refetch() },
|
92
|
+
})
|
93
|
+
);
|
94
|
+
{{/if}}
|
95
|
+
|
96
|
+
const handleAddTodo = (e: React.FormEvent) => {
|
97
|
+
e.preventDefault();
|
98
|
+
if (newTodoText.trim()) {
|
99
|
+
createMutation.mutate({ text: newTodoText });
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
const handleToggleTodo = (id: number, completed: boolean) => {
|
104
|
+
toggleMutation.mutate({ id, completed: !completed });
|
105
|
+
};
|
106
|
+
|
107
|
+
const handleDeleteTodo = (id: number) => {
|
108
|
+
deleteMutation.mutate({ id });
|
109
|
+
};
|
110
|
+
{{/if}}
|
111
|
+
|
112
|
+
return (
|
113
|
+
<div className="w-full mx-auto max-w-md py-10">
|
114
|
+
<Card>
|
115
|
+
<CardHeader>
|
116
|
+
<CardTitle>Todo List</CardTitle>
|
117
|
+
<CardDescription>Manage your tasks efficiently</CardDescription>
|
118
|
+
</CardHeader>
|
119
|
+
<CardContent>
|
120
|
+
<form
|
121
|
+
onSubmit={handleAddTodo}
|
122
|
+
className="mb-6 flex items-center space-x-2"
|
123
|
+
>
|
124
|
+
<Input
|
125
|
+
value={newTodoText}
|
126
|
+
onChange={(e) => setNewTodoText(e.target.value)}
|
127
|
+
placeholder="Add a new task..."
|
128
|
+
{{#if (eq backend "convex")}}
|
129
|
+
{{else}}
|
130
|
+
disabled={createMutation.isPending}
|
131
|
+
{{/if}}
|
132
|
+
/>
|
133
|
+
<Button
|
134
|
+
type="submit"
|
135
|
+
{{#if (eq backend "convex")}}
|
136
|
+
disabled={!newTodoText.trim()}
|
137
|
+
{{else}}
|
138
|
+
disabled={createMutation.isPending || !newTodoText.trim()}
|
139
|
+
{{/if}}
|
140
|
+
>
|
141
|
+
{{#if (eq backend "convex")}}
|
142
|
+
Add
|
143
|
+
{{else}}
|
144
|
+
{createMutation.isPending ? (
|
145
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
146
|
+
) : (
|
147
|
+
"Add"
|
148
|
+
)}
|
149
|
+
{{/if}}
|
150
|
+
</Button>
|
151
|
+
</form>
|
152
|
+
|
153
|
+
{{#if (eq backend "convex")}}
|
154
|
+
{todos === undefined ? (
|
155
|
+
<div className="flex justify-center py-4">
|
156
|
+
<Loader2 className="h-6 w-6 animate-spin" />
|
157
|
+
</div>
|
158
|
+
) : todos.length === 0 ? (
|
159
|
+
<p className="py-4 text-center">No todos yet. Add one above!</p>
|
160
|
+
) : (
|
161
|
+
<ul className="space-y-2">
|
162
|
+
{todos.map((todo) => (
|
163
|
+
<li
|
164
|
+
key={todo._id}
|
165
|
+
className="flex items-center justify-between rounded-md border p-2"
|
166
|
+
>
|
167
|
+
<div className="flex items-center space-x-2">
|
168
|
+
<Checkbox
|
169
|
+
checked={todo.completed}
|
170
|
+
onCheckedChange={() =>
|
171
|
+
handleToggleTodo(todo._id, todo.completed)
|
172
|
+
}
|
173
|
+
id={`todo-${todo._id}`}
|
174
|
+
/>
|
175
|
+
<label
|
176
|
+
htmlFor={`todo-${todo._id}`}
|
177
|
+
className={`${todo.completed ? "line-through text-muted-foreground" : ""}`}
|
178
|
+
>
|
179
|
+
{todo.text}
|
180
|
+
</label>
|
181
|
+
</div>
|
182
|
+
<Button
|
183
|
+
variant="ghost"
|
184
|
+
size="icon"
|
185
|
+
onClick={() => handleDeleteTodo(todo._id)}
|
186
|
+
aria-label="Delete todo"
|
187
|
+
>
|
188
|
+
<Trash2 className="h-4 w-4" />
|
189
|
+
</Button>
|
190
|
+
</li>
|
191
|
+
))}
|
192
|
+
</ul>
|
193
|
+
)}
|
194
|
+
{{else}}
|
195
|
+
{todos.isLoading ? (
|
196
|
+
<div className="flex justify-center py-4">
|
197
|
+
<Loader2 className="h-6 w-6 animate-spin" />
|
198
|
+
</div>
|
199
|
+
) : todos.data?.length === 0 ? (
|
200
|
+
<p className="py-4 text-center">
|
201
|
+
No todos yet. Add one above!
|
202
|
+
</p>
|
203
|
+
) : (
|
204
|
+
<ul className="space-y-2">
|
205
|
+
{todos.data?.map((todo) => (
|
206
|
+
<li
|
207
|
+
key={todo.id}
|
208
|
+
className="flex items-center justify-between rounded-md border p-2"
|
209
|
+
>
|
210
|
+
<div className="flex items-center space-x-2">
|
211
|
+
<Checkbox
|
212
|
+
checked={todo.completed}
|
213
|
+
onCheckedChange={() =>
|
214
|
+
handleToggleTodo(todo.id, todo.completed)
|
215
|
+
}
|
216
|
+
id={`todo-${todo.id}`}
|
217
|
+
/>
|
218
|
+
<label
|
219
|
+
htmlFor={`todo-${todo.id}`}
|
220
|
+
className={`${todo.completed ? "line-through" : ""}`}
|
221
|
+
>
|
222
|
+
{todo.text}
|
223
|
+
</label>
|
224
|
+
</div>
|
225
|
+
<Button
|
226
|
+
variant="ghost"
|
227
|
+
size="icon"
|
228
|
+
onClick={() => handleDeleteTodo(todo.id)}
|
229
|
+
aria-label="Delete todo"
|
230
|
+
>
|
231
|
+
<Trash2 className="h-4 w-4" />
|
232
|
+
</Button>
|
233
|
+
</li>
|
234
|
+
))}
|
235
|
+
</ul>
|
236
|
+
)}
|
237
|
+
{{/if}}
|
238
|
+
</CardContent>
|
239
|
+
</Card>
|
240
|
+
</div>
|
241
|
+
);
|
242
|
+
}
|