kybernus 3.0.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/commands/ecommerce.d.ts +3 -0
- package/dist/cli/commands/ecommerce.d.ts.map +1 -0
- package/dist/cli/commands/ecommerce.js +164 -0
- package/dist/cli/commands/ecommerce.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/ecommerce/.env.example +10 -0
- package/templates/ecommerce/.github/workflows/ci.yml +102 -0
- package/templates/ecommerce/.github/workflows/deploy.yml +31 -0
- package/templates/ecommerce/.prettierrc +9 -0
- package/templates/ecommerce/Dockerfile +54 -0
- package/templates/ecommerce/README.md +295 -0
- package/templates/ecommerce/apps/api/.env.example +59 -0
- package/templates/ecommerce/apps/api/jest.config.ts +50 -0
- package/templates/ecommerce/apps/api/jest.integration.config.ts +45 -0
- package/templates/ecommerce/apps/api/package.json +59 -0
- package/templates/ecommerce/apps/api/prisma/migrations/20260306000137_init/migration.sql +184 -0
- package/templates/ecommerce/apps/api/prisma/migrations/migration_lock.toml +3 -0
- package/templates/ecommerce/apps/api/prisma/schema.prisma +181 -0
- package/templates/ecommerce/apps/api/prisma/seed.ts +159 -0
- package/templates/ecommerce/apps/api/src/__tests__/app.test.ts +39 -0
- package/templates/ecommerce/apps/api/src/__tests__/globalSetup.ts +34 -0
- package/templates/ecommerce/apps/api/src/__tests__/globalTeardown.ts +16 -0
- package/templates/ecommerce/apps/api/src/__tests__/setup.db.ts +18 -0
- package/templates/ecommerce/apps/api/src/__tests__/setup.env.ts +14 -0
- package/templates/ecommerce/apps/api/src/app.ts +133 -0
- package/templates/ecommerce/apps/api/src/application/admin/admin-user.service.ts +24 -0
- package/templates/ecommerce/apps/api/src/application/admin/dashboard.service.ts +102 -0
- package/templates/ecommerce/apps/api/src/application/auth/auth.service.ts +185 -0
- package/templates/ecommerce/apps/api/src/application/cart/cart.service.ts +151 -0
- package/templates/ecommerce/apps/api/src/application/cart/coupon.service.ts +51 -0
- package/templates/ecommerce/apps/api/src/application/catalog/catalog.service.ts +168 -0
- package/templates/ecommerce/apps/api/src/application/checkout/checkout.service.ts +114 -0
- package/templates/ecommerce/apps/api/src/application/orders/order.service.ts +93 -0
- package/templates/ecommerce/apps/api/src/application/ports/email.port.ts +3 -0
- package/templates/ecommerce/apps/api/src/application/ports/payment.port.ts +24 -0
- package/templates/ecommerce/apps/api/src/application/ports/shipping.port.ts +9 -0
- package/templates/ecommerce/apps/api/src/application/ports/storage.port.ts +3 -0
- package/templates/ecommerce/apps/api/src/application/ports/token-blacklist.port.ts +4 -0
- package/templates/ecommerce/apps/api/src/application/ports/token.port.ts +18 -0
- package/templates/ecommerce/apps/api/src/application/profile/profile.service.ts +76 -0
- package/templates/ecommerce/apps/api/src/domain/auth/user.entity.ts +109 -0
- package/templates/ecommerce/apps/api/src/domain/auth/user.repository.ts +11 -0
- package/templates/ecommerce/apps/api/src/domain/cart/cart.entity.ts +136 -0
- package/templates/ecommerce/apps/api/src/domain/cart/cart.repository.ts +8 -0
- package/templates/ecommerce/apps/api/src/domain/cart/coupon.entity.ts +58 -0
- package/templates/ecommerce/apps/api/src/domain/cart/coupon.repository.ts +10 -0
- package/templates/ecommerce/apps/api/src/domain/catalog/category.entity.ts +51 -0
- package/templates/ecommerce/apps/api/src/domain/catalog/category.repository.ts +10 -0
- package/templates/ecommerce/apps/api/src/domain/catalog/product.entity.ts +130 -0
- package/templates/ecommerce/apps/api/src/domain/catalog/product.repository.ts +28 -0
- package/templates/ecommerce/apps/api/src/domain/checkout/order.entity.ts +121 -0
- package/templates/ecommerce/apps/api/src/domain/checkout/order.repository.ts +11 -0
- package/templates/ecommerce/apps/api/src/domain/shared/AppError.ts +12 -0
- package/templates/ecommerce/apps/api/src/infrastructure/cache/redis.ts +16 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/admin.registry.ts +13 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/auth.registry.ts +34 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/cart.registry.ts +49 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/catalog.registry.ts +24 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/checkout.registry.ts +47 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/orders.registry.ts +6 -0
- package/templates/ecommerce/apps/api/src/infrastructure/config/registry/profile.registry.ts +4 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/cart.memory.repository.ts +33 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/category.memory.repository.ts +41 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/coupon.memory.repository.ts +55 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/order.memory.repository.ts +75 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/product.memory.repository.ts +100 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/in-memory/user.memory.repository.ts +54 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma/auth/user.prisma.repository.ts +83 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma/catalog/category.prisma.repository.ts +69 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma/catalog/product.prisma.repository.ts +185 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma/checkout/order.prisma.repository.ts +149 -0
- package/templates/ecommerce/apps/api/src/infrastructure/persistence/prisma-client.ts +17 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/email/email.registry.ts +18 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/email/ethereal.email.service.ts +38 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/email/noop.email.service.ts +12 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/email/smtp.email.service.ts +36 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/payment/stripe-webhook.handler.ts +83 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/payment/stripe.adapter.ts +39 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/shipping/mock.shipping.service.ts +17 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/storage/in-memory.storage.service.ts +11 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/storage/local-disk.storage.service.ts +27 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/storage/s3.storage.service.ts +52 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/storage/storage.registry.ts +19 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/token/redis.token.blacklist.ts +23 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/token/token.blacklist.ts +30 -0
- package/templates/ecommerce/apps/api/src/infrastructure/services/token/token.service.ts +136 -0
- package/templates/ecommerce/apps/api/src/modules/admin/__tests__/admin.routes.integration.test.ts +250 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.controller.ts +116 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.routes.ts +21 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/admin/admin.user.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/auth.logout.redis.test.ts +104 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/auth.routes.integration.test.ts +211 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/auth.service.unit.test.ts +260 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/email.service.unit.test.ts +94 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/token.blacklist.redis.test.ts +65 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/user.entity.unit.test.ts +79 -0
- package/templates/ecommerce/apps/api/src/modules/auth/__tests__/user.prisma.repository.test.ts +138 -0
- package/templates/ecommerce/apps/api/src/modules/auth/auth.controller.ts +148 -0
- package/templates/ecommerce/apps/api/src/modules/auth/auth.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/auth.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/modules/auth/auth.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/redis.token.blacklist.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/token.blacklist.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/auth/token.service.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/auth/user.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/user.prisma.repository.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/auth/user.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/cart/__tests__/cart.entity.unit.test.ts +144 -0
- package/templates/ecommerce/apps/api/src/modules/cart/__tests__/cart.routes.integration.test.ts +242 -0
- package/templates/ecommerce/apps/api/src/modules/cart/__tests__/cart.service.unit.test.ts +151 -0
- package/templates/ecommerce/apps/api/src/modules/cart/__tests__/coupon.admin.integration.test.ts +136 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.controller.ts +94 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/modules/cart/cart.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/coupon.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/coupon.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/cart/coupon.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/cart/shipping.service.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/__tests__/catalog.routes.integration.test.ts +275 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/__tests__/catalog.service.unit.test.ts +223 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/__tests__/product.image.integration.test.ts +130 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/__tests__/product.prisma.repository.test.ts +174 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/catalog.controller.ts +176 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/catalog.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/catalog.routes.ts +38 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/catalog.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/category.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/category.prisma.repository.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/category.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/product.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/product.prisma.repository.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/catalog/product.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/__tests__/checkout.routes.integration.test.ts +163 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/__tests__/checkout.service.unit.test.ts +191 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/__tests__/order.prisma.repository.test.ts +150 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/checkout.controller.ts +59 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/checkout.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/checkout.routes.ts +18 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/checkout.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/order.entity.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/order.prisma.repository.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/order.repository.ts +2 -0
- package/templates/ecommerce/apps/api/src/modules/checkout/tax.service.ts +9 -0
- package/templates/ecommerce/apps/api/src/modules/orders/__tests__/order.entity.unit.test.ts +68 -0
- package/templates/ecommerce/apps/api/src/modules/orders/__tests__/order.routes.integration.test.ts +254 -0
- package/templates/ecommerce/apps/api/src/modules/orders/__tests__/order.service.email.unit.test.ts +142 -0
- package/templates/ecommerce/apps/api/src/modules/orders/order.controller.ts +96 -0
- package/templates/ecommerce/apps/api/src/modules/orders/order.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/orders/order.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/modules/orders/order.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/payment/__tests__/stripe-webhook.unit.test.ts +330 -0
- package/templates/ecommerce/apps/api/src/modules/payment/__tests__/stripe.adapter.unit.test.ts +84 -0
- package/templates/ecommerce/apps/api/src/modules/payment/adapters/stripe.adapter.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/payment/payment.port.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/payment/stripe-webhook.handler.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/profile/__tests__/profile.routes.integration.test.ts +180 -0
- package/templates/ecommerce/apps/api/src/modules/profile/__tests__/profile.service.unit.test.ts +187 -0
- package/templates/ecommerce/apps/api/src/modules/profile/profile.controller.ts +92 -0
- package/templates/ecommerce/apps/api/src/modules/profile/profile.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/modules/profile/profile.routes.ts +14 -0
- package/templates/ecommerce/apps/api/src/modules/profile/profile.service.ts +1 -0
- package/templates/ecommerce/apps/api/src/presentation/middlewares/authenticate.ts +37 -0
- package/templates/ecommerce/apps/api/src/presentation/middlewares/authorize.ts +23 -0
- package/templates/ecommerce/apps/api/src/presentation/middlewares/errorHandler.ts +48 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/admin/admin.controller.ts +116 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/admin/admin.routes.ts +21 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/auth/auth.controller.ts +147 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/auth/auth.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/cart/cart.controller.ts +94 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/cart/cart.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/catalog/catalog.controller.ts +176 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/catalog/catalog.routes.ts +38 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/checkout/checkout.controller.ts +59 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/checkout/checkout.routes.ts +18 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/orders/order.controller.ts +96 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/orders/order.routes.ts +17 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/profile/profile.controller.ts +92 -0
- package/templates/ecommerce/apps/api/src/presentation/modules/profile/profile.routes.ts +14 -0
- package/templates/ecommerce/apps/api/src/presentation/validators/uuidParam.ts +20 -0
- package/templates/ecommerce/apps/api/src/server.ts +47 -0
- package/templates/ecommerce/apps/api/src/shared/__tests__/uuid.validation.test.ts +111 -0
- package/templates/ecommerce/apps/api/src/shared/errors/AppError.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/EtherealEmailService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/IEmailService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/NoopEmailService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/SmtpEmailService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/__tests__/ethereal.email.integration.test.ts +32 -0
- package/templates/ecommerce/apps/api/src/shared/infra/email/email.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/prisma.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/redis.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/IStorageService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/InMemoryStorageService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/LocalDiskStorageService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/S3StorageService.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/__tests__/s3.storage.unit.test.ts +73 -0
- package/templates/ecommerce/apps/api/src/shared/infra/storage/storage.registry.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/middlewares/authenticate.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/middlewares/authorize.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/middlewares/errorHandler.ts +1 -0
- package/templates/ecommerce/apps/api/src/shared/validators/uuidParam.ts +1 -0
- package/templates/ecommerce/apps/api/tsconfig.json +15 -0
- package/templates/ecommerce/apps/web/.env.example +8 -0
- package/templates/ecommerce/apps/web/index.html +19 -0
- package/templates/ecommerce/apps/web/jest.config.ts +45 -0
- package/templates/ecommerce/apps/web/package.json +38 -0
- package/templates/ecommerce/apps/web/src/App.tsx +133 -0
- package/templates/ecommerce/apps/web/src/__mocks__/fileMock.ts +1 -0
- package/templates/ecommerce/apps/web/src/__mocks__/styleMock.ts +1 -0
- package/templates/ecommerce/apps/web/src/index.css +159 -0
- package/templates/ecommerce/apps/web/src/main.tsx +13 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/CouponsAdminPage.test.tsx +134 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/DashboardPage.test.tsx +65 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/OrdersAdminPage.test.tsx +79 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/ProductsAdminPage.test.tsx +84 -0
- package/templates/ecommerce/apps/web/src/modules/admin/__tests__/UsersAdminPage.test.tsx +85 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/CouponsAdminPage.tsx +179 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/DashboardPage.tsx +58 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/OrdersAdminPage.tsx +178 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/ProductsAdminPage.tsx +444 -0
- package/templates/ecommerce/apps/web/src/modules/admin/pages/UsersAdminPage.tsx +87 -0
- package/templates/ecommerce/apps/web/src/modules/auth/LoginForm.tsx +91 -0
- package/templates/ecommerce/apps/web/src/modules/auth/RegisterForm.tsx +109 -0
- package/templates/ecommerce/apps/web/src/modules/auth/__tests__/ForgotPasswordPage.test.tsx +42 -0
- package/templates/ecommerce/apps/web/src/modules/auth/__tests__/LoginForm.test.tsx +76 -0
- package/templates/ecommerce/apps/web/src/modules/auth/__tests__/RegisterForm.test.tsx +62 -0
- package/templates/ecommerce/apps/web/src/modules/auth/__tests__/ResetPasswordPage.test.tsx +66 -0
- package/templates/ecommerce/apps/web/src/modules/auth/pages/ForgotPasswordPage.tsx +100 -0
- package/templates/ecommerce/apps/web/src/modules/auth/pages/LoginPage.tsx +39 -0
- package/templates/ecommerce/apps/web/src/modules/auth/pages/RegisterPage.tsx +39 -0
- package/templates/ecommerce/apps/web/src/modules/auth/pages/ResetPasswordPage.tsx +110 -0
- package/templates/ecommerce/apps/web/src/modules/auth/useAuthStore.ts +141 -0
- package/templates/ecommerce/apps/web/src/modules/cart/__tests__/CartPage.test.tsx +111 -0
- package/templates/ecommerce/apps/web/src/modules/cart/pages/CartPage.tsx +313 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/__tests__/ProductCard.test.tsx +59 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/__tests__/ProductFilters.test.tsx +56 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/components/ProductCard.tsx +78 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/components/ProductFilters.tsx +104 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/pages/ProductDetailPage.tsx +179 -0
- package/templates/ecommerce/apps/web/src/modules/catalog/pages/ProductListPage.tsx +100 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/__tests__/CheckoutPage.test.tsx +159 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/__tests__/StripePaymentForm.test.tsx +79 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/components/StripePaymentForm.tsx +55 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/hooks/useCheckout.ts +56 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/pages/CheckoutPage.tsx +344 -0
- package/templates/ecommerce/apps/web/src/modules/checkout/pages/CheckoutSuccessPage.tsx +12 -0
- package/templates/ecommerce/apps/web/src/modules/legal/pages/PrivacyPolicyPage.tsx +207 -0
- package/templates/ecommerce/apps/web/src/modules/legal/pages/TermsOfServicePage.tsx +175 -0
- package/templates/ecommerce/apps/web/src/modules/orders/__tests__/OrderDetailPage.test.tsx +75 -0
- package/templates/ecommerce/apps/web/src/modules/orders/__tests__/OrderHistoryPage.test.tsx +87 -0
- package/templates/ecommerce/apps/web/src/modules/orders/pages/OrderDetailPage.tsx +73 -0
- package/templates/ecommerce/apps/web/src/modules/orders/pages/OrderHistoryPage.tsx +97 -0
- package/templates/ecommerce/apps/web/src/modules/profile/__tests__/ProfilePage.test.tsx +150 -0
- package/templates/ecommerce/apps/web/src/modules/profile/pages/ProfilePage.tsx +275 -0
- package/templates/ecommerce/apps/web/src/setupTests.ts +10 -0
- package/templates/ecommerce/apps/web/src/shared/components/CookieConsent.tsx +108 -0
- package/templates/ecommerce/apps/web/src/shared/components/ErrorBoundary.tsx +112 -0
- package/templates/ecommerce/apps/web/src/shared/components/Layout.tsx +143 -0
- package/templates/ecommerce/apps/web/src/shared/components/ProtectedRoute.tsx +21 -0
- package/templates/ecommerce/apps/web/src/shared/config/siteConfig.ts +57 -0
- package/templates/ecommerce/apps/web/src/shared/hooks/usePageTitle.ts +16 -0
- package/templates/ecommerce/apps/web/src/shared/lib/apiFetch.ts +16 -0
- package/templates/ecommerce/apps/web/src/shared/pages/NotFoundPage.tsx +42 -0
- package/templates/ecommerce/apps/web/src/shared/theme/ThemeProvider.tsx +45 -0
- package/templates/ecommerce/apps/web/src/shared/theme/__tests__/ThemeProvider.test.tsx +78 -0
- package/templates/ecommerce/apps/web/src/shared/theme/createTheme.ts +58 -0
- package/templates/ecommerce/apps/web/src/shared/theme/tokens.ts +81 -0
- package/templates/ecommerce/apps/web/src/vite-env.d.ts +1 -0
- package/templates/ecommerce/apps/web/tsconfig.jest.json +12 -0
- package/templates/ecommerce/apps/web/tsconfig.json +25 -0
- package/templates/ecommerce/apps/web/tsconfig.node.json +11 -0
- package/templates/ecommerce/apps/web/vite.config.ts +30 -0
- package/templates/ecommerce/docker-compose.yml +85 -0
- package/templates/ecommerce/package-lock.json +11255 -0
- package/templates/ecommerce/package.json +27 -0
- package/templates/ecommerce/packages/shared-types/package.json +13 -0
- package/templates/ecommerce/packages/shared-types/src/index.ts +3 -0
- package/templates/ecommerce/packages/shared-types/src/theme.ts +44 -0
- package/templates/ecommerce/packages/shared-types/tsconfig.json +11 -0
- package/templates/ecommerce/scripts/customize.sh +201 -0
- package/templates/ecommerce/tsconfig.json +14 -0
- package/templates/java-spring/clean/.gitignore.hbs +72 -0
- package/templates/java-spring/clean/docker-compose.yml.hbs +6 -3
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/application/usecase/PaymentUseCase.java.hbs +21 -17
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/persistence/entity/UserEntity.java.hbs +52 -0
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/persistence/repository/JpaUserRepository.java.hbs +12 -0
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/security/JwtAuthenticationFilter.java.hbs +64 -0
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/security/SecurityConfig.java.hbs +36 -0
- package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/stripe/StripeGateway.java.hbs +63 -0
- package/templates/java-spring/clean/src/main/resources/application.properties.hbs +6 -7
- package/templates/java-spring/hexagonal/.gitignore.hbs +72 -0
- package/templates/java-spring/hexagonal/docker-compose.yml.hbs +6 -3
- package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/adapters/outbound/security/JwtFilter.java.hbs +71 -0
- package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/adapters/outbound/security/SecurityConfig.java.hbs +35 -0
- package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/core/service/PaymentService.java.hbs +3 -3
- package/templates/java-spring/hexagonal/src/main/resources/application.properties.hbs +4 -4
- package/templates/java-spring/mvc/.gitignore.hbs +72 -0
- package/templates/java-spring/mvc/docker-compose.yml.hbs +6 -3
- package/templates/java-spring/mvc/src/main/java/{{packagePath}}/config/SecurityConfig.java.hbs +13 -12
- package/templates/java-spring/mvc/src/main/java/{{packagePath}}/controller/AuthController.java.hbs +9 -8
- package/templates/java-spring/mvc/src/main/java/{{packagePath}}/controller/PaymentsController.java.hbs +5 -6
- package/templates/java-spring/mvc/src/main/java/{{packagePath}}/service/StripeService.java.hbs +3 -3
- package/templates/java-spring/mvc/src/main/resources/application.yml.hbs +29 -26
- package/templates/nestjs/clean/.gitignore.hbs +42 -0
- package/templates/nestjs/clean/Dockerfile.hbs +6 -3
- package/templates/nestjs/clean/docker-compose.yml.hbs +1 -11
- package/templates/nestjs/clean/src/app.module.ts.hbs +2 -1
- package/templates/nestjs/clean/src/application/payment.service.ts.hbs +72 -72
- package/templates/nestjs/clean/src/domain/entities/user.entity.ts.hbs +2 -2
- package/templates/nestjs/clean/src/domain/repositories/user.repository.ts.hbs +2 -2
- package/templates/nestjs/clean/src/infrastructure/database/repositories/prisma.user.repository.ts.hbs +18 -18
- package/templates/nestjs/clean/src/infrastructure/http/health.controller.ts.hbs +9 -0
- package/templates/nestjs/clean/src/main.ts.hbs +1 -4
- package/templates/nestjs/clean/src/payment.module.ts.hbs +12 -12
- package/templates/nestjs/hexagonal/.gitignore.hbs +42 -0
- package/templates/nestjs/hexagonal/Dockerfile.hbs +6 -3
- package/templates/nestjs/hexagonal/docker-compose.yml.hbs +1 -11
- package/templates/nestjs/hexagonal/src/adapters/inbound/health.controller.ts.hbs +9 -0
- package/templates/nestjs/hexagonal/src/app.module.ts.hbs +2 -1
- package/templates/nestjs/hexagonal/src/core/domain/user.entity.ts.hbs +6 -6
- package/templates/nestjs/hexagonal/src/core/ports/ports.ts.hbs +4 -4
- package/templates/nestjs/hexagonal/src/main.ts.hbs +1 -4
- package/templates/nestjs/mvc/.gitignore.hbs +42 -0
- package/templates/nestjs/mvc/Dockerfile.hbs +6 -3
- package/templates/nestjs/mvc/docker-compose.yml.hbs +1 -11
- package/templates/nestjs/mvc/src/auth/auth.controller.ts.hbs +11 -1
- package/templates/nestjs/mvc/src/auth/auth.service.ts.hbs +3 -1
- package/templates/nestjs/mvc/src/controllers/health.controller.ts.hbs +6 -6
- package/templates/nestjs/mvc/src/main.ts.hbs +1 -4
- package/templates/nestjs/mvc/src/models/create-item.dto.ts.hbs +5 -2
- package/templates/nestjs/mvc/src/prisma/prisma.service.ts.hbs +1 -0
- package/templates/nextjs/mvc/.gitignore.hbs +42 -0
- package/templates/nextjs/mvc/Dockerfile.hbs +23 -8
- package/templates/nextjs/mvc/docker-compose.yml.hbs +1 -1
- package/templates/nodejs-express/clean/.gitignore.hbs +42 -0
- package/templates/nodejs-express/clean/Dockerfile.hbs +6 -1
- package/templates/nodejs-express/clean/docker-compose.yml.hbs +2 -2
- package/templates/nodejs-express/clean/package.json.hbs +69 -69
- package/templates/nodejs-express/clean/src/config.ts.hbs +11 -0
- package/templates/nodejs-express/clean/src/domain/entities/User.ts.hbs +46 -8
- package/templates/nodejs-express/hexagonal/.gitignore.hbs +42 -0
- package/templates/nodejs-express/hexagonal/Dockerfile.hbs +1 -1
- package/templates/nodejs-express/hexagonal/docker-compose.yml.hbs +2 -2
- package/templates/nodejs-express/hexagonal/package.json.hbs +69 -69
- package/templates/nodejs-express/hexagonal/src/adapters/inbound/http/PaymentController.ts.hbs +21 -38
- package/templates/nodejs-express/hexagonal/src/adapters/outbound/persistence/prisma.ts.hbs +2 -0
- package/templates/nodejs-express/hexagonal/src/config.ts.hbs +9 -0
- package/templates/nodejs-express/hexagonal/src/core/AuthService.ts.hbs +5 -5
- package/templates/nodejs-express/hexagonal/src/core/PaymentService.ts.hbs +7 -22
- package/templates/nodejs-express/hexagonal/src/core/domain/entities/User.ts.hbs +24 -4
- package/templates/nodejs-express/mvc/.gitignore.hbs +42 -0
- package/templates/nodejs-express/mvc/package.json.hbs +67 -67
- package/templates/python-fastapi/clean/.gitignore.hbs +76 -0
- package/templates/python-fastapi/clean/app/application/services/payment_service.py.hbs +3 -3
- package/templates/python-fastapi/clean/app/config.py.hbs +6 -7
- package/templates/python-fastapi/clean/app/domain/usecases/login_user.py.hbs +15 -0
- package/templates/python-fastapi/clean/app/infrastructure/http/auth_controller.py.hbs +40 -6
- package/templates/python-fastapi/clean/app/infrastructure/http/payment_controller.py.hbs +5 -4
- package/templates/python-fastapi/clean/app/infrastructure/security/jwt.py.hbs +23 -0
- package/templates/python-fastapi/clean/app/main.py.hbs +3 -0
- package/templates/python-fastapi/clean/docker-compose.yml.hbs +5 -12
- package/templates/python-fastapi/clean/requirements.txt.hbs +3 -0
- package/templates/python-fastapi/hexagonal/.gitignore.hbs +76 -0
- package/templates/python-fastapi/hexagonal/app/adapters/inbound/http_adapter.py.hbs +6 -9
- package/templates/python-fastapi/hexagonal/app/adapters/inbound/payment_http_adapter.py.hbs +4 -3
- package/templates/python-fastapi/hexagonal/app/adapters/outbound/stripe_adapter.py.hbs +30 -19
- package/templates/python-fastapi/hexagonal/app/config.py.hbs +14 -4
- package/templates/python-fastapi/hexagonal/app/core/domain/user.py.hbs +3 -1
- package/templates/python-fastapi/hexagonal/app/core/payment_service.py.hbs +28 -18
- package/templates/python-fastapi/hexagonal/app/core/ports/__init__.py.hbs +3 -0
- package/templates/python-fastapi/hexagonal/app/core/ports/user_repository.py.hbs +15 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/database/session.py.hbs +7 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/database/user_repository.py.hbs +53 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/security/__init__.py.hbs +0 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/security/adapters.py.hbs +23 -0
- package/templates/python-fastapi/hexagonal/app/infrastructure/security/jwt.py.hbs +23 -0
- package/templates/python-fastapi/hexagonal/docker-compose.yml.hbs +5 -12
- package/templates/python-fastapi/hexagonal/requirements.txt.hbs +4 -0
- package/templates/python-fastapi/mvc/.gitignore.hbs +76 -0
- package/templates/python-fastapi/mvc/app/controllers/payments.py.hbs +3 -17
- package/templates/python-fastapi/mvc/app/middleware/security.py.hbs +24 -3
- package/templates/python-fastapi/mvc/app/schemas/item.py.hbs +3 -1
- package/templates/python-fastapi/mvc/docker-compose.yml.hbs +5 -12
- package/templates/python-fastapi/mvc/requirements.txt.hbs +3 -1
- package/templates/nodejs-express/hexagonal/src/adapters/outbound/persistence/prisma.ts +0 -5
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
|
3
|
+
import { ThemeProvider } from './shared/theme/ThemeProvider';
|
|
4
|
+
import { Layout } from './shared/components/Layout';
|
|
5
|
+
import { ProtectedRoute } from './shared/components/ProtectedRoute';
|
|
6
|
+
import { ErrorBoundary } from './shared/components/ErrorBoundary';
|
|
7
|
+
import { NotFoundPage } from './shared/pages/NotFoundPage';
|
|
8
|
+
import { useAuthStore } from './modules/auth/useAuthStore';
|
|
9
|
+
|
|
10
|
+
// Auth
|
|
11
|
+
import { LoginPage } from './modules/auth/pages/LoginPage';
|
|
12
|
+
import { RegisterPage } from './modules/auth/pages/RegisterPage';
|
|
13
|
+
import { ForgotPasswordPage } from './modules/auth/pages/ForgotPasswordPage';
|
|
14
|
+
import { ResetPasswordPage } from './modules/auth/pages/ResetPasswordPage';
|
|
15
|
+
|
|
16
|
+
// Catalog
|
|
17
|
+
import { ProductListPage } from './modules/catalog/pages/ProductListPage';
|
|
18
|
+
import { ProductDetailPage } from './modules/catalog/pages/ProductDetailPage';
|
|
19
|
+
|
|
20
|
+
// Cart
|
|
21
|
+
import { CartPage } from './modules/cart/pages/CartPage';
|
|
22
|
+
|
|
23
|
+
// Checkout
|
|
24
|
+
import { CheckoutPage } from './modules/checkout/pages/CheckoutPage';
|
|
25
|
+
import { CheckoutSuccessPage } from './modules/checkout/pages/CheckoutSuccessPage';
|
|
26
|
+
|
|
27
|
+
// Profile
|
|
28
|
+
import { ProfilePage } from './modules/profile/pages/ProfilePage';
|
|
29
|
+
|
|
30
|
+
// Orders
|
|
31
|
+
import { OrderHistoryPage } from './modules/orders/pages/OrderHistoryPage';
|
|
32
|
+
import { OrderDetailPage } from './modules/orders/pages/OrderDetailPage';
|
|
33
|
+
|
|
34
|
+
// Admin
|
|
35
|
+
import { DashboardPage } from './modules/admin/pages/DashboardPage';
|
|
36
|
+
import { UsersAdminPage } from './modules/admin/pages/UsersAdminPage';
|
|
37
|
+
import { ProductsAdminPage } from './modules/admin/pages/ProductsAdminPage';
|
|
38
|
+
import { OrdersAdminPage } from './modules/admin/pages/OrdersAdminPage';
|
|
39
|
+
import { CouponsAdminPage } from './modules/admin/pages/CouponsAdminPage';
|
|
40
|
+
|
|
41
|
+
// Legal
|
|
42
|
+
import { TermsOfServicePage } from './modules/legal/pages/TermsOfServicePage';
|
|
43
|
+
import { PrivacyPolicyPage } from './modules/legal/pages/PrivacyPolicyPage';
|
|
44
|
+
|
|
45
|
+
function AppRoutes() {
|
|
46
|
+
const init = useAuthStore((s) => s.init);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
void init();
|
|
50
|
+
}, [init]);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<BrowserRouter>
|
|
54
|
+
<Routes>
|
|
55
|
+
<Route element={<Layout />}>
|
|
56
|
+
{/* Public */}
|
|
57
|
+
<Route index element={<ProductListPage />} />
|
|
58
|
+
<Route path="products/:slug" element={<ProductDetailPage />} />
|
|
59
|
+
<Route path="login" element={<LoginPage />} />
|
|
60
|
+
<Route path="register" element={<RegisterPage />} />
|
|
61
|
+
<Route path="forgot-password" element={<ForgotPasswordPage />} />
|
|
62
|
+
<Route path="reset-password" element={<ResetPasswordPage />} />
|
|
63
|
+
|
|
64
|
+
{/* Cart — accessible to all (authenticated or not) */}
|
|
65
|
+
<Route path="cart" element={<CartPage />} />
|
|
66
|
+
|
|
67
|
+
{/* Protected — any logged-in user */}
|
|
68
|
+
<Route
|
|
69
|
+
path="checkout"
|
|
70
|
+
element={<ProtectedRoute><CheckoutPage /></ProtectedRoute>}
|
|
71
|
+
/>
|
|
72
|
+
<Route
|
|
73
|
+
path="checkout/success"
|
|
74
|
+
element={<ProtectedRoute><CheckoutSuccessPage /></ProtectedRoute>}
|
|
75
|
+
/>
|
|
76
|
+
<Route
|
|
77
|
+
path="profile"
|
|
78
|
+
element={<ProtectedRoute><ProfilePage /></ProtectedRoute>}
|
|
79
|
+
/>
|
|
80
|
+
<Route
|
|
81
|
+
path="orders"
|
|
82
|
+
element={<ProtectedRoute><OrderHistoryPage /></ProtectedRoute>}
|
|
83
|
+
/>
|
|
84
|
+
<Route
|
|
85
|
+
path="orders/:id"
|
|
86
|
+
element={<ProtectedRoute><OrderDetailPage /></ProtectedRoute>}
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
{/* Protected — ADMIN only */}
|
|
90
|
+
<Route
|
|
91
|
+
path="admin"
|
|
92
|
+
element={<ProtectedRoute requiredRole="ADMIN"><DashboardPage /></ProtectedRoute>}
|
|
93
|
+
/>
|
|
94
|
+
<Route
|
|
95
|
+
path="admin/users"
|
|
96
|
+
element={<ProtectedRoute requiredRole="ADMIN"><UsersAdminPage /></ProtectedRoute>}
|
|
97
|
+
/>
|
|
98
|
+
<Route
|
|
99
|
+
path="admin/products"
|
|
100
|
+
element={<ProtectedRoute requiredRole="ADMIN"><ProductsAdminPage /></ProtectedRoute>}
|
|
101
|
+
/>
|
|
102
|
+
<Route
|
|
103
|
+
path="admin/orders"
|
|
104
|
+
element={<ProtectedRoute requiredRole="ADMIN"><OrdersAdminPage /></ProtectedRoute>}
|
|
105
|
+
/>
|
|
106
|
+
<Route
|
|
107
|
+
path="admin/coupons"
|
|
108
|
+
element={<ProtectedRoute requiredRole="ADMIN"><CouponsAdminPage /></ProtectedRoute>}
|
|
109
|
+
/>
|
|
110
|
+
|
|
111
|
+
{/* Legal — public */}
|
|
112
|
+
<Route path="terms" element={<TermsOfServicePage />} />
|
|
113
|
+
<Route path="privacy" element={<PrivacyPolicyPage />} />
|
|
114
|
+
</Route>
|
|
115
|
+
|
|
116
|
+
{/* Fallback */}
|
|
117
|
+
<Route path="*" element={<NotFoundPage />} />
|
|
118
|
+
</Routes>
|
|
119
|
+
</BrowserRouter>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function App() {
|
|
124
|
+
return (
|
|
125
|
+
<ThemeProvider>
|
|
126
|
+
<ErrorBoundary>
|
|
127
|
+
<AppRoutes />
|
|
128
|
+
</ErrorBoundary>
|
|
129
|
+
</ThemeProvider>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default App;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default 'test-file-stub';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/* ── Global Reset & Base Styles ─────────────────────────────────────────── */
|
|
2
|
+
*,
|
|
3
|
+
*::before,
|
|
4
|
+
*::after {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
html,
|
|
11
|
+
body,
|
|
12
|
+
#root {
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body {
|
|
17
|
+
background-color: #f9fafb;
|
|
18
|
+
color: #111827;
|
|
19
|
+
font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
|
20
|
+
font-size: 1rem;
|
|
21
|
+
line-height: 1.5;
|
|
22
|
+
-webkit-font-smoothing: antialiased;
|
|
23
|
+
-moz-osx-font-smoothing: grayscale;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* ── Typography ─────────────────────────────────────────────────────────── */
|
|
27
|
+
h1, h2, h3, h4, h5, h6 {
|
|
28
|
+
line-height: 1.25;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
a {
|
|
33
|
+
color: inherit;
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
img {
|
|
38
|
+
display: block;
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
button {
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
font-family: inherit;
|
|
45
|
+
font-size: inherit;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* ── Form Elements ───────────────────────────────────────────────────────── */
|
|
49
|
+
input,
|
|
50
|
+
textarea,
|
|
51
|
+
select {
|
|
52
|
+
font-family: inherit;
|
|
53
|
+
font-size: 0.9375rem;
|
|
54
|
+
line-height: 1.5;
|
|
55
|
+
display: block;
|
|
56
|
+
width: 100%;
|
|
57
|
+
padding: 0.5625rem 0.75rem;
|
|
58
|
+
border: 1.5px solid #d1d5db;
|
|
59
|
+
border-radius: 0.5rem;
|
|
60
|
+
background: #ffffff;
|
|
61
|
+
color: #111827;
|
|
62
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
63
|
+
outline: none;
|
|
64
|
+
-webkit-appearance: none;
|
|
65
|
+
appearance: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
input:focus,
|
|
69
|
+
textarea:focus,
|
|
70
|
+
select:focus {
|
|
71
|
+
border-color: #6366f1;
|
|
72
|
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
input::placeholder,
|
|
76
|
+
textarea::placeholder {
|
|
77
|
+
color: #9ca3af;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
select {
|
|
81
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
|
|
82
|
+
background-repeat: no-repeat;
|
|
83
|
+
background-position: right 0.65rem center;
|
|
84
|
+
padding-right: 2.25rem;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
label {
|
|
88
|
+
display: block;
|
|
89
|
+
font-size: 0.875rem;
|
|
90
|
+
font-weight: 500;
|
|
91
|
+
color: #374151;
|
|
92
|
+
margin-bottom: 0.375rem;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* ── Buttons ────────────────────────────────────────────────────────────── */
|
|
96
|
+
button[type="submit"] {
|
|
97
|
+
display: inline-flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
gap: 0.5rem;
|
|
101
|
+
width: 100%;
|
|
102
|
+
padding: 0.625rem 1.25rem;
|
|
103
|
+
background: #6366f1;
|
|
104
|
+
color: #ffffff;
|
|
105
|
+
border: none;
|
|
106
|
+
border-radius: 0.5rem;
|
|
107
|
+
font-weight: 600;
|
|
108
|
+
font-size: 0.9375rem;
|
|
109
|
+
transition: background 0.15s ease, opacity 0.15s ease;
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
button[type="submit"]:hover:not(:disabled) {
|
|
114
|
+
background: #4f46e5;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
button[type="submit"]:disabled {
|
|
118
|
+
opacity: 0.55;
|
|
119
|
+
cursor: not-allowed;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* ── Scrollbar (Webkit) ─────────────────────────────────────────────────── */
|
|
123
|
+
::-webkit-scrollbar {
|
|
124
|
+
width: 6px;
|
|
125
|
+
height: 6px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
::-webkit-scrollbar-track {
|
|
129
|
+
background: #f1f5f9;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
::-webkit-scrollbar-thumb {
|
|
133
|
+
background: #cbd5e1;
|
|
134
|
+
border-radius: 3px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
::-webkit-scrollbar-thumb:hover {
|
|
138
|
+
background: #94a3b8;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* ── Layout responsive classes ──────────────────────────────────────────── */
|
|
142
|
+
.site-nav {
|
|
143
|
+
padding: 0.875rem 2rem;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.site-main {
|
|
147
|
+
padding: 1.75rem 2rem;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@media (max-width: 640px) {
|
|
151
|
+
.site-nav {
|
|
152
|
+
padding: 0.625rem 1rem;
|
|
153
|
+
gap: 0.5rem;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.site-main {
|
|
157
|
+
padding: 1.25rem 1rem;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import './index.css';
|
|
4
|
+
import App from './App';
|
|
5
|
+
|
|
6
|
+
const root = document.getElementById('root');
|
|
7
|
+
if (!root) throw new Error('Root element not found');
|
|
8
|
+
|
|
9
|
+
createRoot(root).render(
|
|
10
|
+
<StrictMode>
|
|
11
|
+
<App />
|
|
12
|
+
</StrictMode>,
|
|
13
|
+
);
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import { CouponsAdminPage } from '../pages/CouponsAdminPage';
|
|
5
|
+
|
|
6
|
+
const mockFetch = jest.fn();
|
|
7
|
+
beforeAll(() => { global.fetch = mockFetch; });
|
|
8
|
+
beforeEach(() => mockFetch.mockClear());
|
|
9
|
+
|
|
10
|
+
function renderPage() {
|
|
11
|
+
return render(
|
|
12
|
+
<MemoryRouter>
|
|
13
|
+
<CouponsAdminPage />
|
|
14
|
+
</MemoryRouter>,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const coupons = [
|
|
19
|
+
{
|
|
20
|
+
id: 'coup-1',
|
|
21
|
+
code: 'PROMO10',
|
|
22
|
+
discountType: 'percent',
|
|
23
|
+
discountValue: 10,
|
|
24
|
+
minOrderValue: 0,
|
|
25
|
+
usageLimit: 100,
|
|
26
|
+
usageCount: 5,
|
|
27
|
+
expiresAt: null,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'coup-2',
|
|
31
|
+
code: 'FIXED20',
|
|
32
|
+
discountType: 'fixed',
|
|
33
|
+
discountValue: 20,
|
|
34
|
+
minOrderValue: 50,
|
|
35
|
+
usageLimit: null,
|
|
36
|
+
usageCount: 0,
|
|
37
|
+
expiresAt: null,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
describe('CouponsAdminPage', () => {
|
|
42
|
+
it('renderiza tabela com código, desconto e limite', async () => {
|
|
43
|
+
mockFetch.mockResolvedValueOnce({
|
|
44
|
+
ok: true,
|
|
45
|
+
json: async () => ({ items: coupons }),
|
|
46
|
+
} as Response);
|
|
47
|
+
|
|
48
|
+
renderPage();
|
|
49
|
+
|
|
50
|
+
await waitFor(() => {
|
|
51
|
+
expect(screen.getByText('PROMO10')).toBeInTheDocument();
|
|
52
|
+
expect(screen.getByText('FIXED20')).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(screen.getByText('10%')).toBeInTheDocument();
|
|
56
|
+
expect(screen.getByText('R$ 20,00')).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('formulário de criação chama POST /api/admin/coupons', async () => {
|
|
60
|
+
mockFetch
|
|
61
|
+
.mockResolvedValueOnce({
|
|
62
|
+
ok: true,
|
|
63
|
+
json: async () => ({ items: [] }),
|
|
64
|
+
} as Response)
|
|
65
|
+
.mockResolvedValueOnce({
|
|
66
|
+
ok: true,
|
|
67
|
+
json: async () => ({
|
|
68
|
+
id: 'coup-new',
|
|
69
|
+
code: 'NEWCOUPON',
|
|
70
|
+
discountType: 'percent',
|
|
71
|
+
discountValue: 5,
|
|
72
|
+
minOrderValue: 0,
|
|
73
|
+
usageLimit: null,
|
|
74
|
+
usageCount: 0,
|
|
75
|
+
expiresAt: null,
|
|
76
|
+
}),
|
|
77
|
+
} as Response)
|
|
78
|
+
.mockResolvedValueOnce({
|
|
79
|
+
ok: true,
|
|
80
|
+
json: async () => ({ items: [] }),
|
|
81
|
+
} as Response);
|
|
82
|
+
|
|
83
|
+
renderPage();
|
|
84
|
+
|
|
85
|
+
await waitFor(() => {
|
|
86
|
+
expect(screen.getByRole('button', { name: /criar|novo/i })).toBeInTheDocument();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
await userEvent.type(screen.getByLabelText(/código/i), 'NEWCOUPON');
|
|
90
|
+
await userEvent.type(screen.getByLabelText(/valor/i), '5');
|
|
91
|
+
await userEvent.click(screen.getByRole('button', { name: /criar|novo/i }));
|
|
92
|
+
|
|
93
|
+
await waitFor(() => {
|
|
94
|
+
const calls = mockFetch.mock.calls;
|
|
95
|
+
const postCall = calls.find(
|
|
96
|
+
(c) => typeof c[0] === 'string' && c[0].includes('/api/admin/coupons') && c[1]?.method === 'POST',
|
|
97
|
+
);
|
|
98
|
+
expect(postCall).toBeDefined();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('botão deletar chama DELETE /api/admin/coupons/:id', async () => {
|
|
103
|
+
mockFetch
|
|
104
|
+
.mockResolvedValueOnce({
|
|
105
|
+
ok: true,
|
|
106
|
+
json: async () => ({ items: [coupons[0]] }),
|
|
107
|
+
} as Response)
|
|
108
|
+
.mockResolvedValueOnce({
|
|
109
|
+
ok: true,
|
|
110
|
+
json: async () => ({}),
|
|
111
|
+
status: 204,
|
|
112
|
+
} as unknown as Response)
|
|
113
|
+
.mockResolvedValueOnce({
|
|
114
|
+
ok: true,
|
|
115
|
+
json: async () => ({ items: [] }),
|
|
116
|
+
} as Response);
|
|
117
|
+
|
|
118
|
+
renderPage();
|
|
119
|
+
|
|
120
|
+
await waitFor(() => {
|
|
121
|
+
expect(screen.getByText('PROMO10')).toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
await userEvent.click(screen.getByRole('button', { name: /excluir|remover|deletar/i }));
|
|
125
|
+
|
|
126
|
+
await waitFor(() => {
|
|
127
|
+
const calls = mockFetch.mock.calls;
|
|
128
|
+
const deleteCall = calls.find(
|
|
129
|
+
(c) => typeof c[0] === 'string' && c[0].includes('/api/admin/coupons/coup-1') && c[1]?.method === 'DELETE',
|
|
130
|
+
);
|
|
131
|
+
expect(deleteCall).toBeDefined();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
import { DashboardPage } from '../pages/DashboardPage';
|
|
4
|
+
|
|
5
|
+
const mockFetch = jest.fn();
|
|
6
|
+
beforeAll(() => { global.fetch = mockFetch; });
|
|
7
|
+
beforeEach(() => mockFetch.mockClear());
|
|
8
|
+
|
|
9
|
+
function renderPage() {
|
|
10
|
+
return render(
|
|
11
|
+
<MemoryRouter>
|
|
12
|
+
<DashboardPage />
|
|
13
|
+
</MemoryRouter>,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const baseStats = {
|
|
18
|
+
totalRevenue: 1250.5,
|
|
19
|
+
totalOrders: 25,
|
|
20
|
+
totalCustomers: 10,
|
|
21
|
+
avgOrderValue: 125.05,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe('DashboardPage', () => {
|
|
25
|
+
it('exibe estado de carregamento inicialmente', () => {
|
|
26
|
+
mockFetch.mockReturnValue(new Promise(() => {}));
|
|
27
|
+
renderPage();
|
|
28
|
+
expect(screen.getByText(/carregando/i)).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renderiza os KPIs: totalRevenue, totalOrders, totalCustomers, avgOrderValue', async () => {
|
|
32
|
+
mockFetch.mockResolvedValue({
|
|
33
|
+
ok: true,
|
|
34
|
+
json: async () => baseStats,
|
|
35
|
+
});
|
|
36
|
+
renderPage();
|
|
37
|
+
await waitFor(() =>
|
|
38
|
+
expect(screen.getByText('25')).toBeInTheDocument(),
|
|
39
|
+
);
|
|
40
|
+
expect(screen.getByText('10')).toBeInTheDocument();
|
|
41
|
+
// Revenue and avgOrderValue displayed as currency
|
|
42
|
+
expect(screen.getByText(/1\.250,50|1250,50|1250.50/)).toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('exibe títulos dos KPI cards', async () => {
|
|
46
|
+
mockFetch.mockResolvedValue({
|
|
47
|
+
ok: true,
|
|
48
|
+
json: async () => baseStats,
|
|
49
|
+
});
|
|
50
|
+
renderPage();
|
|
51
|
+
await waitFor(() =>
|
|
52
|
+
expect(screen.getByText(/receita/i)).toBeInTheDocument(),
|
|
53
|
+
);
|
|
54
|
+
expect(screen.getByText(/pedidos/i)).toBeInTheDocument();
|
|
55
|
+
expect(screen.getByText(/clientes/i)).toBeInTheDocument();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('exibe erro ao falhar requisição', async () => {
|
|
59
|
+
mockFetch.mockResolvedValue({ ok: false, status: 403 });
|
|
60
|
+
renderPage();
|
|
61
|
+
await waitFor(() =>
|
|
62
|
+
expect(screen.getByRole('alert')).toBeInTheDocument(),
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import { OrdersAdminPage } from '../pages/OrdersAdminPage';
|
|
5
|
+
|
|
6
|
+
const mockFetch = jest.fn();
|
|
7
|
+
beforeAll(() => { global.fetch = mockFetch; });
|
|
8
|
+
beforeEach(() => mockFetch.mockClear());
|
|
9
|
+
|
|
10
|
+
function renderPage() {
|
|
11
|
+
return render(
|
|
12
|
+
<MemoryRouter>
|
|
13
|
+
<OrdersAdminPage />
|
|
14
|
+
</MemoryRouter>,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const orders = [
|
|
19
|
+
{
|
|
20
|
+
id: 'ord-1',
|
|
21
|
+
userId: 'u1',
|
|
22
|
+
status: 'PAID',
|
|
23
|
+
total: 199.9,
|
|
24
|
+
trackingCode: null,
|
|
25
|
+
createdAt: new Date().toISOString(),
|
|
26
|
+
items: [],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'ord-2',
|
|
30
|
+
userId: 'u2',
|
|
31
|
+
status: 'SHIPPED',
|
|
32
|
+
total: 89.5,
|
|
33
|
+
trackingCode: 'BR123456789',
|
|
34
|
+
createdAt: new Date().toISOString(),
|
|
35
|
+
items: [],
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
describe('OrdersAdminPage', () => {
|
|
40
|
+
it('renderiza lista de pedidos com status badge', async () => {
|
|
41
|
+
mockFetch.mockResolvedValue({
|
|
42
|
+
ok: true,
|
|
43
|
+
json: async () => ({ items: orders, nextCursor: null }),
|
|
44
|
+
});
|
|
45
|
+
renderPage();
|
|
46
|
+
await waitFor(() => expect(screen.getByText('ord-1')).toBeInTheDocument());
|
|
47
|
+
expect(screen.getByText('ord-2')).toBeInTheDocument();
|
|
48
|
+
expect(screen.getAllByText('PAID').length).toBeGreaterThanOrEqual(1);
|
|
49
|
+
expect(screen.getAllByText('SHIPPED').length).toBeGreaterThanOrEqual(1);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('permite filtrar por status', async () => {
|
|
53
|
+
const user = userEvent.setup();
|
|
54
|
+
mockFetch.mockResolvedValue({
|
|
55
|
+
ok: true,
|
|
56
|
+
json: async () => ({ items: orders, nextCursor: null }),
|
|
57
|
+
});
|
|
58
|
+
renderPage();
|
|
59
|
+
await waitFor(() => expect(screen.getByText('ord-1')).toBeInTheDocument());
|
|
60
|
+
|
|
61
|
+
const select = screen.getByRole('combobox', { name: /filtrar|status/i });
|
|
62
|
+
expect(select).toBeInTheDocument();
|
|
63
|
+
await user.selectOptions(select, 'PAID');
|
|
64
|
+
expect(mockFetch).toHaveBeenCalledTimes(2);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('exibe select para atualizar status de um pedido', async () => {
|
|
68
|
+
mockFetch.mockResolvedValue({
|
|
69
|
+
ok: true,
|
|
70
|
+
json: async () => ({ items: orders, nextCursor: null }),
|
|
71
|
+
});
|
|
72
|
+
renderPage();
|
|
73
|
+
await waitFor(() => expect(screen.getByText('ord-1')).toBeInTheDocument());
|
|
74
|
+
|
|
75
|
+
// Should have selects for updating order status (one per order)
|
|
76
|
+
const selects = screen.getAllByRole('combobox');
|
|
77
|
+
expect(selects.length).toBeGreaterThanOrEqual(2); // filter + at least one row select
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import { ProductsAdminPage } from '../pages/ProductsAdminPage';
|
|
5
|
+
|
|
6
|
+
const mockFetch = jest.fn();
|
|
7
|
+
beforeAll(() => { global.fetch = mockFetch; });
|
|
8
|
+
beforeEach(() => mockFetch.mockClear());
|
|
9
|
+
|
|
10
|
+
function renderPage() {
|
|
11
|
+
return render(
|
|
12
|
+
<MemoryRouter>
|
|
13
|
+
<ProductsAdminPage />
|
|
14
|
+
</MemoryRouter>,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const products = [
|
|
19
|
+
{
|
|
20
|
+
id: 'p1',
|
|
21
|
+
name: 'Camiseta Básica',
|
|
22
|
+
slug: 'camiseta-basica',
|
|
23
|
+
price: 49.9,
|
|
24
|
+
images: [],
|
|
25
|
+
variants: [],
|
|
26
|
+
status: 'ACTIVE',
|
|
27
|
+
categoryId: 'cat1',
|
|
28
|
+
description: null,
|
|
29
|
+
createdAt: new Date().toISOString(),
|
|
30
|
+
updatedAt: new Date().toISOString(),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'p2',
|
|
34
|
+
name: 'Tênis Runner',
|
|
35
|
+
slug: 'tenis-runner',
|
|
36
|
+
price: 299.9,
|
|
37
|
+
images: ['http://example.com/img.jpg'],
|
|
38
|
+
variants: [],
|
|
39
|
+
status: 'ACTIVE',
|
|
40
|
+
categoryId: 'cat2',
|
|
41
|
+
description: null,
|
|
42
|
+
createdAt: new Date().toISOString(),
|
|
43
|
+
updatedAt: new Date().toISOString(),
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
describe('ProductsAdminPage', () => {
|
|
48
|
+
it('renderiza lista de produtos com nome e preço', async () => {
|
|
49
|
+
mockFetch.mockResolvedValue({
|
|
50
|
+
ok: true,
|
|
51
|
+
json: async () => ({ items: products, nextCursor: null }),
|
|
52
|
+
});
|
|
53
|
+
renderPage();
|
|
54
|
+
await waitFor(() => expect(screen.getByText('Camiseta Básica')).toBeInTheDocument());
|
|
55
|
+
expect(screen.getByText('Tênis Runner')).toBeInTheDocument();
|
|
56
|
+
expect(screen.getByText(/49[,.]9/)).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('exibe botão "Novo Produto"', async () => {
|
|
60
|
+
mockFetch.mockResolvedValue({
|
|
61
|
+
ok: true,
|
|
62
|
+
json: async () => ({ items: products, nextCursor: null }),
|
|
63
|
+
});
|
|
64
|
+
renderPage();
|
|
65
|
+
await waitFor(() => expect(screen.getByText(/novo produto/i)).toBeInTheDocument());
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('aceita upload de imagem via input file', async () => {
|
|
69
|
+
mockFetch.mockResolvedValue({
|
|
70
|
+
ok: true,
|
|
71
|
+
json: async () => ({ items: products, nextCursor: null }),
|
|
72
|
+
});
|
|
73
|
+
const user = userEvent.setup();
|
|
74
|
+
renderPage();
|
|
75
|
+
await waitFor(() => expect(screen.getByText('Camiseta Básica')).toBeInTheDocument());
|
|
76
|
+
|
|
77
|
+
const fileInput = document.querySelector('input[type="file"]') as HTMLInputElement;
|
|
78
|
+
expect(fileInput).not.toBeNull();
|
|
79
|
+
|
|
80
|
+
const file = new File(['img'], 'photo.jpg', { type: 'image/jpeg' });
|
|
81
|
+
await user.upload(fileInput, file);
|
|
82
|
+
expect(fileInput.files?.[0]).toBe(file);
|
|
83
|
+
});
|
|
84
|
+
});
|