create-snapify-app 0.0.0-stage → 1.1.1
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/LICENSE.md +24 -0
- package/README.md +55 -2
- package/bin/create-snapify-app.mjs +174 -0
- package/lib/args.mjs +59 -0
- package/lib/copy.mjs +44 -0
- package/lib/env.mjs +84 -0
- package/lib/prompt.mjs +63 -0
- package/package.json +35 -4
- package/template/.env.example +79 -0
- package/template/.github/workflows/ci.yml +23 -0
- package/template/.github/workflows/deploy.yml +26 -0
- package/template/.github/workflows/ping.yml +8 -0
- package/template/.github/workflows/release.yml +67 -0
- package/template/.snapify-install.json +5 -0
- package/template/CHANGELOG.md +28 -0
- package/template/LICENSE +14 -0
- package/template/README.md +287 -0
- package/template/administrator.html +23 -0
- package/template/apps/client/src/App.tsx +765 -0
- package/template/apps/client/src/auth.css +400 -0
- package/template/apps/client/src/lib/api.ts +22 -0
- package/template/apps/client/src/main.tsx +20 -0
- package/template/apps/community/src/App.tsx +592 -0
- package/template/apps/community/src/main.tsx +20 -0
- package/template/apps/community/src/styles.css +24 -0
- package/template/apps/developers/src/App.tsx +643 -0
- package/template/apps/developers/src/main.tsx +17 -0
- package/template/apps/developers/src/pages.tsx +1587 -0
- package/template/apps/developers/src/styles.css +98 -0
- package/template/apps/developers/src/ui.tsx +179 -0
- package/template/apps/landing/src/App.tsx +598 -0
- package/template/apps/landing/src/LegalPages.tsx +158 -0
- package/template/apps/landing/src/OrderPage.tsx +381 -0
- package/template/apps/landing/src/SeoPages.tsx +923 -0
- package/template/apps/landing/src/copy.ts +195 -0
- package/template/apps/landing/src/main.tsx +20 -0
- package/template/apps/landing/src/styles.css +803 -0
- package/template/apps/landing/src/types.ts +19 -0
- package/template/apps/marketplace/src/App.tsx +1229 -0
- package/template/apps/marketplace/src/developer/DeveloperApp.tsx +1266 -0
- package/template/apps/marketplace/src/main.tsx +20 -0
- package/template/apps/marketplace/src/styles.css +1001 -0
- package/template/apps/shared/AuthContext.tsx +65 -0
- package/template/apps/shared/Logo.tsx +33 -0
- package/template/apps/shared/api.ts +47 -0
- package/template/apps/shared/ui.tsx +128 -0
- package/template/apps/superadmin/src/App.tsx +1264 -0
- package/template/apps/superadmin/src/lib/api.ts +20 -0
- package/template/apps/superadmin/src/lib/hooks.ts +20 -0
- package/template/apps/superadmin/src/main.tsx +16 -0
- package/template/apps/superadmin/src/pages/ClientsPage.tsx +185 -0
- package/template/apps/superadmin/src/pages/InvoicesPage.tsx +157 -0
- package/template/apps/superadmin/src/pages/NewsletterPage.tsx +212 -0
- package/template/apps/superadmin/src/pages/OrdersPage.tsx +195 -0
- package/template/apps/superadmin/src/pages/PaymentsPage.tsx +150 -0
- package/template/apps/superadmin/src/pages/PayoutsPage.tsx +133 -0
- package/template/apps/superadmin/src/pages/PublishersPage.tsx +151 -0
- package/template/apps/superadmin/src/pages/SeoControlPage.tsx +692 -0
- package/template/apps/superadmin/src/pages/SettingsPage.tsx +199 -0
- package/template/apps/superadmin/src/pages/SystemPage.tsx +109 -0
- package/template/apps/superadmin/src/pages/TicketsPage.tsx +201 -0
- package/template/apps/superadmin/src/pages/UsersPage.tsx +167 -0
- package/template/client.html +21 -0
- package/template/community/hamdiayari/akhbar/README.md +23 -0
- package/template/community/hamdiayari/akhbar/screenshot.jpg +0 -0
- package/template/community/hamdiayari/akhbar/snapify.theme.json +76 -0
- package/template/community/hamdiayari/akhbar/src/Brand.tsx +26 -0
- package/template/community/hamdiayari/akhbar/src/Footer.tsx +182 -0
- package/template/community/hamdiayari/akhbar/src/Header.tsx +191 -0
- package/template/community/hamdiayari/akhbar/src/Layout.tsx +49 -0
- package/template/community/hamdiayari/akhbar/src/Social.tsx +33 -0
- package/template/community/hamdiayari/akhbar/src/Ticker.tsx +86 -0
- package/template/community/hamdiayari/akhbar/src/Views.tsx +285 -0
- package/template/community/hamdiayari/akhbar/src/blocks/CollectionBlocks.tsx +672 -0
- package/template/community/hamdiayari/akhbar/src/blocks/ContentBlocks.tsx +305 -0
- package/template/community/hamdiayari/akhbar/src/blocks/ConversionBlocks.tsx +569 -0
- package/template/community/hamdiayari/akhbar/src/blocks/HeaderBlocks.tsx +287 -0
- package/template/community/hamdiayari/akhbar/src/index.tsx +51 -0
- package/template/community/hamdiayari/akhbar/src/kit.tsx +357 -0
- package/template/community/hamdiayari/akhbar/src/site.ts +96 -0
- package/template/community/hamdiayari/akhbar/src/styles.css +566 -0
- package/template/community/hamdiayari/akhbar-actualites/README.md +28 -0
- package/template/community/hamdiayari/akhbar-actualites/screenshot.jpg +0 -0
- package/template/community/hamdiayari/akhbar-actualites/snapify.module.json +107 -0
- package/template/community/hamdiayari/akhbar-actualites/src/admin/AudiencePage.tsx +185 -0
- package/template/community/hamdiayari/akhbar-actualites/src/admin/index.tsx +11 -0
- package/template/community/hamdiayari/akhbar-actualites/src/public/Archive.tsx +142 -0
- package/template/community/hamdiayari/akhbar-actualites/src/public/cards.tsx +152 -0
- package/template/community/hamdiayari/akhbar-actualites/src/public/index.tsx +71 -0
- package/template/community/hamdiayari/akhbar-actualites/src/public/posts.ts +103 -0
- package/template/community/hamdiayari/akhbar-actualites/src/public/styles.css +568 -0
- package/template/community/hamdiayari/akhbar-actualites/src/public/widgets.tsx +226 -0
- package/template/community/hamdiayari/akhbar-actualites/src/server.ts +119 -0
- package/template/community/hamdiayari/akhbar-actualites/src/types.ts +25 -0
- package/template/community/hamdiayari/akhbar-urgent/README.md +36 -0
- package/template/community/hamdiayari/akhbar-urgent/screenshot.jpg +0 -0
- package/template/community/hamdiayari/akhbar-urgent/snapify.module.json +64 -0
- package/template/community/hamdiayari/akhbar-urgent/src/admin/FlashesPage.tsx +229 -0
- package/template/community/hamdiayari/akhbar-urgent/src/admin/index.tsx +11 -0
- package/template/community/hamdiayari/akhbar-urgent/src/public/Ticker.tsx +81 -0
- package/template/community/hamdiayari/akhbar-urgent/src/public/index.tsx +63 -0
- package/template/community/hamdiayari/akhbar-urgent/src/public/styles.css +142 -0
- package/template/community/hamdiayari/akhbar-urgent/src/server.ts +101 -0
- package/template/community/hamdiayari/akhbar-urgent/src/types.ts +35 -0
- package/template/community.html +21 -0
- package/template/developers.html +24 -0
- package/template/docker-compose.db.yml +24 -0
- package/template/docs/BACKOFFICE_SNAPIFY.md +130 -0
- package/template/docs/CI_CD.md +66 -0
- package/template/docs/MODULES.md +346 -0
- package/template/docs/PLATFORM_DEPLOY.md +54 -0
- package/template/docs/logo.svg +10 -0
- package/template/drizzle/0000_init.sql +147 -0
- package/template/drizzle/0001_page_project.sql +5 -0
- package/template/drizzle/0002_modules.sql +23 -0
- package/template/drizzle/0003_themes.sql +4 -0
- package/template/drizzle/0004_security.sql +82 -0
- package/template/drizzle/0005_module_records.sql +16 -0
- package/template/drizzle/0006_avatars.sql +4 -0
- package/template/drizzle/0007_platform.sql +264 -0
- package/template/drizzle/0008_mp_validation.sql +3 -0
- package/template/drizzle/0009_saas_ops.sql +77 -0
- package/template/drizzle/0010_cms_chrome.sql +13 -0
- package/template/drizzle/0011_client_portal.sql +26 -0
- package/template/drizzle/meta/0000_snapshot.json +998 -0
- package/template/drizzle/meta/0001_snapshot.json +1004 -0
- package/template/drizzle/meta/_journal.json +90 -0
- package/template/drizzle.config.ts +16 -0
- package/template/ecosystem.snapify.cjs +24 -0
- package/template/for.html +1 -0
- package/template/index.html +29 -0
- package/template/landing.html +37 -0
- package/template/marketplace/catalog.json +373 -0
- package/template/marketplace/gallery/hamdiayari.preveris/01-home.jpg +0 -0
- package/template/marketplace/gallery/hamdiayari.recaptcha/01-reglages.jpg +0 -0
- package/template/marketplace/gallery/hamdiayari.recaptcha/02-logo.jpg +0 -0
- package/template/marketplace/gallery/novalabs.ai-articles/01-generer.jpg +0 -0
- package/template/marketplace/gallery/novalabs.ai-articles/02-fournisseur-ia.jpg +0 -0
- package/template/marketplace/gallery/novalabs.calendar/01-agenda-site.jpg +0 -0
- package/template/marketplace/gallery/novalabs.calendar/02-evenements-admin.jpg +0 -0
- package/template/marketplace/gallery/novalabs.calendar/03-reglages.jpg +0 -0
- package/template/marketplace/screenshots/hamdiayari.preveris-1.0.6.jpg +0 -0
- package/template/marketplace/screenshots/hamdiayari.recaptcha-1.0.0.jpg +0 -0
- package/template/marketplace/screenshots/hamdiayari.wp-seo-migrator-1.1.1.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.ai-articles-1.0.1.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.ai-chat-1.0.1.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.calendar-1.0.1.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.cart-1.0.0.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.checkout-1.0.0.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.customers-1.1.0.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.dogga-1.0.0.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.mahdia-1.0.0.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.shop-1.0.0.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.sidibou-1.0.0.jpg +0 -0
- package/template/marketplace/screenshots/novalabs.whatsapp-1.0.1.jpg +0 -0
- package/template/marketplace.html +21 -0
- package/template/metadata.json +7 -0
- package/template/modules/ai-articles/screenshot.jpg +0 -0
- package/template/modules/ai-articles/snapify.module.json +74 -0
- package/template/modules/ai-articles/src/admin/ArticlesPage.tsx +162 -0
- package/template/modules/ai-articles/src/admin/GeneratePage.tsx +118 -0
- package/template/modules/ai-articles/src/admin/index.tsx +12 -0
- package/template/modules/ai-articles/src/public/index.tsx +119 -0
- package/template/modules/ai-articles/src/server.ts +287 -0
- package/template/modules/ai-articles/src/types.ts +30 -0
- package/template/modules/ai-chat/screenshot.jpg +0 -0
- package/template/modules/ai-chat/snapify.module.json +217 -0
- package/template/modules/ai-chat/src/public.tsx +198 -0
- package/template/modules/ai-chat/src/server.ts +142 -0
- package/template/modules/ai-theme-studio/README.md +15 -0
- package/template/modules/ai-theme-studio/screenshot.jpg +0 -0
- package/template/modules/ai-theme-studio/snapify.module.json +175 -0
- package/template/modules/ai-theme-studio/src/admin/HistoryPage.tsx +91 -0
- package/template/modules/ai-theme-studio/src/admin/StudioPage.tsx +414 -0
- package/template/modules/ai-theme-studio/src/admin/index.tsx +11 -0
- package/template/modules/ai-theme-studio/src/lib/images.ts +240 -0
- package/template/modules/ai-theme-studio/src/lib/llm.ts +123 -0
- package/template/modules/ai-theme-studio/src/lib/normalize.ts +714 -0
- package/template/modules/ai-theme-studio/src/lib/prompts.ts +198 -0
- package/template/modules/ai-theme-studio/src/server.ts +137 -0
- package/template/modules/ai-theme-studio/src/types.ts +112 -0
- package/template/modules/calendar/screenshot.jpg +0 -0
- package/template/modules/calendar/snapify.module.json +45 -0
- package/template/modules/calendar/src/admin/EventsPage.tsx +217 -0
- package/template/modules/calendar/src/admin/index.tsx +11 -0
- package/template/modules/calendar/src/public/index.tsx +231 -0
- package/template/modules/calendar/src/server.ts +143 -0
- package/template/modules/calendar/src/types.ts +25 -0
- package/template/modules/cart/screenshot.jpg +0 -0
- package/template/modules/cart/snapify.module.json +90 -0
- package/template/modules/cart/src/admin/index.tsx +265 -0
- package/template/modules/cart/src/public/CartPage.tsx +198 -0
- package/template/modules/cart/src/public/index.tsx +261 -0
- package/template/modules/cart/src/public/useQuote.ts +67 -0
- package/template/modules/cart/src/server.ts +148 -0
- package/template/modules/cart/src/types.ts +31 -0
- package/template/modules/checkout/screenshot.jpg +0 -0
- package/template/modules/checkout/snapify.module.json +264 -0
- package/template/modules/checkout/src/admin/OrderDetailPage.tsx +304 -0
- package/template/modules/checkout/src/admin/badges.tsx +28 -0
- package/template/modules/checkout/src/admin/index.tsx +236 -0
- package/template/modules/checkout/src/public/CheckoutPage.tsx +461 -0
- package/template/modules/checkout/src/public/OrderPages.tsx +153 -0
- package/template/modules/checkout/src/public/index.tsx +23 -0
- package/template/modules/checkout/src/server.ts +383 -0
- package/template/modules/checkout/src/types.ts +70 -0
- package/template/modules/customers/screenshot.jpg +0 -0
- package/template/modules/customers/snapify.module.json +115 -0
- package/template/modules/customers/src/admin/CustomerDetailPage.tsx +274 -0
- package/template/modules/customers/src/admin/index.tsx +194 -0
- package/template/modules/customers/src/public/AccountPages.tsx +470 -0
- package/template/modules/customers/src/public/AddressForm.tsx +115 -0
- package/template/modules/customers/src/public/AuthPages.tsx +349 -0
- package/template/modules/customers/src/public/Avatar.tsx +29 -0
- package/template/modules/customers/src/public/ProfileSection.tsx +291 -0
- package/template/modules/customers/src/public/index.tsx +137 -0
- package/template/modules/customers/src/public/session.ts +51 -0
- package/template/modules/customers/src/server.ts +421 -0
- package/template/modules/customers/src/types.ts +53 -0
- package/template/modules/recaptcha/logo.jpg +0 -0
- package/template/modules/recaptcha/screenshot.jpg +0 -0
- package/template/modules/recaptcha/snapify.module.json +99 -0
- package/template/modules/recaptcha/src/public/index.tsx +94 -0
- package/template/modules/recaptcha/src/server.ts +65 -0
- package/template/modules/recaptcha/src/types.ts +18 -0
- package/template/modules/shop/screenshot.jpg +0 -0
- package/template/modules/shop/snapify.module.json +340 -0
- package/template/modules/shop/src/admin/CategoriesPage.tsx +224 -0
- package/template/modules/shop/src/admin/ProductEditor.tsx +313 -0
- package/template/modules/shop/src/admin/ProductsPage.tsx +307 -0
- package/template/modules/shop/src/admin/index.tsx +14 -0
- package/template/modules/shop/src/public/Catalog.tsx +244 -0
- package/template/modules/shop/src/public/NotFound.tsx +22 -0
- package/template/modules/shop/src/public/ProductPage.tsx +195 -0
- package/template/modules/shop/src/public/index.tsx +134 -0
- package/template/modules/shop/src/public/useFetch.ts +26 -0
- package/template/modules/shop/src/server.ts +493 -0
- package/template/modules/shop/src/shared.ts +41 -0
- package/template/modules/shop/src/types.ts +60 -0
- package/template/modules/whatsapp/screenshot.jpg +0 -0
- package/template/modules/whatsapp/snapify.module.json +121 -0
- package/template/modules/whatsapp/src/public.tsx +119 -0
- package/template/modules/wp-seo-migrator/ARCHITECTURE.md +113 -0
- package/template/modules/wp-seo-migrator/README.md +21 -0
- package/template/modules/wp-seo-migrator/fixtures/aioseo-sample.csv +3 -0
- package/template/modules/wp-seo-migrator/fixtures/sample-exporter.json +39 -0
- package/template/modules/wp-seo-migrator/fixtures/sample-page.html +12 -0
- package/template/modules/wp-seo-migrator/fixtures/sample.htaccess +3 -0
- package/template/modules/wp-seo-migrator/screenshot.jpg +0 -0
- package/template/modules/wp-seo-migrator/snapify.module.json +87 -0
- package/template/modules/wp-seo-migrator/src/admin/HistoryPage.tsx +64 -0
- package/template/modules/wp-seo-migrator/src/admin/WizardPage.tsx +788 -0
- package/template/modules/wp-seo-migrator/src/admin/i18n.ts +156 -0
- package/template/modules/wp-seo-migrator/src/admin/index.tsx +11 -0
- package/template/modules/wp-seo-migrator/src/connectors/CUSTOM_CONNECTOR.md +31 -0
- package/template/modules/wp-seo-migrator/src/connectors/csvSeoFactory.ts +106 -0
- package/template/modules/wp-seo-migrator/src/connectors/exporter.ts +96 -0
- package/template/modules/wp-seo-migrator/src/connectors/gscCsv.ts +53 -0
- package/template/modules/wp-seo-migrator/src/connectors/htaccess.ts +65 -0
- package/template/modules/wp-seo-migrator/src/connectors/htmlCrawler.ts +90 -0
- package/template/modules/wp-seo-migrator/src/connectors/index.ts +113 -0
- package/template/modules/wp-seo-migrator/src/connectors/pluginCsv.ts +77 -0
- package/template/modules/wp-seo-migrator/src/connectors/rankMathCsv.ts +77 -0
- package/template/modules/wp-seo-migrator/src/connectors/redirection.ts +62 -0
- package/template/modules/wp-seo-migrator/src/connectors/sitemap.ts +44 -0
- package/template/modules/wp-seo-migrator/src/connectors/utils.ts +111 -0
- package/template/modules/wp-seo-migrator/src/connectors/wxr.ts +103 -0
- package/template/modules/wp-seo-migrator/src/connectors/yoastCsv.ts +56 -0
- package/template/modules/wp-seo-migrator/src/pipeline/analyze.ts +158 -0
- package/template/modules/wp-seo-migrator/src/pipeline/htmlParse.ts +58 -0
- package/template/modules/wp-seo-migrator/src/pipeline/remoteAuto.ts +328 -0
- package/template/modules/wp-seo-migrator/src/server.ts +492 -0
- package/template/modules/wp-seo-migrator/src/types.ts +151 -0
- package/template/modules/wp-seo-migrator/tests/connectors-extra.test.ts +39 -0
- package/template/modules/wp-seo-migrator/tests/merge.test.ts +25 -0
- package/template/package-lock.json +6016 -0
- package/template/package.json +74 -0
- package/template/public/images/photos/caravane-chameaux-desert.webp +0 -0
- package/template/public/images/photos/hammamet-medina-plage.jpg +0 -0
- package/template/public/images/photos/maison-campagne-collines.webp +0 -0
- package/template/public/images/photos/maisons-troglodytes-desert.jpg +0 -0
- package/template/public/images/photos/panorama-ville.jpg +0 -0
- package/template/public/images/photos/preveris-accessibilite-erp.jpg +0 -0
- package/template/public/images/photos/preveris-collectivites.jpg +0 -0
- package/template/public/images/photos/preveris-etudes-plans.jpg +0 -0
- package/template/public/images/photos/preveris-hero-erp.jpg +0 -0
- package/template/public/images/photos/preveris-ssi-incendie.jpg +0 -0
- package/template/public/images/photos/preveris-suivi-hotel.jpg +0 -0
- package/template/public/images/photos/ruelle-bleue-medina.jpg +0 -0
- package/template/public/images/photos/sidi-bou-said-port.webp +0 -0
- package/template/public/images/photos/terrasse-blanche-mer-voilier.jpg +0 -0
- package/template/public/landing/hero-ai-cms.jpg +0 -0
- package/template/public/landing/shot-dogga.jpg +0 -0
- package/template/public/landing/shot-mahdia.jpg +0 -0
- package/template/public/landing/shot-sidibou.jpg +0 -0
- package/template/public/llms.txt +35 -0
- package/template/public/logo.svg +10 -0
- package/template/scripts/app-pack.ts +155 -0
- package/template/scripts/app-publish.ts +123 -0
- package/template/scripts/apply-ecommerce-home.ts +196 -0
- package/template/scripts/auto-deploy-poll.sh +13 -0
- package/template/scripts/db-backup.sh +16 -0
- package/template/scripts/db-restore.sh +11 -0
- package/template/scripts/deploy.sh +34 -0
- package/template/scripts/github-webhook-deploy.sh +7 -0
- package/template/scripts/install-new-modules.ts +96 -0
- package/template/scripts/refresh-demo-baseline.ts +9 -0
- package/template/scripts/reinstall-marketplace-packs.ts +51 -0
- package/template/scripts/restore-classic-home.ts +13 -0
- package/template/scripts/sdk-pack.ts +289 -0
- package/template/scripts/sdk-publish.ts +75 -0
- package/template/scripts/seed-demo-products.ts +120 -0
- package/template/scripts/seed-theme-content-packs.ts +42 -0
- package/template/scripts/snapify-module.ts +207 -0
- package/template/scripts/test-theme-switch.ts +24 -0
- package/template/sdk/admin.css +18 -0
- package/template/sdk/admin.ts +95 -0
- package/template/sdk/build.ts +249 -0
- package/template/sdk/commerce.ts +512 -0
- package/template/sdk/content.ts +76 -0
- package/template/sdk/icons.ts +101 -0
- package/template/sdk/image.ts +60 -0
- package/template/sdk/index.ts +500 -0
- package/template/sdk/package.ts +298 -0
- package/template/sdk/recaptcha.tsx +122 -0
- package/template/sdk/settings.ts +84 -0
- package/template/sdk/theme.css +29 -0
- package/template/sdk/theme.ts +100 -0
- package/template/sdk/ui/commerce.tsx +385 -0
- package/template/sdk/ui/orders.tsx +136 -0
- package/template/sdk-kit/CHANGELOG.md +17 -0
- package/template/sdk-kit/LICENSE.md +47 -0
- package/template/sdk-kit/README.md +81 -0
- package/template/sdk-kit/cli.ts +339 -0
- package/template/sdk-kit/create-snapify/README.md +28 -0
- package/template/sdk-kit/create-snapify/create-snapify.mjs +11 -0
- package/template/sdk-kit/create-snapify/package.template.json +16 -0
- package/template/sdk-kit/package.template.json +95 -0
- package/template/sdk-kit/templates/common/README.md.tpl +27 -0
- package/template/sdk-kit/templates/common/_gitignore +3 -0
- package/template/sdk-kit/templates/common/package.json.tpl +19 -0
- package/template/sdk-kit/templates/common/src/snapify-env.d.ts +2 -0
- package/template/sdk-kit/templates/common/tsconfig.json +15 -0
- package/template/sdk-kit/templates/module/snapify.module.json.tpl +33 -0
- package/template/sdk-kit/templates/module/src/admin.tsx +53 -0
- package/template/sdk-kit/templates/module/src/public.tsx +49 -0
- package/template/sdk-kit/templates/module/src/server.ts +30 -0
- package/template/sdk-kit/templates/module/src/types.ts +19 -0
- package/template/sdk-kit/templates/theme/snapify.theme.json.tpl +22 -0
- package/template/sdk-kit/templates/theme/src/Footer.tsx +40 -0
- package/template/sdk-kit/templates/theme/src/Header.tsx +47 -0
- package/template/sdk-kit/templates/theme/src/Views.tsx +36 -0
- package/template/sdk-kit/templates/theme/src/blocks.tsx +93 -0
- package/template/sdk-kit/templates/theme/src/index.tsx +30 -0
- package/template/sdk-kit/templates/theme/src/site.tsx +59 -0
- package/template/sdk-kit/templates/theme/src/styles.css +71 -0
- package/template/server/client/routes.ts +252 -0
- package/template/server/cms/analyticsStore.ts +180 -0
- package/template/server/cms/auth.ts +155 -0
- package/template/server/cms/blockCatalog.ts +342 -0
- package/template/server/cms/blocks.ts +521 -0
- package/template/server/cms/contentMigration.ts +1119 -0
- package/template/server/cms/defaults.ts +303 -0
- package/template/server/cms/permissions.ts +154 -0
- package/template/server/cms/restoreClassicHome.ts +183 -0
- package/template/server/cms/revisions.ts +99 -0
- package/template/server/cms/scheduler.ts +78 -0
- package/template/server/cms/seed.ts +72 -0
- package/template/server/cms/seoAnalyzer.ts +213 -0
- package/template/server/cms/store.ts +122 -0
- package/template/server/cms/themeContent.ts +1386 -0
- package/template/server/cms/themePacks/sidibou-branding.json +1 -0
- package/template/server/cms/themePacks/sidibou-home.json +1 -0
- package/template/server/cms/themePacks/sidibou-menus.json +1 -0
- package/template/server/cms/types.ts +432 -0
- package/template/server/community/routes.ts +410 -0
- package/template/server/db/client.ts +43 -0
- package/template/server/db/repository.ts +389 -0
- package/template/server/db/schema.ts +726 -0
- package/template/server/demo/cmsReset.ts +196 -0
- package/template/server/developers/sdk.ts +85 -0
- package/template/server/geoip.ts +15 -0
- package/template/server/http.ts +53 -0
- package/template/server/mail.ts +216 -0
- package/template/server/marketplace/catalog.ts +74 -0
- package/template/server/marketplace/packageValidate.ts +475 -0
- package/template/server/marketplace/payments.ts +193 -0
- package/template/server/marketplace/routes.ts +850 -0
- package/template/server/marketplace/signing.ts +116 -0
- package/template/server/marketplace/syncOfficial.ts +282 -0
- package/template/server/media/images.ts +63 -0
- package/template/server/middleware/adminAuth.ts +134 -0
- package/template/server/modules/legacy.ts +44 -0
- package/template/server/modules/manager.ts +1122 -0
- package/template/server/modules/marketplace.ts +178 -0
- package/template/server/modules/outbound.ts +178 -0
- package/template/server/modules/purchases.ts +149 -0
- package/template/server/modules/records.ts +168 -0
- package/template/server/modules/themeHtml.ts +32 -0
- package/template/server/modules/trust.ts +16 -0
- package/template/server/modules/types.ts +147 -0
- package/template/server/platform/auth.ts +223 -0
- package/template/server/platform/clientWelcome.ts +168 -0
- package/template/server/platform/clients.ts +139 -0
- package/template/server/platform/dailyImprove.ts +356 -0
- package/template/server/platform/flouci.ts +126 -0
- package/template/server/platform/host.ts +69 -0
- package/template/server/platform/hostingProviders.ts +143 -0
- package/template/server/platform/licenseOrders.ts +291 -0
- package/template/server/platform/money.ts +42 -0
- package/template/server/platform/passwords.ts +41 -0
- package/template/server/platform/region.ts +86 -0
- package/template/server/platform/routes.ts +225 -0
- package/template/server/platform/seed.ts +82 -0
- package/template/server/platform/settings.ts +72 -0
- package/template/server/routes/adminAccount.ts +403 -0
- package/template/server/routes/adminCms.ts +808 -0
- package/template/server/routes/adminSystem.ts +243 -0
- package/template/server/routes/adminUsers.ts +449 -0
- package/template/server/routes/googleOAuth.ts +327 -0
- package/template/server/routes/modules.ts +323 -0
- package/template/server/routes/publicCms.ts +313 -0
- package/template/server/routes/seoPublic.ts +158 -0
- package/template/server/security/accounts.ts +121 -0
- package/template/server/security/audit.ts +143 -0
- package/template/server/security/authTokens.ts +74 -0
- package/template/server/security/ip.ts +68 -0
- package/template/server/security/rateLimit.ts +85 -0
- package/template/server/security/retention.ts +46 -0
- package/template/server/security/secrets.ts +44 -0
- package/template/server/security/sessions.ts +140 -0
- package/template/server/security/totp.ts +101 -0
- package/template/server/superadmin/analytics.ts +109 -0
- package/template/server/superadmin/auth.ts +92 -0
- package/template/server/superadmin/backlinksCatalog.ts +210 -0
- package/template/server/superadmin/frSeoContent.ts +165 -0
- package/template/server/superadmin/landingSeo.ts +675 -0
- package/template/server/superadmin/ops.ts +238 -0
- package/template/server/superadmin/routes.ts +1095 -0
- package/template/server/superadmin/tnSeoContent.ts +130 -0
- package/template/server.ts +522 -0
- package/template/src/App.tsx +263 -0
- package/template/src/admin/AdminApp.tsx +162 -0
- package/template/src/admin/account/AuthLayout.tsx +57 -0
- package/template/src/admin/account/SecurityForms.tsx +276 -0
- package/template/src/admin/admin.css +127 -0
- package/template/src/admin/context/AuthContext.tsx +147 -0
- package/template/src/admin/context/SiteContext.tsx +50 -0
- package/template/src/admin/editor/BlockLibrary.tsx +173 -0
- package/template/src/admin/editor/BlocksPanel.tsx +396 -0
- package/template/src/admin/editor/EditorBits.tsx +106 -0
- package/template/src/admin/editor/PreviewFrame.tsx +145 -0
- package/template/src/admin/editor/RichTextEditor.tsx +276 -0
- package/template/src/admin/editor/SeoPanel.tsx +349 -0
- package/template/src/admin/editor/StyleEditor.tsx +114 -0
- package/template/src/admin/editor/blockSchemas.ts +699 -0
- package/template/src/admin/editor/fields.tsx +486 -0
- package/template/src/admin/layout/AdminShell.tsx +418 -0
- package/template/src/admin/layout/nav.ts +95 -0
- package/template/src/admin/lib/api.ts +408 -0
- package/template/src/admin/lib/audit.ts +141 -0
- package/template/src/admin/lib/format.ts +84 -0
- package/template/src/admin/lib/hooks.ts +125 -0
- package/template/src/admin/main.tsx +16 -0
- package/template/src/admin/modules/InstallDialog.tsx +160 -0
- package/template/src/admin/modules/SettingsForm.tsx +145 -0
- package/template/src/admin/modules/kit.tsx +127 -0
- package/template/src/admin/modules/labels.tsx +226 -0
- package/template/src/admin/pages/AccountSetupPage.tsx +62 -0
- package/template/src/admin/pages/AnalyticsPage.tsx +206 -0
- package/template/src/admin/pages/BrandingPage.tsx +154 -0
- package/template/src/admin/pages/DashboardPage.tsx +239 -0
- package/template/src/admin/pages/EngagementPage.tsx +168 -0
- package/template/src/admin/pages/FormsPage.tsx +435 -0
- package/template/src/admin/pages/GeneralPage.tsx +120 -0
- package/template/src/admin/pages/LoginPage.tsx +249 -0
- package/template/src/admin/pages/MaintenancePage.tsx +125 -0
- package/template/src/admin/pages/MarketplacePage.tsx +426 -0
- package/template/src/admin/pages/MediaPage.tsx +251 -0
- package/template/src/admin/pages/MenusPage.tsx +446 -0
- package/template/src/admin/pages/ModuleAdminPage.tsx +113 -0
- package/template/src/admin/pages/ModuleDetailPage.tsx +293 -0
- package/template/src/admin/pages/ModulesPage.tsx +135 -0
- package/template/src/admin/pages/NewsletterPage.tsx +193 -0
- package/template/src/admin/pages/PageEditorPage.tsx +322 -0
- package/template/src/admin/pages/PagesListPage.tsx +277 -0
- package/template/src/admin/pages/PostEditorPage.tsx +292 -0
- package/template/src/admin/pages/PostsListPage.tsx +187 -0
- package/template/src/admin/pages/ProfilePage.tsx +489 -0
- package/template/src/admin/pages/ResetPasswordPage.tsx +110 -0
- package/template/src/admin/pages/SeoPage.tsx +670 -0
- package/template/src/admin/pages/SettingsPage.tsx +189 -0
- package/template/src/admin/pages/ThemeCustomizePage.tsx +170 -0
- package/template/src/admin/pages/ThemesPage.tsx +292 -0
- package/template/src/admin/pages/UsersPage.tsx +57 -0
- package/template/src/admin/pages/WidgetsPage.tsx +200 -0
- package/template/src/admin/seo/GoogleSetup.tsx +529 -0
- package/template/src/admin/settings/EmailTab.tsx +293 -0
- package/template/src/admin/settings/OtherTabs.tsx +270 -0
- package/template/src/admin/settings/SecurityTab.tsx +172 -0
- package/template/src/admin/settings/controls.tsx +133 -0
- package/template/src/admin/ui/Pagination.tsx +170 -0
- package/template/src/admin/ui/SaveBar.tsx +77 -0
- package/template/src/admin/ui/TagInput.tsx +54 -0
- package/template/src/admin/ui/charts.tsx +108 -0
- package/template/src/admin/ui/media.tsx +265 -0
- package/template/src/admin/ui/overlays.tsx +239 -0
- package/template/src/admin/ui/primitives.tsx +544 -0
- package/template/src/admin/users/AuditTab.tsx +104 -0
- package/template/src/admin/users/RolesTab.tsx +368 -0
- package/template/src/admin/users/UsersTab.tsx +723 -0
- package/template/src/admin/users/shared.tsx +278 -0
- package/template/src/cms/icons.ts +7 -0
- package/template/src/components/CookieBanner.tsx +166 -0
- package/template/src/components/MaintenanceGate.tsx +66 -0
- package/template/src/components/SiteAnalytics.tsx +64 -0
- package/template/src/components/SnapifyLogo.tsx +44 -0
- package/template/src/components/cms/BlockRenderer.tsx +154 -0
- package/template/src/components/cms/WidgetArea.tsx +193 -0
- package/template/src/context/SiteConfigContext.tsx +130 -0
- package/template/src/demoBase.ts +23 -0
- package/template/src/index.css +90 -0
- package/template/src/main.tsx +16 -0
- package/template/src/modules/ModuleHost.tsx +197 -0
- package/template/src/preview.ts +63 -0
- package/template/src/runtime.ts +38 -0
- package/template/src/themes/ThemeHost.tsx +168 -0
- package/template/src/themes/fallback.tsx +71 -0
- package/template/src/types.ts +94 -0
- package/template/src/views/BlogPostView.tsx +68 -0
- package/template/src/views/CmsPageView.tsx +34 -0
- package/template/start-pm2.sh +3 -0
- package/template/superadmin.html +20 -0
- package/template/themes/ai-canvas/screenshot.jpg +0 -0
- package/template/themes/ai-canvas/snapify.theme.json +96 -0
- package/template/themes/ai-canvas/src/CeeSimulator.tsx +247 -0
- package/template/themes/ai-canvas/src/Footer.tsx +190 -0
- package/template/themes/ai-canvas/src/Header.tsx +324 -0
- package/template/themes/ai-canvas/src/Layout.tsx +56 -0
- package/template/themes/ai-canvas/src/NotFound.tsx +58 -0
- package/template/themes/ai-canvas/src/Post.tsx +26 -0
- package/template/themes/ai-canvas/src/SnapifyLogo.tsx +44 -0
- package/template/themes/ai-canvas/src/blocks/CollectionBlocks.tsx +711 -0
- package/template/themes/ai-canvas/src/blocks/ContentBlocks.tsx +318 -0
- package/template/themes/ai-canvas/src/blocks/ConversionBlocks.tsx +559 -0
- package/template/themes/ai-canvas/src/blocks/HeaderBlocks.tsx +341 -0
- package/template/themes/ai-canvas/src/index.tsx +54 -0
- package/template/themes/ai-canvas/src/kit.tsx +398 -0
- package/template/themes/ai-canvas/src/site.ts +29 -0
- package/template/themes/ai-canvas/src/styles.css +317 -0
- package/template/themes/dogga/screenshot.jpg +0 -0
- package/template/themes/dogga/snapify.theme.json +55 -0
- package/template/themes/dogga/src/Brand.tsx +41 -0
- package/template/themes/dogga/src/Footer.tsx +202 -0
- package/template/themes/dogga/src/Header.tsx +239 -0
- package/template/themes/dogga/src/Layout.tsx +43 -0
- package/template/themes/dogga/src/Views.tsx +71 -0
- package/template/themes/dogga/src/blocks/CollectionBlocks.tsx +674 -0
- package/template/themes/dogga/src/blocks/ContentBlocks.tsx +307 -0
- package/template/themes/dogga/src/blocks/ConversionBlocks.tsx +571 -0
- package/template/themes/dogga/src/blocks/HeaderBlocks.tsx +289 -0
- package/template/themes/dogga/src/index.tsx +53 -0
- package/template/themes/dogga/src/kit.tsx +362 -0
- package/template/themes/dogga/src/site.ts +56 -0
- package/template/themes/dogga/src/styles.css +396 -0
- package/template/themes/mahdia/screenshot.jpg +0 -0
- package/template/themes/mahdia/snapify.theme.json +65 -0
- package/template/themes/mahdia/src/Brand.tsx +39 -0
- package/template/themes/mahdia/src/Footer.tsx +210 -0
- package/template/themes/mahdia/src/Header.tsx +291 -0
- package/template/themes/mahdia/src/Layout.tsx +44 -0
- package/template/themes/mahdia/src/Views.tsx +79 -0
- package/template/themes/mahdia/src/blocks/CollectionBlocks.tsx +674 -0
- package/template/themes/mahdia/src/blocks/ContentBlocks.tsx +307 -0
- package/template/themes/mahdia/src/blocks/ConversionBlocks.tsx +571 -0
- package/template/themes/mahdia/src/blocks/HeaderBlocks.tsx +289 -0
- package/template/themes/mahdia/src/index.tsx +53 -0
- package/template/themes/mahdia/src/kit.tsx +362 -0
- package/template/themes/mahdia/src/site.ts +75 -0
- package/template/themes/mahdia/src/styles.css +446 -0
- package/template/themes/preveris/screenshot.jpg +0 -0
- package/template/themes/preveris/snapify.theme.json +126 -0
- package/template/themes/preveris/src/Brand.tsx +44 -0
- package/template/themes/preveris/src/Footer.tsx +202 -0
- package/template/themes/preveris/src/Header.tsx +239 -0
- package/template/themes/preveris/src/Layout.tsx +42 -0
- package/template/themes/preveris/src/Views.tsx +71 -0
- package/template/themes/preveris/src/blocks/CollectionBlocks.tsx +678 -0
- package/template/themes/preveris/src/blocks/ContentBlocks.tsx +307 -0
- package/template/themes/preveris/src/blocks/ConversionBlocks.tsx +571 -0
- package/template/themes/preveris/src/blocks/HeaderBlocks.tsx +299 -0
- package/template/themes/preveris/src/index.tsx +53 -0
- package/template/themes/preveris/src/kit.tsx +365 -0
- package/template/themes/preveris/src/site.ts +79 -0
- package/template/themes/preveris/src/styles.css +446 -0
- package/template/themes/sidibou/screenshot.jpg +0 -0
- package/template/themes/sidibou/snapify.theme.json +21 -0
- package/template/themes/sidibou/src/CeeSimulator.tsx +247 -0
- package/template/themes/sidibou/src/Footer.tsx +203 -0
- package/template/themes/sidibou/src/Header.tsx +324 -0
- package/template/themes/sidibou/src/Layout.tsx +53 -0
- package/template/themes/sidibou/src/NotFound.tsx +58 -0
- package/template/themes/sidibou/src/Post.tsx +26 -0
- package/template/themes/sidibou/src/SnapifyLogo.tsx +44 -0
- package/template/themes/sidibou/src/blocks/CollectionBlocks.tsx +711 -0
- package/template/themes/sidibou/src/blocks/ContentBlocks.tsx +318 -0
- package/template/themes/sidibou/src/blocks/ConversionBlocks.tsx +559 -0
- package/template/themes/sidibou/src/blocks/HeaderBlocks.tsx +341 -0
- package/template/themes/sidibou/src/index.tsx +54 -0
- package/template/themes/sidibou/src/kit.tsx +398 -0
- package/template/themes/sidibou/src/site.ts +28 -0
- package/template/themes/sidibou/src/styles.css +317 -0
- package/template/tsconfig.json +33 -0
- package/template/vite.config.ts +42 -0
|
@@ -0,0 +1,1229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapify Marketplace — UI inspirée d’addons.prestashop.com
|
|
3
|
+
* © 2026 NOVALABS WEB DESIGN — Tunisie
|
|
4
|
+
*/
|
|
5
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { Link, Navigate, Route, Routes, useLocation, useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
|
7
|
+
import {
|
|
8
|
+
Award,
|
|
9
|
+
BadgeCheck,
|
|
10
|
+
LayoutTemplate,
|
|
11
|
+
Package,
|
|
12
|
+
Puzzle,
|
|
13
|
+
Search,
|
|
14
|
+
ShoppingCart,
|
|
15
|
+
Star,
|
|
16
|
+
Upload,
|
|
17
|
+
Users,
|
|
18
|
+
Shield,
|
|
19
|
+
User,
|
|
20
|
+
Menu,
|
|
21
|
+
SlidersHorizontal,
|
|
22
|
+
X,
|
|
23
|
+
} from 'lucide-react';
|
|
24
|
+
import { api, ApiError } from '../../shared/api';
|
|
25
|
+
import { useAuth } from '../../shared/AuthContext';
|
|
26
|
+
import { Brand, SnapifyMark } from '../../shared/Logo';
|
|
27
|
+
import { DtInput, formatMoney } from '../../shared/ui';
|
|
28
|
+
import { DeveloperRoutes } from './developer/DeveloperApp';
|
|
29
|
+
|
|
30
|
+
type Product = {
|
|
31
|
+
id: string;
|
|
32
|
+
slug: string;
|
|
33
|
+
name: string;
|
|
34
|
+
kind: 'module' | 'theme';
|
|
35
|
+
shortDesc: string;
|
|
36
|
+
longDesc?: string;
|
|
37
|
+
category: string;
|
|
38
|
+
priceMillimes: number;
|
|
39
|
+
priceLabel: string;
|
|
40
|
+
icon: string;
|
|
41
|
+
screenshots: string[];
|
|
42
|
+
salesCount: number;
|
|
43
|
+
status?: string;
|
|
44
|
+
versions?: { id: string; version: string; changelog: string; createdAt: string }[];
|
|
45
|
+
reviews?: { id: string; rating: number; body: string; author: { displayName: string } | null }[];
|
|
46
|
+
avgRating?: number | null;
|
|
47
|
+
reviewCount?: number;
|
|
48
|
+
publisher?: { displayName: string; website?: string | null } | null;
|
|
49
|
+
engines?: { snapify?: string };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function Stars({ value, count }: { value?: number | null; count?: number }) {
|
|
53
|
+
if (value == null && !count) return <span className="mp-stars"><span>—</span></span>;
|
|
54
|
+
const v = value ?? 0;
|
|
55
|
+
return (
|
|
56
|
+
<span className="mp-stars" title={`${v}/5`}>
|
|
57
|
+
<Star className="h-3.5 w-3.5 fill-current" />
|
|
58
|
+
{v ? v.toFixed(1) : '—'}
|
|
59
|
+
{typeof count === 'number' ? <span>({count})</span> : null}
|
|
60
|
+
</span>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function mediaUrl(s?: string | null) {
|
|
65
|
+
return !!s && (/^https?:\/\//.test(s) || s.startsWith('/uploads/'));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function coverOf(p: Product) {
|
|
69
|
+
return (p.screenshots && p.screenshots.find(mediaUrl)) || (mediaUrl(p.icon) ? p.icon : null);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function ProductCard({ p }: { p: Product }) {
|
|
73
|
+
const cover = coverOf(p);
|
|
74
|
+
return (
|
|
75
|
+
<Link to={`/product/${p.slug}`} className="mp-card">
|
|
76
|
+
<div className="mp-card-media">
|
|
77
|
+
<span className="kind">{p.kind === 'theme' ? 'Thème' : 'Module'}</span>
|
|
78
|
+
{cover ? (
|
|
79
|
+
<img src={cover} alt="" />
|
|
80
|
+
) : p.kind === 'theme' ? (
|
|
81
|
+
<LayoutTemplate className="h-12 w-12 text-px-primary-dark opacity-80" />
|
|
82
|
+
) : (
|
|
83
|
+
<Puzzle className="h-12 w-12 text-px-primary-dark opacity-80" />
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
<div className="mp-card-body">
|
|
87
|
+
<h3>{p.name}</h3>
|
|
88
|
+
<div className="mp-card-dev">par {p.publisher?.displayName || 'Snapify Community'}</div>
|
|
89
|
+
<p className="mp-card-desc">{p.shortDesc}</p>
|
|
90
|
+
<div className="mp-card-meta">
|
|
91
|
+
<span className={`mp-price ${p.priceMillimes === 0 ? 'free' : ''}`}>{p.priceMillimes === 0 ? 'Gratuit' : p.priceLabel}</span>
|
|
92
|
+
<Stars value={p.avgRating} count={p.reviewCount} />
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</Link>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const NAV_LINKS = [
|
|
100
|
+
{ to: '/catalog?kind=module', label: 'Modules', match: (path: string, kind: string | null) => path === '/catalog' && kind === 'module' },
|
|
101
|
+
{ to: '/catalog?kind=theme', label: 'Thèmes', match: (path: string, kind: string | null) => path === '/catalog' && kind === 'theme' },
|
|
102
|
+
{ to: '/catalog', label: 'Catalogue', match: (path: string, kind: string | null) => path === '/catalog' && !kind },
|
|
103
|
+
{ to: '/developer', label: 'Développeurs', match: (path: string) => path === '/developer' },
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
function Shell({ children }: { children: React.ReactNode }) {
|
|
107
|
+
const { user, logout } = useAuth();
|
|
108
|
+
const nav = useNavigate();
|
|
109
|
+
const location = useLocation();
|
|
110
|
+
const [cartCount, setCartCount] = useState(0);
|
|
111
|
+
const [q, setQ] = useState('');
|
|
112
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
113
|
+
const [fees, setFees] = useState<{ developerFeeLabel: string; commissionBps: number } | null>(null);
|
|
114
|
+
const kind = new URLSearchParams(location.search).get('kind');
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
api<{ developerFeeLabel: string; commissionBps: number }>('/api/marketplace/settings/public')
|
|
118
|
+
.then(setFees)
|
|
119
|
+
.catch(() => {});
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (!user) return setCartCount(0);
|
|
124
|
+
api<{ items: unknown[] }>('/api/marketplace/cart')
|
|
125
|
+
.then((d) => setCartCount(d.items.length))
|
|
126
|
+
.catch(() => setCartCount(0));
|
|
127
|
+
}, [user, children]);
|
|
128
|
+
|
|
129
|
+
useEffect(() => setMenuOpen(false), [location.pathname, location.search]);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
document.body.style.overflow = menuOpen ? 'hidden' : '';
|
|
133
|
+
return () => {
|
|
134
|
+
document.body.style.overflow = '';
|
|
135
|
+
};
|
|
136
|
+
}, [menuOpen]);
|
|
137
|
+
|
|
138
|
+
const goSearch = (e?: React.FormEvent) => {
|
|
139
|
+
e?.preventDefault();
|
|
140
|
+
nav(`/catalog?q=${encodeURIComponent(q.trim())}`);
|
|
141
|
+
setMenuOpen(false);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const isPublisher = user && (user.role === 'publisher' || user.role === 'admin');
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<div className="min-h-screen bg-white">
|
|
148
|
+
<div className="mp-topbar">
|
|
149
|
+
<div className="mp-wrap flex h-9 items-center justify-between gap-3">
|
|
150
|
+
<span>Marketplace officielle Snapify — thèmes & modules signés</span>
|
|
151
|
+
<div className="flex gap-4">
|
|
152
|
+
<Link to="/developer">Devenir développeur</Link>
|
|
153
|
+
<a href="https://developers.snapify.tn">Documentation</a>
|
|
154
|
+
<a href="https://community.snapify.tn" target="_blank" rel="noreferrer">
|
|
155
|
+
Community
|
|
156
|
+
</a>
|
|
157
|
+
<a href="https://snapify.tn" target="_blank" rel="noreferrer">
|
|
158
|
+
snapify.tn →
|
|
159
|
+
</a>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<header className="mp-header">
|
|
165
|
+
<div className="mp-header-inner">
|
|
166
|
+
<button
|
|
167
|
+
type="button"
|
|
168
|
+
className="mp-icon-btn mp-burger"
|
|
169
|
+
onClick={() => setMenuOpen((v) => !v)}
|
|
170
|
+
aria-label={menuOpen ? 'Fermer le menu' : 'Ouvrir le menu'}
|
|
171
|
+
aria-expanded={menuOpen}
|
|
172
|
+
>
|
|
173
|
+
{menuOpen ? <X className="h-5 w-5" /> : <Menu className="h-5 w-5" />}
|
|
174
|
+
</button>
|
|
175
|
+
<Link to="/" className="mp-logo">
|
|
176
|
+
<div className="mp-logo-mark">
|
|
177
|
+
<SnapifyMark className="h-5 w-5" accent="#fff" frame="#fff" />
|
|
178
|
+
</div>
|
|
179
|
+
<div className="mp-logo-text">
|
|
180
|
+
<div className="text-sm font-bold tracking-wide">SNAPIFY</div>
|
|
181
|
+
<div className="text-[11px] text-white/50">Addons Marketplace</div>
|
|
182
|
+
</div>
|
|
183
|
+
</Link>
|
|
184
|
+
|
|
185
|
+
<nav className="mp-nav">
|
|
186
|
+
{NAV_LINKS.map((l) => (
|
|
187
|
+
<Link key={l.to} to={l.to} className={l.match(location.pathname, kind) ? 'active' : ''}>
|
|
188
|
+
{l.label}
|
|
189
|
+
</Link>
|
|
190
|
+
))}
|
|
191
|
+
</nav>
|
|
192
|
+
|
|
193
|
+
<form className="mp-search-header" onSubmit={goSearch}>
|
|
194
|
+
<input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Rechercher un module, un thème…" />
|
|
195
|
+
<button type="submit" aria-label="Rechercher">
|
|
196
|
+
<Search className="h-4 w-4" />
|
|
197
|
+
</button>
|
|
198
|
+
</form>
|
|
199
|
+
|
|
200
|
+
<div className="mp-header-actions">
|
|
201
|
+
{user ? (
|
|
202
|
+
<>
|
|
203
|
+
<Link to="/account" className="mp-icon-btn" aria-label="Mon compte">
|
|
204
|
+
<User className="h-5 w-5" />
|
|
205
|
+
<span className="mp-hide-lg">{user.displayName}</span>
|
|
206
|
+
</Link>
|
|
207
|
+
{isPublisher && (
|
|
208
|
+
<Link to="/developer/dashboard" className="mp-icon-btn mp-hide-sm">
|
|
209
|
+
Dashboard
|
|
210
|
+
</Link>
|
|
211
|
+
)}
|
|
212
|
+
{user.role === 'admin' && (
|
|
213
|
+
<Link to="/admin" className="mp-icon-btn mp-hide-sm">
|
|
214
|
+
Admin
|
|
215
|
+
</Link>
|
|
216
|
+
)}
|
|
217
|
+
<button type="button" className="mp-icon-btn mp-hide-sm" onClick={() => void logout()}>
|
|
218
|
+
Sortir
|
|
219
|
+
</button>
|
|
220
|
+
</>
|
|
221
|
+
) : (
|
|
222
|
+
<Link to="/login" className="mp-icon-btn" aria-label="Compte">
|
|
223
|
+
<User className="h-5 w-5" />
|
|
224
|
+
<span className="mp-hide-sm">Compte</span>
|
|
225
|
+
</Link>
|
|
226
|
+
)}
|
|
227
|
+
<Link to="/cart" className="mp-icon-btn" aria-label={`Panier (${cartCount})`}>
|
|
228
|
+
<ShoppingCart className="h-5 w-5" />
|
|
229
|
+
<span className="mp-hide-sm">({cartCount})</span>
|
|
230
|
+
{cartCount > 0 && <span className="mp-badge">{cartCount}</span>}
|
|
231
|
+
</Link>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
{menuOpen && (
|
|
236
|
+
<div className="mp-drawer">
|
|
237
|
+
<form className="mp-drawer-search" onSubmit={goSearch}>
|
|
238
|
+
<Search className="h-4 w-4" />
|
|
239
|
+
<input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Rechercher un module, un thème…" />
|
|
240
|
+
</form>
|
|
241
|
+
<nav>
|
|
242
|
+
{NAV_LINKS.map((l) => (
|
|
243
|
+
<Link key={l.to} to={l.to} className={l.match(location.pathname, kind) ? 'active' : ''}>
|
|
244
|
+
{l.label}
|
|
245
|
+
</Link>
|
|
246
|
+
))}
|
|
247
|
+
</nav>
|
|
248
|
+
<div className="mp-drawer-sep" />
|
|
249
|
+
<nav>
|
|
250
|
+
{user ? (
|
|
251
|
+
<>
|
|
252
|
+
<Link to="/account">Mes achats & licences</Link>
|
|
253
|
+
{isPublisher && <Link to="/developer/dashboard">Dashboard vendeur</Link>}
|
|
254
|
+
{user.role === 'admin' && <Link to="/admin">Admin marketplace</Link>}
|
|
255
|
+
<button type="button" onClick={() => void logout()}>
|
|
256
|
+
Se déconnecter
|
|
257
|
+
</button>
|
|
258
|
+
</>
|
|
259
|
+
) : (
|
|
260
|
+
<>
|
|
261
|
+
<Link to="/login">Se connecter</Link>
|
|
262
|
+
<Link to="/register">Créer un compte</Link>
|
|
263
|
+
</>
|
|
264
|
+
)}
|
|
265
|
+
</nav>
|
|
266
|
+
<div className="mp-drawer-sep" />
|
|
267
|
+
<nav className="mp-drawer-ext">
|
|
268
|
+
<a href="https://developers.snapify.tn">Documentation développeurs</a>
|
|
269
|
+
<a href="https://community.snapify.tn" target="_blank" rel="noreferrer">
|
|
270
|
+
Community
|
|
271
|
+
</a>
|
|
272
|
+
<a href="https://snapify.tn" target="_blank" rel="noreferrer">
|
|
273
|
+
snapify.tn
|
|
274
|
+
</a>
|
|
275
|
+
</nav>
|
|
276
|
+
</div>
|
|
277
|
+
)}
|
|
278
|
+
</header>
|
|
279
|
+
{menuOpen && <div className="mp-drawer-backdrop" onClick={() => setMenuOpen(false)} />}
|
|
280
|
+
|
|
281
|
+
<main>{children}</main>
|
|
282
|
+
|
|
283
|
+
<footer className="mp-footer">
|
|
284
|
+
<div className="mp-wrap">
|
|
285
|
+
<div className="mp-footer-grid">
|
|
286
|
+
<div>
|
|
287
|
+
<Brand subtitle="Addons Marketplace" dark />
|
|
288
|
+
<p className="mt-4 max-w-xs text-sm leading-relaxed text-white/55">
|
|
289
|
+
La marketplace officielle pour étendre Snapify : modules, thèmes, et outils créés par la communauté et NOVALABS.
|
|
290
|
+
</p>
|
|
291
|
+
</div>
|
|
292
|
+
<div>
|
|
293
|
+
<h4>Catalogue</h4>
|
|
294
|
+
<Link to="/catalog?kind=module">Modules</Link>
|
|
295
|
+
<Link to="/catalog?kind=theme">Thèmes</Link>
|
|
296
|
+
<Link to="/catalog?pricing=free">Gratuits</Link>
|
|
297
|
+
<Link to="/catalog?sort=popular">Best-sellers</Link>
|
|
298
|
+
</div>
|
|
299
|
+
<div>
|
|
300
|
+
<h4>Développeurs</h4>
|
|
301
|
+
<a href="https://developers.snapify.tn">Documentation</a>
|
|
302
|
+
<Link to="/developer">Publier un module</Link>
|
|
303
|
+
<Link to="/developer">{fees ? `Inscription ${fees.developerFeeLabel}` : 'Inscription développeur'}</Link>
|
|
304
|
+
<Link to="/developer/dashboard">Espace vendeur</Link>
|
|
305
|
+
</div>
|
|
306
|
+
<div>
|
|
307
|
+
<h4>Aide</h4>
|
|
308
|
+
<a href="https://community.snapify.tn">Forum Community</a>
|
|
309
|
+
<a href="https://snapify.tn">Snapify Tunisie</a>
|
|
310
|
+
<a href="https://snapify.fr">Snapify France</a>
|
|
311
|
+
<a href="https://novalabs.tn" rel="noopener noreferrer">
|
|
312
|
+
NOVALABS
|
|
313
|
+
</a>
|
|
314
|
+
<Link to="/account">Mes achats & licences</Link>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
<div className="mp-footer-bottom">
|
|
318
|
+
<span>© 2026 NOVALABS WEB DESIGN — Tunisie</span>
|
|
319
|
+
<span>Paiements Flouci{fees ? ` · Commission marketplace ${fees.commissionBps / 100} %` : ''}</span>
|
|
320
|
+
</div>
|
|
321
|
+
</div>
|
|
322
|
+
</footer>
|
|
323
|
+
</div>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function Home() {
|
|
328
|
+
const nav = useNavigate();
|
|
329
|
+
const [q, setQ] = useState('');
|
|
330
|
+
const [popular, setPopular] = useState<Product[]>([]);
|
|
331
|
+
const [newest, setNewest] = useState<Product[]>([]);
|
|
332
|
+
const [modules, setModules] = useState<Product[]>([]);
|
|
333
|
+
const [themes, setThemes] = useState<Product[]>([]);
|
|
334
|
+
const [cats, setCats] = useState<{ category: string; n: number }[]>([]);
|
|
335
|
+
const [devFeeLabel, setDevFeeLabel] = useState(() => formatMoney(100000));
|
|
336
|
+
|
|
337
|
+
useEffect(() => {
|
|
338
|
+
api<{ items: Product[] }>('/api/marketplace/products?sort=popular&pageSize=8').then((d) => setPopular(d.items));
|
|
339
|
+
api<{ items: Product[] }>('/api/marketplace/products?sort=newest&pageSize=8').then((d) => setNewest(d.items));
|
|
340
|
+
api<{ items: Product[] }>('/api/marketplace/products?kind=module&sort=popular&pageSize=4').then((d) => setModules(d.items));
|
|
341
|
+
api<{ items: Product[] }>('/api/marketplace/products?kind=theme&sort=popular&pageSize=4').then((d) => setThemes(d.items));
|
|
342
|
+
api<{ items: { category: string; n: number }[] }>('/api/marketplace/categories').then((d) => setCats(d.items));
|
|
343
|
+
api<{ developerFeeLabel: string }>('/api/marketplace/settings/public')
|
|
344
|
+
.then((d) => setDevFeeLabel(d.developerFeeLabel))
|
|
345
|
+
.catch(() => {});
|
|
346
|
+
}, []);
|
|
347
|
+
|
|
348
|
+
return (
|
|
349
|
+
<div>
|
|
350
|
+
<section className="mp-hero">
|
|
351
|
+
<h1>Boostez les performances de votre site avec notre Marketplace</h1>
|
|
352
|
+
<p>Tout ce dont vous avez besoin pour personnaliser Snapify — modules, thèmes et outils.</p>
|
|
353
|
+
<form
|
|
354
|
+
className="mp-hero-search"
|
|
355
|
+
onSubmit={(e) => {
|
|
356
|
+
e.preventDefault();
|
|
357
|
+
nav(`/catalog?q=${encodeURIComponent(q.trim())}`);
|
|
358
|
+
}}
|
|
359
|
+
>
|
|
360
|
+
<input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Que recherchez-vous ? (Ex. paiement, SEO, thème…)" />
|
|
361
|
+
<button type="submit" aria-label="Rechercher">
|
|
362
|
+
<Search className="h-4 w-4" /> <span className="mp-hide-sm">Rechercher</span>
|
|
363
|
+
</button>
|
|
364
|
+
</form>
|
|
365
|
+
</section>
|
|
366
|
+
|
|
367
|
+
<div className="mp-wrap">
|
|
368
|
+
<div className="mp-promos">
|
|
369
|
+
<Link to="/catalog?kind=module" className="mp-promo mp-promo-a">
|
|
370
|
+
<div>
|
|
371
|
+
<h3>Modules pour accélérer votre boutique</h3>
|
|
372
|
+
<p>SEO, panier, checkout, chat IA… étendez Snapify en un clic.</p>
|
|
373
|
+
</div>
|
|
374
|
+
<span className="btn-mp self-start mt-4">Voir les modules</span>
|
|
375
|
+
</Link>
|
|
376
|
+
<Link to="/catalog?kind=theme" className="mp-promo mp-promo-b">
|
|
377
|
+
<div>
|
|
378
|
+
<h3>Thèmes premium prêts à publier</h3>
|
|
379
|
+
<p>Apparence moderne, blocs CMS et e-commerce intégrés.</p>
|
|
380
|
+
</div>
|
|
381
|
+
<span className="btn-mp self-start mt-4" style={{ background: '#0b1528' }}>
|
|
382
|
+
Voir les thèmes
|
|
383
|
+
</span>
|
|
384
|
+
</Link>
|
|
385
|
+
</div>
|
|
386
|
+
|
|
387
|
+
<div className="mp-trust">
|
|
388
|
+
<div className="mp-trust-item">
|
|
389
|
+
<div className="mp-trust-icon">
|
|
390
|
+
<Award className="h-5 w-5" />
|
|
391
|
+
</div>
|
|
392
|
+
<div>
|
|
393
|
+
<strong>Sélection de modules & thèmes</strong>
|
|
394
|
+
<span>Catalogue validé par l’équipe Snapify</span>
|
|
395
|
+
</div>
|
|
396
|
+
</div>
|
|
397
|
+
<div className="mp-trust-item">
|
|
398
|
+
<div className="mp-trust-icon">
|
|
399
|
+
<BadgeCheck className="h-5 w-5" />
|
|
400
|
+
</div>
|
|
401
|
+
<div>
|
|
402
|
+
<strong>Assurance qualité</strong>
|
|
403
|
+
<span>Paquets signés, versions & changelog</span>
|
|
404
|
+
</div>
|
|
405
|
+
</div>
|
|
406
|
+
<div className="mp-trust-item">
|
|
407
|
+
<div className="mp-trust-icon">
|
|
408
|
+
<Users className="h-5 w-5" />
|
|
409
|
+
</div>
|
|
410
|
+
<div>
|
|
411
|
+
<strong>Communauté de développeurs</strong>
|
|
412
|
+
<span>Publiez vos créations dès {devFeeLabel}</span>
|
|
413
|
+
</div>
|
|
414
|
+
</div>
|
|
415
|
+
</div>
|
|
416
|
+
|
|
417
|
+
{cats.length > 0 && (
|
|
418
|
+
<section className="mp-section">
|
|
419
|
+
<div className="mp-section-head">
|
|
420
|
+
<h2>Parcourir par catégorie</h2>
|
|
421
|
+
<Link className="mp-link-more" to="/catalog">
|
|
422
|
+
Voir tout →
|
|
423
|
+
</Link>
|
|
424
|
+
</div>
|
|
425
|
+
<div className="mp-cats">
|
|
426
|
+
{cats.map((c) => (
|
|
427
|
+
<Link key={c.category} className="mp-cat" to={`/catalog?category=${encodeURIComponent(c.category)}`}>
|
|
428
|
+
{c.category} <span style={{ color: '#9aa3af', fontWeight: 500 }}>({c.n})</span>
|
|
429
|
+
</Link>
|
|
430
|
+
))}
|
|
431
|
+
</div>
|
|
432
|
+
</section>
|
|
433
|
+
)}
|
|
434
|
+
|
|
435
|
+
<section className="mp-section">
|
|
436
|
+
<div className="mp-section-head">
|
|
437
|
+
<h2>Best-sellers</h2>
|
|
438
|
+
<Link className="mp-link-more" to="/catalog?sort=popular">
|
|
439
|
+
Voir plus →
|
|
440
|
+
</Link>
|
|
441
|
+
</div>
|
|
442
|
+
<div className="mp-grid">{popular.map((p) => <ProductCard key={p.id} p={p} />)}</div>
|
|
443
|
+
</section>
|
|
444
|
+
|
|
445
|
+
<section className="mp-section" style={{ paddingTop: 0 }}>
|
|
446
|
+
<div className="mp-section-head">
|
|
447
|
+
<h2>Nouveautés</h2>
|
|
448
|
+
<Link className="mp-link-more" to="/catalog?sort=newest">
|
|
449
|
+
Voir plus →
|
|
450
|
+
</Link>
|
|
451
|
+
</div>
|
|
452
|
+
<div className="mp-grid">{newest.map((p) => <ProductCard key={p.id} p={p} />)}</div>
|
|
453
|
+
</section>
|
|
454
|
+
|
|
455
|
+
<section className="mp-section" style={{ paddingTop: 0 }}>
|
|
456
|
+
<div className="mp-section-head">
|
|
457
|
+
<h2>Modules populaires</h2>
|
|
458
|
+
<Link className="mp-link-more" to="/catalog?kind=module">
|
|
459
|
+
Tous les modules →
|
|
460
|
+
</Link>
|
|
461
|
+
</div>
|
|
462
|
+
<div className="mp-grid">{modules.map((p) => <ProductCard key={p.id} p={p} />)}</div>
|
|
463
|
+
</section>
|
|
464
|
+
|
|
465
|
+
<section className="mp-section" style={{ paddingTop: 0 }}>
|
|
466
|
+
<div className="mp-section-head">
|
|
467
|
+
<h2>Thèmes populaires</h2>
|
|
468
|
+
<Link className="mp-link-more" to="/catalog?kind=theme">
|
|
469
|
+
Tous les thèmes →
|
|
470
|
+
</Link>
|
|
471
|
+
</div>
|
|
472
|
+
<div className="mp-grid">{themes.map((p) => <ProductCard key={p.id} p={p} />)}</div>
|
|
473
|
+
</section>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function Catalog() {
|
|
480
|
+
const [params, setParams] = useSearchParams();
|
|
481
|
+
const [data, setData] = useState<{ items: Product[]; total: number }>({ items: [], total: 0 });
|
|
482
|
+
const [cats, setCats] = useState<{ category: string; n: number }[]>([]);
|
|
483
|
+
const q = params.get('q') || '';
|
|
484
|
+
const kind = params.get('kind') || '';
|
|
485
|
+
const sort = params.get('sort') || 'popular';
|
|
486
|
+
const pricing = params.get('pricing') || '';
|
|
487
|
+
const category = params.get('category') || '';
|
|
488
|
+
const [filtersOpen, setFiltersOpen] = useState(false);
|
|
489
|
+
const activeFilters = [kind, pricing, category, q].filter(Boolean).length;
|
|
490
|
+
|
|
491
|
+
const set = (key: string, value: string) => {
|
|
492
|
+
const next = new URLSearchParams(params);
|
|
493
|
+
if (value) next.set(key, value);
|
|
494
|
+
else next.delete(key);
|
|
495
|
+
setParams(next);
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
useEffect(() => {
|
|
499
|
+
const qs = new URLSearchParams({ sort, pageSize: '24' });
|
|
500
|
+
if (q) qs.set('q', q);
|
|
501
|
+
if (kind) qs.set('kind', kind);
|
|
502
|
+
if (pricing) qs.set('pricing', pricing);
|
|
503
|
+
if (category) qs.set('category', category);
|
|
504
|
+
api<{ items: Product[]; total: number }>(`/api/marketplace/products?${qs}`).then(setData);
|
|
505
|
+
}, [q, kind, sort, pricing, category]);
|
|
506
|
+
|
|
507
|
+
useEffect(() => {
|
|
508
|
+
api<{ items: { category: string; n: number }[] }>('/api/marketplace/categories').then((d) => setCats(d.items));
|
|
509
|
+
}, []);
|
|
510
|
+
|
|
511
|
+
const title = useMemo(() => {
|
|
512
|
+
if (kind === 'module') return 'Modules';
|
|
513
|
+
if (kind === 'theme') return 'Thèmes';
|
|
514
|
+
if (pricing === 'free') return 'Extensions gratuites';
|
|
515
|
+
if (category) return category;
|
|
516
|
+
return 'Catalogue';
|
|
517
|
+
}, [kind, pricing, category]);
|
|
518
|
+
|
|
519
|
+
return (
|
|
520
|
+
<div className="mp-wrap">
|
|
521
|
+
<div className="mp-breadcrumb">
|
|
522
|
+
<Link to="/">Accueil</Link> / <span>{title}</span>
|
|
523
|
+
</div>
|
|
524
|
+
<div className="mp-catalog">
|
|
525
|
+
<button type="button" className="mp-filter-toggle" onClick={() => setFiltersOpen((v) => !v)} aria-expanded={filtersOpen}>
|
|
526
|
+
<SlidersHorizontal className="h-4 w-4" />
|
|
527
|
+
Filtres et tri
|
|
528
|
+
{activeFilters > 0 && <span className="mp-filter-count">{activeFilters}</span>}
|
|
529
|
+
</button>
|
|
530
|
+
<aside className={`mp-filters${filtersOpen ? ' is-open' : ''}`}>
|
|
531
|
+
<div className="group">
|
|
532
|
+
<h3>Recherche</h3>
|
|
533
|
+
<input
|
|
534
|
+
className="mp-input"
|
|
535
|
+
type="search"
|
|
536
|
+
defaultValue={q}
|
|
537
|
+
placeholder="Mot-clé…"
|
|
538
|
+
onKeyDown={(e) => {
|
|
539
|
+
if (e.key === 'Enter') set('q', (e.target as HTMLInputElement).value);
|
|
540
|
+
}}
|
|
541
|
+
/>
|
|
542
|
+
</div>
|
|
543
|
+
<div className="group">
|
|
544
|
+
<h3>Type</h3>
|
|
545
|
+
{[
|
|
546
|
+
['', 'Tous'],
|
|
547
|
+
['module', 'Modules'],
|
|
548
|
+
['theme', 'Thèmes'],
|
|
549
|
+
].map(([v, l]) => (
|
|
550
|
+
<label key={v || 'all'}>
|
|
551
|
+
<input type="radio" name="kind" checked={kind === v} onChange={() => set('kind', v)} /> {l}
|
|
552
|
+
</label>
|
|
553
|
+
))}
|
|
554
|
+
</div>
|
|
555
|
+
<div className="group">
|
|
556
|
+
<h3>Tarif</h3>
|
|
557
|
+
{[
|
|
558
|
+
['', 'Tous'],
|
|
559
|
+
['free', 'Gratuit'],
|
|
560
|
+
['paid', 'Payant'],
|
|
561
|
+
].map(([v, l]) => (
|
|
562
|
+
<label key={v || 'allp'}>
|
|
563
|
+
<input type="radio" name="pricing" checked={pricing === v} onChange={() => set('pricing', v)} /> {l}
|
|
564
|
+
</label>
|
|
565
|
+
))}
|
|
566
|
+
</div>
|
|
567
|
+
<div className="group">
|
|
568
|
+
<h3>Catégorie</h3>
|
|
569
|
+
<label>
|
|
570
|
+
<input type="radio" name="cat" checked={!category} onChange={() => set('category', '')} /> Toutes
|
|
571
|
+
</label>
|
|
572
|
+
{cats.map((c) => (
|
|
573
|
+
<label key={c.category}>
|
|
574
|
+
<input type="radio" name="cat" checked={category === c.category} onChange={() => set('category', c.category)} />
|
|
575
|
+
{c.category} ({c.n})
|
|
576
|
+
</label>
|
|
577
|
+
))}
|
|
578
|
+
</div>
|
|
579
|
+
<div className="group">
|
|
580
|
+
<h3>Trier par</h3>
|
|
581
|
+
<select value={sort} onChange={(e) => set('sort', e.target.value)}>
|
|
582
|
+
<option value="popular">Popularité</option>
|
|
583
|
+
<option value="newest">Nouveautés</option>
|
|
584
|
+
<option value="price_asc">Prix croissant</option>
|
|
585
|
+
<option value="price_desc">Prix décroissant</option>
|
|
586
|
+
</select>
|
|
587
|
+
</div>
|
|
588
|
+
</aside>
|
|
589
|
+
|
|
590
|
+
<div>
|
|
591
|
+
<div className="mp-toolbar">
|
|
592
|
+
<h1 style={{ margin: 0, fontSize: '1.5rem' }}>{title}</h1>
|
|
593
|
+
<span className="count">{data.total} résultat{data.total > 1 ? 's' : ''}</span>
|
|
594
|
+
</div>
|
|
595
|
+
{data.items.length ? (
|
|
596
|
+
<div className="mp-grid">{data.items.map((p) => <ProductCard key={p.id} p={p} />)}</div>
|
|
597
|
+
) : (
|
|
598
|
+
<div className="mp-empty">Aucun produit ne correspond à vos filtres.</div>
|
|
599
|
+
)}
|
|
600
|
+
</div>
|
|
601
|
+
</div>
|
|
602
|
+
</div>
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function ProductPage() {
|
|
607
|
+
const { slug } = useParams();
|
|
608
|
+
const { user } = useAuth();
|
|
609
|
+
const nav = useNavigate();
|
|
610
|
+
const [product, setProduct] = useState<Product | null>(null);
|
|
611
|
+
const [tab, setTab] = useState<'desc' | 'versions' | 'reviews'>('desc');
|
|
612
|
+
const [msg, setMsg] = useState('');
|
|
613
|
+
const [busy, setBusy] = useState(false);
|
|
614
|
+
const [rating, setRating] = useState(5);
|
|
615
|
+
const [reviewBody, setReviewBody] = useState('');
|
|
616
|
+
const [galleryIdx, setGalleryIdx] = useState(0);
|
|
617
|
+
|
|
618
|
+
useEffect(() => {
|
|
619
|
+
api<{ product: Product }>(`/api/marketplace/products/${slug}`).then((d) => {
|
|
620
|
+
setProduct(d.product);
|
|
621
|
+
setGalleryIdx(0);
|
|
622
|
+
});
|
|
623
|
+
}, [slug]);
|
|
624
|
+
|
|
625
|
+
if (!product) return <div className="mp-wrap py-16 text-center text-slate-500">Chargement du produit…</div>;
|
|
626
|
+
|
|
627
|
+
const gallery = [
|
|
628
|
+
...new Set([...(mediaUrl(product.icon) ? [product.icon] : []), ...(product.screenshots || []).filter(mediaUrl)]),
|
|
629
|
+
];
|
|
630
|
+
const mainImage = gallery[galleryIdx] || gallery[0];
|
|
631
|
+
const shortDesc = (product.shortDesc || '').trim();
|
|
632
|
+
const showShortDesc = !!shortDesc && !(product.longDesc || '').replace(/<[^>]+>/g, ' ').includes(shortDesc);
|
|
633
|
+
|
|
634
|
+
return (
|
|
635
|
+
<div className="mp-wrap">
|
|
636
|
+
<div className="mp-breadcrumb">
|
|
637
|
+
<Link to="/">Accueil</Link> / <Link to={`/catalog?kind=${product.kind}`}>{product.kind === 'theme' ? 'Thèmes' : 'Modules'}</Link> /{' '}
|
|
638
|
+
<span>{product.name}</span>
|
|
639
|
+
</div>
|
|
640
|
+
|
|
641
|
+
<div className="mp-product">
|
|
642
|
+
<div className="mp-product-media">
|
|
643
|
+
<div className="mp-gallery">
|
|
644
|
+
{mainImage ? (
|
|
645
|
+
<img className="mp-gallery-main" src={mainImage} alt={product.name} />
|
|
646
|
+
) : product.kind === 'theme' ? (
|
|
647
|
+
<LayoutTemplate className="h-24 w-24 text-px-primary-dark opacity-70" />
|
|
648
|
+
) : (
|
|
649
|
+
<Puzzle className="h-24 w-24 text-px-primary-dark opacity-70" />
|
|
650
|
+
)}
|
|
651
|
+
</div>
|
|
652
|
+
{gallery.length > 1 && (
|
|
653
|
+
<div className="mp-gallery-thumbs">
|
|
654
|
+
{gallery.map((url, i) => (
|
|
655
|
+
<button key={`${url}-${i}`} type="button" className={i === galleryIdx ? 'active' : ''} onClick={() => setGalleryIdx(i)}>
|
|
656
|
+
<img src={url} alt="" />
|
|
657
|
+
</button>
|
|
658
|
+
))}
|
|
659
|
+
</div>
|
|
660
|
+
)}
|
|
661
|
+
</div>
|
|
662
|
+
<div className="mp-product-info">
|
|
663
|
+
<div className="mp-tabs">
|
|
664
|
+
<button type="button" className={tab === 'desc' ? 'active' : ''} onClick={() => setTab('desc')}>
|
|
665
|
+
Description
|
|
666
|
+
</button>
|
|
667
|
+
<button type="button" className={tab === 'versions' ? 'active' : ''} onClick={() => setTab('versions')}>
|
|
668
|
+
Versions & changelog
|
|
669
|
+
</button>
|
|
670
|
+
<button type="button" className={tab === 'reviews' ? 'active' : ''} onClick={() => setTab('reviews')}>
|
|
671
|
+
Avis ({product.reviews?.length || 0})
|
|
672
|
+
</button>
|
|
673
|
+
</div>
|
|
674
|
+
<div className="mp-tab-panel">
|
|
675
|
+
{tab === 'desc' && (
|
|
676
|
+
<div>
|
|
677
|
+
{showShortDesc && <p style={{ color: '#6c6c6c', marginTop: 0 }}>{shortDesc}</p>}
|
|
678
|
+
<div dangerouslySetInnerHTML={{ __html: product.longDesc || '<p>Aucune description détaillée.</p>' }} />
|
|
679
|
+
<p style={{ marginTop: 20, fontSize: 13, color: '#6c6c6c' }}>
|
|
680
|
+
Catégorie : <strong>{product.category}</strong> · Compatible Snapify {product.engines?.snapify || '^1.0.0'}
|
|
681
|
+
</p>
|
|
682
|
+
</div>
|
|
683
|
+
)}
|
|
684
|
+
{tab === 'versions' && (
|
|
685
|
+
<ul style={{ listStyle: 'none', padding: 0, margin: 0 }}>
|
|
686
|
+
{(product.versions || []).map((v) => (
|
|
687
|
+
<li key={v.id} style={{ borderBottom: '1px solid #e5e7eb', padding: '14px 0' }}>
|
|
688
|
+
<strong>v{v.version}</strong>
|
|
689
|
+
<div style={{ color: '#6c6c6c', fontSize: 13, marginTop: 4 }}>{new Date(v.createdAt).toLocaleDateString('fr-TN')}</div>
|
|
690
|
+
<div style={{ marginTop: 8 }}>{v.changelog || '—'}</div>
|
|
691
|
+
</li>
|
|
692
|
+
))}
|
|
693
|
+
{!product.versions?.length && <li>Aucune version publiée.</li>}
|
|
694
|
+
</ul>
|
|
695
|
+
)}
|
|
696
|
+
{tab === 'reviews' && (
|
|
697
|
+
<div>
|
|
698
|
+
<ul style={{ listStyle: 'none', padding: 0, margin: 0 }}>
|
|
699
|
+
{(product.reviews || []).map((r) => (
|
|
700
|
+
<li key={r.id} style={{ borderBottom: '1px solid #e5e7eb', padding: '14px 0' }}>
|
|
701
|
+
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
702
|
+
<strong>{r.author?.displayName || 'Anonyme'}</strong>
|
|
703
|
+
<Stars value={r.rating} />
|
|
704
|
+
</div>
|
|
705
|
+
<p style={{ margin: '8px 0 0', color: '#444' }}>{r.body}</p>
|
|
706
|
+
</li>
|
|
707
|
+
))}
|
|
708
|
+
{!product.reviews?.length && <li style={{ color: '#6c6c6c' }}>Pas encore d’avis — soyez le premier.</li>}
|
|
709
|
+
</ul>
|
|
710
|
+
{user && (
|
|
711
|
+
<div style={{ marginTop: 24, borderTop: '1px solid #e5e7eb', paddingTop: 16 }}>
|
|
712
|
+
<h3 style={{ marginTop: 0 }}>Donner un avis</h3>
|
|
713
|
+
<label className="mp-label">
|
|
714
|
+
Note
|
|
715
|
+
<select className="mp-input" value={rating} onChange={(e) => setRating(Number(e.target.value))}>
|
|
716
|
+
{[5, 4, 3, 2, 1].map((n) => (
|
|
717
|
+
<option key={n} value={n}>
|
|
718
|
+
{n} / 5
|
|
719
|
+
</option>
|
|
720
|
+
))}
|
|
721
|
+
</select>
|
|
722
|
+
</label>
|
|
723
|
+
<label className="mp-label">
|
|
724
|
+
Commentaire
|
|
725
|
+
<textarea className="mp-input" rows={3} value={reviewBody} onChange={(e) => setReviewBody(e.target.value)} />
|
|
726
|
+
</label>
|
|
727
|
+
<button
|
|
728
|
+
type="button"
|
|
729
|
+
className="btn-mp"
|
|
730
|
+
style={{ marginTop: 12 }}
|
|
731
|
+
onClick={async () => {
|
|
732
|
+
try {
|
|
733
|
+
await api(`/api/marketplace/products/${product.id}/reviews`, {
|
|
734
|
+
method: 'POST',
|
|
735
|
+
body: JSON.stringify({ rating, body: reviewBody }),
|
|
736
|
+
});
|
|
737
|
+
const d = await api<{ product: Product }>(`/api/marketplace/products/${slug}`);
|
|
738
|
+
setProduct(d.product);
|
|
739
|
+
setReviewBody('');
|
|
740
|
+
setMsg('Avis publié');
|
|
741
|
+
} catch (e) {
|
|
742
|
+
setMsg(e instanceof ApiError ? e.message : 'Erreur');
|
|
743
|
+
}
|
|
744
|
+
}}
|
|
745
|
+
>
|
|
746
|
+
Publier l’avis
|
|
747
|
+
</button>
|
|
748
|
+
</div>
|
|
749
|
+
)}
|
|
750
|
+
</div>
|
|
751
|
+
)}
|
|
752
|
+
</div>
|
|
753
|
+
</div>
|
|
754
|
+
|
|
755
|
+
<aside className="mp-buybox">
|
|
756
|
+
<div style={{ display: 'flex', gap: 12, alignItems: 'flex-start' }}>
|
|
757
|
+
{mediaUrl(product.icon) ? (
|
|
758
|
+
<img src={product.icon} alt="" style={{ width: 56, height: 56, borderRadius: 12, objectFit: 'cover', border: '1px solid #e5e7eb', flexShrink: 0 }} />
|
|
759
|
+
) : null}
|
|
760
|
+
<div style={{ minWidth: 0 }}>
|
|
761
|
+
<div style={{ fontSize: 12, fontWeight: 700, textTransform: 'uppercase', letterSpacing: '.06em', color: '#6c6c6c' }}>
|
|
762
|
+
{product.kind === 'theme' ? 'Thème' : 'Module'} · {product.category}
|
|
763
|
+
</div>
|
|
764
|
+
<h1 style={{ margin: '8px 0 0', fontSize: '1.45rem', lineHeight: 1.3 }}>{product.name}</h1>
|
|
765
|
+
</div>
|
|
766
|
+
</div>
|
|
767
|
+
<div style={{ marginTop: 8, display: 'flex', gap: 10, alignItems: 'center' }}>
|
|
768
|
+
<Stars value={product.avgRating} count={product.reviews?.length} />
|
|
769
|
+
<span style={{ fontSize: 12, color: '#6c6c6c' }}>{product.salesCount} ventes</span>
|
|
770
|
+
</div>
|
|
771
|
+
<div className={`price-lg ${product.priceMillimes === 0 ? 'free' : ''}`} style={product.priceMillimes === 0 ? { color: '#00a89d' } : undefined}>
|
|
772
|
+
{product.priceMillimes === 0 ? 'Gratuit' : product.priceLabel}
|
|
773
|
+
</div>
|
|
774
|
+
<div className="tax">TTC · Paiement sécurisé Flouci</div>
|
|
775
|
+
<button
|
|
776
|
+
type="button"
|
|
777
|
+
className="mp-btn-buy"
|
|
778
|
+
disabled={busy}
|
|
779
|
+
onClick={async () => {
|
|
780
|
+
if (!user) return nav('/login');
|
|
781
|
+
setBusy(true);
|
|
782
|
+
setMsg('');
|
|
783
|
+
try {
|
|
784
|
+
await api('/api/marketplace/cart/add', { method: 'POST', body: JSON.stringify({ productId: product.id }) });
|
|
785
|
+
setMsg('Ajouté au panier');
|
|
786
|
+
} catch (e) {
|
|
787
|
+
setMsg(e instanceof ApiError ? e.message : 'Erreur');
|
|
788
|
+
} finally {
|
|
789
|
+
setBusy(false);
|
|
790
|
+
}
|
|
791
|
+
}}
|
|
792
|
+
>
|
|
793
|
+
Ajouter au panier
|
|
794
|
+
</button>
|
|
795
|
+
<button type="button" className="mp-btn-ghost" onClick={() => nav('/cart')}>
|
|
796
|
+
Voir mon panier
|
|
797
|
+
</button>
|
|
798
|
+
{msg && <p style={{ marginTop: 12, fontSize: 13, color: '#00a89d' }}>{msg}</p>}
|
|
799
|
+
<div style={{ marginTop: 20, paddingTop: 16, borderTop: '1px solid #e5e7eb', fontSize: 13, color: '#6c6c6c' }}>
|
|
800
|
+
<div>
|
|
801
|
+
Développé par <strong style={{ color: '#1d1d1b' }}>{product.publisher?.displayName || 'Community'}</strong>
|
|
802
|
+
</div>
|
|
803
|
+
{product.versions?.[0] && (
|
|
804
|
+
<div style={{ marginTop: 6 }}>
|
|
805
|
+
Version actuelle : <strong style={{ color: '#1d1d1b' }}>v{product.versions[0].version}</strong>
|
|
806
|
+
</div>
|
|
807
|
+
)}
|
|
808
|
+
<div style={{ marginTop: 6, display: 'flex', gap: 6, alignItems: 'center' }}>
|
|
809
|
+
<Shield className="h-3.5 w-3.5" /> Paquet contrôlé Snapify
|
|
810
|
+
</div>
|
|
811
|
+
</div>
|
|
812
|
+
</aside>
|
|
813
|
+
</div>
|
|
814
|
+
</div>
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function CartPage() {
|
|
819
|
+
const { user } = useAuth();
|
|
820
|
+
const nav = useNavigate();
|
|
821
|
+
const [items, setItems] = useState<Product[]>([]);
|
|
822
|
+
const [total, setTotal] = useState(0);
|
|
823
|
+
const [busy, setBusy] = useState(false);
|
|
824
|
+
const [err, setErr] = useState('');
|
|
825
|
+
|
|
826
|
+
useEffect(() => {
|
|
827
|
+
if (!user) return;
|
|
828
|
+
api<{ items: Product[]; totalMillimes: number }>('/api/marketplace/cart').then((d) => {
|
|
829
|
+
setItems(d.items);
|
|
830
|
+
setTotal(d.totalMillimes);
|
|
831
|
+
});
|
|
832
|
+
}, [user]);
|
|
833
|
+
|
|
834
|
+
if (!user) return <Navigate to="/login" replace />;
|
|
835
|
+
|
|
836
|
+
return (
|
|
837
|
+
<div className="mp-wrap" style={{ maxWidth: 860, paddingBottom: 48 }}>
|
|
838
|
+
<div className="mp-breadcrumb">
|
|
839
|
+
<Link to="/">Accueil</Link> / Panier
|
|
840
|
+
</div>
|
|
841
|
+
<h1 style={{ fontSize: '1.75rem', margin: '12px 0 20px' }}>Votre panier</h1>
|
|
842
|
+
{items.length === 0 ? (
|
|
843
|
+
<div className="mp-empty">
|
|
844
|
+
Votre panier est vide.
|
|
845
|
+
<div style={{ marginTop: 16 }}>
|
|
846
|
+
<Link to="/catalog" className="btn-mp">
|
|
847
|
+
Continuer vos achats
|
|
848
|
+
</Link>
|
|
849
|
+
</div>
|
|
850
|
+
</div>
|
|
851
|
+
) : (
|
|
852
|
+
<>
|
|
853
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
854
|
+
{items.map((p) => (
|
|
855
|
+
<div key={p.id} style={{ display: 'flex', gap: 14, border: '1px solid #e5e7eb', borderRadius: 8, padding: 12, alignItems: 'center' }}>
|
|
856
|
+
<div style={{ width: 72, height: 50, flexShrink: 0, background: '#eef6f5', borderRadius: 6, display: 'grid', placeItems: 'center', overflow: 'hidden' }}>
|
|
857
|
+
{coverOf(p) ? <img src={coverOf(p)!} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover' }} /> : <Package className="h-6 w-6 text-px-primary-dark" />}
|
|
858
|
+
</div>
|
|
859
|
+
<div style={{ flex: 1, minWidth: 0 }}>
|
|
860
|
+
<Link to={`/product/${p.slug}`} style={{ fontWeight: 700 }}>
|
|
861
|
+
{p.name}
|
|
862
|
+
</Link>
|
|
863
|
+
<div style={{ fontSize: 13, color: '#6c6c6c' }}>{p.kind === 'theme' ? 'Thème' : 'Module'}</div>
|
|
864
|
+
</div>
|
|
865
|
+
<strong>{p.priceMillimes === 0 ? 'Gratuit' : p.priceLabel}</strong>
|
|
866
|
+
</div>
|
|
867
|
+
))}
|
|
868
|
+
</div>
|
|
869
|
+
<div style={{ marginTop: 24, border: '1px solid #e5e7eb', borderRadius: 8, padding: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
|
|
870
|
+
<div>
|
|
871
|
+
<div style={{ fontSize: 13, color: '#6c6c6c' }}>Total TTC</div>
|
|
872
|
+
<div style={{ fontSize: '1.5rem', fontWeight: 800 }}>{formatMoney(total)}</div>
|
|
873
|
+
</div>
|
|
874
|
+
<button
|
|
875
|
+
type="button"
|
|
876
|
+
className="mp-btn-buy"
|
|
877
|
+
style={{ width: 'auto', minWidth: 200, padding: '0 24px' }}
|
|
878
|
+
disabled={busy}
|
|
879
|
+
onClick={async () => {
|
|
880
|
+
setBusy(true);
|
|
881
|
+
setErr('');
|
|
882
|
+
try {
|
|
883
|
+
const res = await api<{ orderId: string; status: string; link: string | null }>('/api/marketplace/checkout', {
|
|
884
|
+
method: 'POST',
|
|
885
|
+
body: '{}',
|
|
886
|
+
});
|
|
887
|
+
if (res.link && res.status !== 'paid') window.location.href = res.link;
|
|
888
|
+
else nav(`/checkout/success?order=${res.orderId}`);
|
|
889
|
+
} catch (e) {
|
|
890
|
+
setErr(e instanceof ApiError ? e.message : 'Erreur');
|
|
891
|
+
} finally {
|
|
892
|
+
setBusy(false);
|
|
893
|
+
}
|
|
894
|
+
}}
|
|
895
|
+
>
|
|
896
|
+
Payer avec Flouci
|
|
897
|
+
</button>
|
|
898
|
+
</div>
|
|
899
|
+
{err && <p style={{ color: '#dc2626', fontSize: 14 }}>{err}</p>}
|
|
900
|
+
</>
|
|
901
|
+
)}
|
|
902
|
+
</div>
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
function AuthPage({ mode }: { mode: 'login' | 'register' }) {
|
|
907
|
+
const { login, register, user } = useAuth();
|
|
908
|
+
const nav = useNavigate();
|
|
909
|
+
const [email, setEmail] = useState('');
|
|
910
|
+
const [password, setPassword] = useState('');
|
|
911
|
+
const [displayName, setDisplayName] = useState('');
|
|
912
|
+
const [err, setErr] = useState('');
|
|
913
|
+
if (user) return <Navigate to="/" replace />;
|
|
914
|
+
|
|
915
|
+
return (
|
|
916
|
+
<div className="mp-panel">
|
|
917
|
+
<h1 style={{ marginTop: 0, fontSize: '1.4rem' }}>{mode === 'login' ? 'Connexion' : 'Créer un compte'}</h1>
|
|
918
|
+
<p style={{ color: '#6c6c6c', fontSize: 14, marginTop: 4 }}>Compte partagé Community + Marketplace</p>
|
|
919
|
+
<form
|
|
920
|
+
onSubmit={async (e) => {
|
|
921
|
+
e.preventDefault();
|
|
922
|
+
setErr('');
|
|
923
|
+
try {
|
|
924
|
+
if (mode === 'login') await login(email, password);
|
|
925
|
+
else await register(email, password, displayName);
|
|
926
|
+
nav('/');
|
|
927
|
+
} catch (ex) {
|
|
928
|
+
setErr(ex instanceof ApiError ? ex.message : 'Erreur');
|
|
929
|
+
}
|
|
930
|
+
}}
|
|
931
|
+
>
|
|
932
|
+
{mode === 'register' && (
|
|
933
|
+
<label className="mp-label">
|
|
934
|
+
Nom affiché
|
|
935
|
+
<input className="mp-input" value={displayName} onChange={(e) => setDisplayName(e.target.value)} required />
|
|
936
|
+
</label>
|
|
937
|
+
)}
|
|
938
|
+
<label className="mp-label">
|
|
939
|
+
E-mail
|
|
940
|
+
<input className="mp-input" type="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
|
|
941
|
+
</label>
|
|
942
|
+
<label className="mp-label">
|
|
943
|
+
Mot de passe
|
|
944
|
+
<input className="mp-input" type="password" value={password} onChange={(e) => setPassword(e.target.value)} required />
|
|
945
|
+
</label>
|
|
946
|
+
{err && <p style={{ color: '#dc2626', fontSize: 13 }}>{err}</p>}
|
|
947
|
+
<button type="submit" className="mp-btn-buy" style={{ marginTop: 18 }}>
|
|
948
|
+
{mode === 'login' ? 'Se connecter' : 'S’inscrire'}
|
|
949
|
+
</button>
|
|
950
|
+
</form>
|
|
951
|
+
<p style={{ textAlign: 'center', marginTop: 16, fontSize: 14 }}>
|
|
952
|
+
{mode === 'login' ? <Link to="/register">Créer un compte</Link> : <Link to="/login">Déjà inscrit ?</Link>}
|
|
953
|
+
</p>
|
|
954
|
+
</div>
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function AccountPage() {
|
|
959
|
+
const { user } = useAuth();
|
|
960
|
+
const [orders, setOrders] = useState<
|
|
961
|
+
{ id: string; status: string; totalLabel: string; items: { licenseKey: string; downloadToken: string | null; product: Product | null }[] }[]
|
|
962
|
+
>([]);
|
|
963
|
+
useEffect(() => {
|
|
964
|
+
if (user) api<{ items: typeof orders }>('/api/marketplace/orders/mine').then((d) => setOrders(d.items));
|
|
965
|
+
}, [user]);
|
|
966
|
+
if (!user) return <Navigate to="/login" replace />;
|
|
967
|
+
|
|
968
|
+
return (
|
|
969
|
+
<div className="mp-wrap" style={{ maxWidth: 900, paddingBottom: 48 }}>
|
|
970
|
+
<div className="mp-breadcrumb">
|
|
971
|
+
<Link to="/">Accueil</Link> / Mes achats
|
|
972
|
+
</div>
|
|
973
|
+
<h1 style={{ fontSize: '1.75rem' }}>Mes achats & licences</h1>
|
|
974
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, marginTop: 16 }}>
|
|
975
|
+
{orders.map((o) => (
|
|
976
|
+
<div key={o.id} style={{ border: '1px solid #e5e7eb', borderRadius: 8, padding: 16 }}>
|
|
977
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 13, color: '#6c6c6c' }}>
|
|
978
|
+
<span>Commande {o.id.slice(0, 8)}…</span>
|
|
979
|
+
<span>
|
|
980
|
+
{o.status} · {o.totalLabel}
|
|
981
|
+
</span>
|
|
982
|
+
</div>
|
|
983
|
+
{o.items.map((it, i) => (
|
|
984
|
+
<div key={i} style={{ display: 'flex', justifyContent: 'space-between', gap: 12, marginTop: 12, paddingTop: 12, borderTop: '1px solid #f1f5f9', flexWrap: 'wrap' }}>
|
|
985
|
+
<strong>{it.product?.name}</strong>
|
|
986
|
+
<span style={{ fontSize: 13, color: '#6c6c6c' }}>Licence {it.licenseKey}</span>
|
|
987
|
+
{it.downloadToken && (
|
|
988
|
+
<a href={`/api/marketplace/downloads/${it.downloadToken}`} style={{ color: '#0066ee', fontWeight: 600, fontSize: 13 }}>
|
|
989
|
+
Télécharger
|
|
990
|
+
</a>
|
|
991
|
+
)}
|
|
992
|
+
</div>
|
|
993
|
+
))}
|
|
994
|
+
</div>
|
|
995
|
+
))}
|
|
996
|
+
{!orders.length && <div className="mp-empty">Aucun achat pour le moment.</div>}
|
|
997
|
+
</div>
|
|
998
|
+
</div>
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function DeveloperLanding() {
|
|
1003
|
+
const { user } = useAuth();
|
|
1004
|
+
const [fee, setFee] = useState(() => formatMoney(100000));
|
|
1005
|
+
const [busy, setBusy] = useState(false);
|
|
1006
|
+
const [err, setErr] = useState('');
|
|
1007
|
+
const [name, setName] = useState(user?.displayName || '');
|
|
1008
|
+
|
|
1009
|
+
useEffect(() => {
|
|
1010
|
+
api<{ developerFeeLabel: string }>('/api/marketplace/settings/public')
|
|
1011
|
+
.then((d) => setFee(d.developerFeeLabel))
|
|
1012
|
+
.catch(() => setFee(formatMoney(100000)));
|
|
1013
|
+
}, []);
|
|
1014
|
+
|
|
1015
|
+
return (
|
|
1016
|
+
<div>
|
|
1017
|
+
<section className="mp-hero" style={{ paddingBottom: 64 }}>
|
|
1018
|
+
<h1>Devenez développeur Snapify</h1>
|
|
1019
|
+
<p>Publiez vos modules et thèmes sur la marketplace. Inscription unique : {fee}.</p>
|
|
1020
|
+
<a href="https://developers.snapify.tn" className="mp-dev-docs-link">
|
|
1021
|
+
Lire la documentation développeur →
|
|
1022
|
+
</a>
|
|
1023
|
+
</section>
|
|
1024
|
+
<div className="mp-wrap" style={{ maxWidth: 720, marginTop: -32, position: 'relative', zIndex: 2, paddingBottom: 48 }}>
|
|
1025
|
+
<div style={{ background: '#fff', border: '1px solid #e5e7eb', borderRadius: 8, padding: 28, boxShadow: '0 12px 40px rgba(0,0,0,.08)' }}>
|
|
1026
|
+
<div className="mp-trust" style={{ border: 'none', padding: '0 0 24px', gridTemplateColumns: '1fr' }}>
|
|
1027
|
+
<div className="mp-trust-item">
|
|
1028
|
+
<div className="mp-trust-icon">
|
|
1029
|
+
<Upload className="h-5 w-5" />
|
|
1030
|
+
</div>
|
|
1031
|
+
<div>
|
|
1032
|
+
<strong>Publiez sans limite</strong>
|
|
1033
|
+
<span>Uploadez des paquets .snapmod / .snaptheme, versions et changelogs.</span>
|
|
1034
|
+
</div>
|
|
1035
|
+
</div>
|
|
1036
|
+
<div className="mp-trust-item">
|
|
1037
|
+
<div className="mp-trust-icon">
|
|
1038
|
+
<BadgeCheck className="h-5 w-5" />
|
|
1039
|
+
</div>
|
|
1040
|
+
<div>
|
|
1041
|
+
<strong>Revenus nets</strong>
|
|
1042
|
+
<span>Snapify prélève 30 % de commission sur chaque vente.</span>
|
|
1043
|
+
</div>
|
|
1044
|
+
</div>
|
|
1045
|
+
</div>
|
|
1046
|
+
{!user ? (
|
|
1047
|
+
<Link to="/login" className="btn-mp">
|
|
1048
|
+
Connectez-vous pour continuer
|
|
1049
|
+
</Link>
|
|
1050
|
+
) : user.role === 'publisher' || user.role === 'admin' ? (
|
|
1051
|
+
<Link to="/developer/dashboard" className="btn-mp">
|
|
1052
|
+
Accéder au dashboard vendeur
|
|
1053
|
+
</Link>
|
|
1054
|
+
) : (
|
|
1055
|
+
<>
|
|
1056
|
+
<label className="mp-label">
|
|
1057
|
+
Nom éditeur
|
|
1058
|
+
<input className="mp-input" value={name} onChange={(e) => setName(e.target.value)} />
|
|
1059
|
+
</label>
|
|
1060
|
+
<button
|
|
1061
|
+
type="button"
|
|
1062
|
+
className="mp-btn-buy"
|
|
1063
|
+
style={{ marginTop: 16 }}
|
|
1064
|
+
disabled={busy}
|
|
1065
|
+
onClick={async () => {
|
|
1066
|
+
setBusy(true);
|
|
1067
|
+
setErr('');
|
|
1068
|
+
try {
|
|
1069
|
+
const res = await api<{ link: string }>('/api/marketplace/developer/register', {
|
|
1070
|
+
method: 'POST',
|
|
1071
|
+
body: JSON.stringify({ displayName: name }),
|
|
1072
|
+
});
|
|
1073
|
+
if (res.link) window.location.href = res.link;
|
|
1074
|
+
} catch (e) {
|
|
1075
|
+
setErr(e instanceof ApiError ? e.message : 'Erreur');
|
|
1076
|
+
} finally {
|
|
1077
|
+
setBusy(false);
|
|
1078
|
+
}
|
|
1079
|
+
}}
|
|
1080
|
+
>
|
|
1081
|
+
Payer {fee} avec Flouci
|
|
1082
|
+
</button>
|
|
1083
|
+
{err && <p style={{ color: '#dc2626', fontSize: 13 }}>{err}</p>}
|
|
1084
|
+
</>
|
|
1085
|
+
)}
|
|
1086
|
+
</div>
|
|
1087
|
+
</div>
|
|
1088
|
+
</div>
|
|
1089
|
+
);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
function AdminPage() {
|
|
1093
|
+
const { user } = useAuth();
|
|
1094
|
+
const [pending, setPending] = useState<Product[]>([]);
|
|
1095
|
+
const [settings, setSettings] = useState({ commissionBps: 3000, developerFeeMillimes: 100000, flouciPublicKey: '' });
|
|
1096
|
+
const [msg, setMsg] = useState('');
|
|
1097
|
+
|
|
1098
|
+
const load = async () => {
|
|
1099
|
+
setPending((await api<{ items: Product[] }>('/api/marketplace/admin/products?status=pending')).items);
|
|
1100
|
+
setSettings(await api<typeof settings>('/api/marketplace/admin/settings'));
|
|
1101
|
+
};
|
|
1102
|
+
useEffect(() => {
|
|
1103
|
+
if (user?.role === 'admin') void load();
|
|
1104
|
+
}, [user]);
|
|
1105
|
+
|
|
1106
|
+
if (!user) return <Navigate to="/login" replace />;
|
|
1107
|
+
if (user.role !== 'admin') return <Navigate to="/" replace />;
|
|
1108
|
+
|
|
1109
|
+
return (
|
|
1110
|
+
<div className="mp-wrap" style={{ maxWidth: 900, paddingBottom: 48 }}>
|
|
1111
|
+
<h1>Admin marketplace</h1>
|
|
1112
|
+
<div style={{ border: '1px solid #e5e7eb', borderRadius: 8, padding: 20, marginTop: 16 }}>
|
|
1113
|
+
<h2 style={{ marginTop: 0, fontSize: '1.05rem' }}>Réglages</h2>
|
|
1114
|
+
<label className="mp-label">
|
|
1115
|
+
Commission (%)
|
|
1116
|
+
<input
|
|
1117
|
+
className="mp-input"
|
|
1118
|
+
type="number"
|
|
1119
|
+
min={0}
|
|
1120
|
+
max={90}
|
|
1121
|
+
step={0.5}
|
|
1122
|
+
value={settings.commissionBps / 100}
|
|
1123
|
+
onChange={(e) => setSettings({ ...settings, commissionBps: Math.round(Number(e.target.value) * 100) })}
|
|
1124
|
+
/>
|
|
1125
|
+
</label>
|
|
1126
|
+
<label className="mp-label">
|
|
1127
|
+
Frais d’inscription développeur
|
|
1128
|
+
<DtInput millimes={settings.developerFeeMillimes} onMillimes={(m) => setSettings({ ...settings, developerFeeMillimes: m })} />
|
|
1129
|
+
</label>
|
|
1130
|
+
<label className="mp-label">
|
|
1131
|
+
Flouci public key
|
|
1132
|
+
<input className="mp-input" value={settings.flouciPublicKey} onChange={(e) => setSettings({ ...settings, flouciPublicKey: e.target.value })} />
|
|
1133
|
+
</label>
|
|
1134
|
+
<button
|
|
1135
|
+
type="button"
|
|
1136
|
+
className="btn-mp"
|
|
1137
|
+
style={{ marginTop: 14 }}
|
|
1138
|
+
onClick={async () => {
|
|
1139
|
+
await api('/api/marketplace/admin/settings', { method: 'PUT', body: JSON.stringify(settings) });
|
|
1140
|
+
setMsg('Enregistré');
|
|
1141
|
+
}}
|
|
1142
|
+
>
|
|
1143
|
+
Sauver
|
|
1144
|
+
</button>
|
|
1145
|
+
</div>
|
|
1146
|
+
<h2 style={{ marginTop: 28 }}>Produits en attente</h2>
|
|
1147
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
1148
|
+
{pending.map((p) => (
|
|
1149
|
+
<div key={p.id} style={{ display: 'flex', justifyContent: 'space-between', gap: 12, border: '1px solid #e5e7eb', borderRadius: 8, padding: 14, alignItems: 'center' }}>
|
|
1150
|
+
<div>
|
|
1151
|
+
<strong>{p.name}</strong>
|
|
1152
|
+
<div style={{ fontSize: 13, color: '#6c6c6c' }}>{p.slug}</div>
|
|
1153
|
+
</div>
|
|
1154
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
1155
|
+
<button
|
|
1156
|
+
type="button"
|
|
1157
|
+
className="btn-mp"
|
|
1158
|
+
onClick={async () => {
|
|
1159
|
+
await api(`/api/marketplace/admin/products/${p.id}/review`, { method: 'POST', body: JSON.stringify({ action: 'approve' }) });
|
|
1160
|
+
void load();
|
|
1161
|
+
}}
|
|
1162
|
+
>
|
|
1163
|
+
Approuver
|
|
1164
|
+
</button>
|
|
1165
|
+
<button
|
|
1166
|
+
type="button"
|
|
1167
|
+
className="mp-btn-ghost"
|
|
1168
|
+
style={{ width: 'auto', padding: '0 14px', color: '#dc2626' }}
|
|
1169
|
+
onClick={async () => {
|
|
1170
|
+
await api(`/api/marketplace/admin/products/${p.id}/review`, { method: 'POST', body: JSON.stringify({ action: 'reject', reason: 'Non conforme' }) });
|
|
1171
|
+
void load();
|
|
1172
|
+
}}
|
|
1173
|
+
>
|
|
1174
|
+
Rejeter
|
|
1175
|
+
</button>
|
|
1176
|
+
</div>
|
|
1177
|
+
</div>
|
|
1178
|
+
))}
|
|
1179
|
+
{!pending.length && <div className="mp-empty">Aucune soumission.</div>}
|
|
1180
|
+
</div>
|
|
1181
|
+
{msg && <p style={{ color: '#00a89d' }}>{msg}</p>}
|
|
1182
|
+
</div>
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
function SuccessPage() {
|
|
1187
|
+
const [params] = useSearchParams();
|
|
1188
|
+
return (
|
|
1189
|
+
<div className="mp-wrap" style={{ maxWidth: 520, textAlign: 'center', padding: '64px 20px' }}>
|
|
1190
|
+
<BadgeCheck className="mx-auto h-14 w-14 text-px-primary-dark" />
|
|
1191
|
+
<h1 style={{ fontSize: '1.75rem' }}>Paiement réussi</h1>
|
|
1192
|
+
<p style={{ color: '#6c6c6c' }}>Référence {params.get('order') || params.get('publisher') || ''} confirmée.</p>
|
|
1193
|
+
<Link to="/account" className="btn-mp" style={{ marginTop: 16, display: 'inline-flex' }}>
|
|
1194
|
+
Voir mes achats
|
|
1195
|
+
</Link>
|
|
1196
|
+
</div>
|
|
1197
|
+
);
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
export function App() {
|
|
1201
|
+
return (
|
|
1202
|
+
<Routes>
|
|
1203
|
+
{/* Dashboard développeur : layout plein écran (hors shell marketplace) */}
|
|
1204
|
+
<Route path="/developer/dashboard/*" element={<DeveloperRoutes />} />
|
|
1205
|
+
<Route
|
|
1206
|
+
path="*"
|
|
1207
|
+
element={
|
|
1208
|
+
<Shell>
|
|
1209
|
+
<Routes>
|
|
1210
|
+
<Route path="/" element={<Home />} />
|
|
1211
|
+
<Route path="/catalog" element={<Catalog />} />
|
|
1212
|
+
<Route path="/product/:slug" element={<ProductPage />} />
|
|
1213
|
+
<Route path="/cart" element={<CartPage />} />
|
|
1214
|
+
<Route path="/login" element={<AuthPage mode="login" />} />
|
|
1215
|
+
<Route path="/register" element={<AuthPage mode="register" />} />
|
|
1216
|
+
<Route path="/account" element={<AccountPage />} />
|
|
1217
|
+
<Route path="/developer" element={<DeveloperLanding />} />
|
|
1218
|
+
<Route path="/developer/register/success" element={<SuccessPage />} />
|
|
1219
|
+
<Route path="/checkout/success" element={<SuccessPage />} />
|
|
1220
|
+
<Route path="/checkout/fail" element={<div className="mp-wrap py-16 text-center">Paiement échoué</div>} />
|
|
1221
|
+
<Route path="/admin" element={<AdminPage />} />
|
|
1222
|
+
<Route path="*" element={<Navigate to="/" replace />} />
|
|
1223
|
+
</Routes>
|
|
1224
|
+
</Shell>
|
|
1225
|
+
}
|
|
1226
|
+
/>
|
|
1227
|
+
</Routes>
|
|
1228
|
+
);
|
|
1229
|
+
}
|