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,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapify
|
|
3
|
+
* © 2026 NOVALABS WEB DESIGN — Tunisie
|
|
4
|
+
* Contact : contact@novalabs.tn · +216 24 734 647
|
|
5
|
+
* Tous droits réservés. Toute reproduction, modification ou diffusion sans autorisation écrite est interdite.
|
|
6
|
+
*/
|
|
7
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { CheckCircle2, Database, Gauge, Globe2, Image as ImageIcon, Mail, Server, ShieldCheck, XCircle } from 'lucide-react';
|
|
9
|
+
import { useSearchParams } from 'react-router-dom';
|
|
10
|
+
import { api, type SystemMeta, type SystemView } from '../lib/api';
|
|
11
|
+
import { useAsync, useEditable } from '../lib/hooks';
|
|
12
|
+
import { useSite, useSiteData } from '../context/SiteContext';
|
|
13
|
+
import { ErrorState, Field, Input, PageHeader, PageSkeleton, Section, Switch, Tabs } from '../ui/primitives';
|
|
14
|
+
import { SaveBar } from '../ui/SaveBar';
|
|
15
|
+
import { firstFormError, type SystemForm, type TabProps } from '../settings/controls';
|
|
16
|
+
import { EmailTab } from '../settings/EmailTab';
|
|
17
|
+
import { SecurityTab } from '../settings/SecurityTab';
|
|
18
|
+
import { DataTab, LimitsTab, MediaTab, SystemTab } from '../settings/OtherTabs';
|
|
19
|
+
|
|
20
|
+
interface SiteState {
|
|
21
|
+
publicUrl: string;
|
|
22
|
+
cookieBannerEnabled: boolean;
|
|
23
|
+
analyticsEnabled: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface FormState {
|
|
26
|
+
site: SiteState;
|
|
27
|
+
system: SystemForm;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type TabId = 'general' | 'email' | 'security' | 'limits' | 'media' | 'data' | 'system';
|
|
31
|
+
|
|
32
|
+
const TABS: { value: TabId; label: string; icon: typeof Globe2; keys: (keyof SystemForm | 'site')[] }[] = [
|
|
33
|
+
{ value: 'general', label: 'Général', icon: Globe2, keys: ['site'] },
|
|
34
|
+
{ value: 'email', label: 'E-mails', icon: Mail, keys: ['smtp', 'notifications'] },
|
|
35
|
+
{ value: 'security', label: 'Sécurité', icon: ShieldCheck, keys: ['security'] },
|
|
36
|
+
{ value: 'limits', label: 'Limites', icon: Gauge, keys: ['limits'] },
|
|
37
|
+
{ value: 'media', label: 'Médias', icon: ImageIcon, keys: ['uploads'] },
|
|
38
|
+
{ value: 'data', label: 'Données', icon: Database, keys: ['privacy'] },
|
|
39
|
+
{ value: 'system', label: 'Système', icon: Server, keys: ['performance'] },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const toForm = (s: SystemView): SystemForm => ({ ...s, smtp: { ...s.smtp, password: '', clearPassword: false } });
|
|
43
|
+
|
|
44
|
+
function validUrl(url: string) {
|
|
45
|
+
try {
|
|
46
|
+
return /^https?:$/.test(new URL(url).protocol);
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function GeneralTab({ s, patch, meta }: { s: SiteState; patch: (p: Partial<SiteState>) => void; meta: SystemMeta }) {
|
|
53
|
+
const { data: dash } = useAsync(() => api.dashboard(), []);
|
|
54
|
+
const services = [
|
|
55
|
+
{ ok: meta.smtpSource !== 'none', label: 'Envoi d’e-mails (SMTP)', detail: meta.smtpSource === 'settings' ? 'Onglet E-mails' : meta.smtpSource === 'env' ? 'Fichier .env' : 'Non configuré' },
|
|
56
|
+
{ ok: !!dash?.health?.googleOAuthConfigured, label: 'Connexion Google (Search Console)', detail: 'SEO › Google Search Console' },
|
|
57
|
+
{ ok: !!dash?.health?.gemini, label: 'Assistant IA (Gemini)', detail: 'GEMINI_API_KEY' },
|
|
58
|
+
{ ok: !!meta.dedicatedSecretKey, label: 'Clé de chiffrement dédiée', detail: 'SNAPIFY_SECRET_KEY' },
|
|
59
|
+
];
|
|
60
|
+
return (
|
|
61
|
+
<div className="grid gap-6 xl:grid-cols-2">
|
|
62
|
+
<div className="space-y-6">
|
|
63
|
+
<Section title="Adresse du site">
|
|
64
|
+
<Field
|
|
65
|
+
label="URL publique"
|
|
66
|
+
hint="Utilisée pour le sitemap, les liens canoniques, les aperçus de partage et les liens des e-mails."
|
|
67
|
+
error={s.publicUrl && !validUrl(s.publicUrl) ? 'URL invalide (ex. https://www.snapify.fr)' : undefined}
|
|
68
|
+
>
|
|
69
|
+
<Input value={s.publicUrl} onChange={(e) => patch({ publicUrl: e.target.value })} placeholder="https://www.snapify.fr" />
|
|
70
|
+
</Field>
|
|
71
|
+
</Section>
|
|
72
|
+
<Section title="Confidentialité et mesure d’audience">
|
|
73
|
+
<Switch
|
|
74
|
+
checked={s.analyticsEnabled}
|
|
75
|
+
onChange={(analyticsEnabled) => patch({ analyticsEnabled })}
|
|
76
|
+
label="Statistiques de visite"
|
|
77
|
+
description="Mesure d’audience interne, anonyme et hébergée sur votre serveur (aucun cookie tiers)."
|
|
78
|
+
/>
|
|
79
|
+
<Switch
|
|
80
|
+
checked={s.cookieBannerEnabled}
|
|
81
|
+
onChange={(cookieBannerEnabled) => patch({ cookieBannerEnabled })}
|
|
82
|
+
label="Bandeau de consentement aux cookies"
|
|
83
|
+
description="Affiche le bandeau d’information RGPD aux nouveaux visiteurs."
|
|
84
|
+
/>
|
|
85
|
+
</Section>
|
|
86
|
+
</div>
|
|
87
|
+
<Section title="Services connectés" description="État des intégrations. Les clés techniques se règlent dans le fichier .env du serveur.">
|
|
88
|
+
<ul className="divide-y divide-slate-100">
|
|
89
|
+
{services.map((sv) => (
|
|
90
|
+
<li key={sv.label} className="flex items-start gap-3 py-3">
|
|
91
|
+
{sv.ok ? <CheckCircle2 className="mt-0.5 h-4 w-4 text-emerald-500" /> : <XCircle className="mt-0.5 h-4 w-4 text-slate-300" />}
|
|
92
|
+
<div className="flex-1">
|
|
93
|
+
<p className="text-sm font-medium text-slate-800">{sv.label}</p>
|
|
94
|
+
<p className="font-mono text-[11px] text-slate-400">{sv.detail}</p>
|
|
95
|
+
</div>
|
|
96
|
+
<span className={sv.ok ? 'text-xs font-medium text-emerald-600' : 'text-xs text-slate-400'}>{sv.ok ? 'Actif' : 'Inactif'}</span>
|
|
97
|
+
</li>
|
|
98
|
+
))}
|
|
99
|
+
</ul>
|
|
100
|
+
</Section>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default function SettingsPage() {
|
|
106
|
+
const site = useSiteData();
|
|
107
|
+
const { patchSite } = useSite();
|
|
108
|
+
const [params, setParams] = useSearchParams();
|
|
109
|
+
const tab = (TABS.some((t) => t.value === params.get('tab')) ? params.get('tab') : 'general') as TabId;
|
|
110
|
+
const setTab = (t: TabId) => setParams(t === 'general' ? {} : { tab: t }, { replace: true });
|
|
111
|
+
|
|
112
|
+
const sys = useAsync(() => api.system.get(), []);
|
|
113
|
+
const [meta, setMeta] = useState<SystemMeta | null>(null);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (sys.data) setMeta((m) => ({ ...m, ...sys.data!.meta }));
|
|
116
|
+
}, [sys.data]);
|
|
117
|
+
|
|
118
|
+
const initial = useMemo<FormState | null>(
|
|
119
|
+
() =>
|
|
120
|
+
sys.data
|
|
121
|
+
? {
|
|
122
|
+
site: { publicUrl: site.settings.publicUrl, cookieBannerEnabled: site.settings.cookieBannerEnabled, analyticsEnabled: site.settings.analyticsEnabled },
|
|
123
|
+
system: toForm(sys.data.system),
|
|
124
|
+
}
|
|
125
|
+
: null,
|
|
126
|
+
[sys.data, site.settings]
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const save = useCallback(
|
|
130
|
+
async (f: FormState) => {
|
|
131
|
+
const err = firstFormError(f.system);
|
|
132
|
+
if (err) throw new Error(err);
|
|
133
|
+
const publicUrl = f.site.publicUrl.trim().replace(/\/+$/, '');
|
|
134
|
+
if (publicUrl && !validUrl(publicUrl)) throw new Error('URL publique invalide (ex. https://www.snapify.fr)');
|
|
135
|
+
if (!initial) return f;
|
|
136
|
+
|
|
137
|
+
let system = f.system;
|
|
138
|
+
if (JSON.stringify(f.system) !== JSON.stringify(initial.system)) {
|
|
139
|
+
const { password, clearPassword, hasPassword: _h, ...smtp } = f.system.smtp;
|
|
140
|
+
const r = await api.system.save({ ...f.system, smtp: { ...smtp, password: password || undefined, clearPassword } });
|
|
141
|
+
system = toForm(r.system);
|
|
142
|
+
sys.setData({ system: r.system, meta: { ...(meta ?? r.meta), ...r.meta } });
|
|
143
|
+
}
|
|
144
|
+
const nextSite = { ...f.site, publicUrl };
|
|
145
|
+
if (JSON.stringify(nextSite) !== JSON.stringify(initial.site)) {
|
|
146
|
+
await api.saveSection('settings', nextSite);
|
|
147
|
+
patchSite('settings', { ...site.settings, ...nextSite });
|
|
148
|
+
}
|
|
149
|
+
return { site: nextSite, system };
|
|
150
|
+
},
|
|
151
|
+
[initial, meta, sys, patchSite, site.settings]
|
|
152
|
+
);
|
|
153
|
+
const ed = useEditable<FormState>(initial, save, { successMessage: 'Paramètres enregistrés' });
|
|
154
|
+
|
|
155
|
+
if (sys.error && !sys.data) return <ErrorState message={sys.error} onRetry={() => void sys.reload()} />;
|
|
156
|
+
if (!ed.value || !meta || !initial) return <PageSkeleton />;
|
|
157
|
+
const f = ed.value;
|
|
158
|
+
|
|
159
|
+
const set: TabProps['set'] = (key, p) => ed.setValue((cur) => (cur ? { ...cur, system: { ...cur.system, [key]: { ...cur.system[key], ...p } } } : cur));
|
|
160
|
+
const patchSiteState = (p: Partial<SiteState>) => ed.setValue((cur) => (cur ? { ...cur, site: { ...cur.site, ...p } } : cur));
|
|
161
|
+
const changed = (k: keyof SystemForm | 'site') =>
|
|
162
|
+
k === 'site' ? JSON.stringify(f.site) !== JSON.stringify(initial.site) : JSON.stringify(f.system[k]) !== JSON.stringify(initial.system[k]);
|
|
163
|
+
|
|
164
|
+
const props: TabProps = { v: f.system, set, meta };
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div className="space-y-6">
|
|
168
|
+
<PageHeader title="Paramètres" description="Réglages techniques du site et de l’administration : e-mails, sécurité, limites, médias et données." />
|
|
169
|
+
<Tabs<TabId>
|
|
170
|
+
value={tab}
|
|
171
|
+
onChange={setTab}
|
|
172
|
+
tabs={TABS.map((t) => ({
|
|
173
|
+
value: t.value,
|
|
174
|
+
label: t.label,
|
|
175
|
+
icon: t.icon,
|
|
176
|
+
badge: t.keys.some(changed) ? <span className="h-1.5 w-1.5 rounded-full bg-amber-500" title="Modifications non enregistrées" /> : undefined,
|
|
177
|
+
}))}
|
|
178
|
+
/>
|
|
179
|
+
{tab === 'general' ? <GeneralTab s={f.site} patch={patchSiteState} meta={meta} /> : null}
|
|
180
|
+
{tab === 'email' ? <EmailTab {...props} /> : null}
|
|
181
|
+
{tab === 'security' ? <SecurityTab {...props} /> : null}
|
|
182
|
+
{tab === 'limits' ? <LimitsTab {...props} /> : null}
|
|
183
|
+
{tab === 'media' ? <MediaTab {...props} /> : null}
|
|
184
|
+
{tab === 'data' ? <DataTab {...props} dirty={ed.dirty} /> : null}
|
|
185
|
+
{tab === 'system' ? <SystemTab v={f.system} set={set} /> : null}
|
|
186
|
+
<SaveBar dirty={ed.dirty} saving={ed.saving} onSave={ed.commit} onReset={ed.reset} blocker={ed.blocker} />
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapify
|
|
3
|
+
* © 2026 NOVALABS WEB DESIGN — Tunisie
|
|
4
|
+
* Contact : contact@novalabs.tn · +216 24 734 647
|
|
5
|
+
* Tous droits réservés. Toute reproduction, modification ou diffusion sans autorisation écrite est interdite.
|
|
6
|
+
*/
|
|
7
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
8
|
+
import { Link, useSearchParams } from 'react-router-dom';
|
|
9
|
+
import { CheckCircle2, Eye, RotateCcw, ShieldAlert, SlidersHorizontal } from 'lucide-react';
|
|
10
|
+
import { toast } from 'sonner';
|
|
11
|
+
import type { SettingField } from '../../../sdk/index';
|
|
12
|
+
import { useAuth } from '../context/AuthContext';
|
|
13
|
+
import { useSiteData } from '../context/SiteContext';
|
|
14
|
+
import { api, ApiError } from '../lib/api';
|
|
15
|
+
import { errorMessage, useAsync, useEditable } from '../lib/hooks';
|
|
16
|
+
import { Alert, Badge, Button, EmptyState, ErrorState, PageHeader, PageSkeleton, Select } from '../ui/primitives';
|
|
17
|
+
import { SaveBar } from '../ui/SaveBar';
|
|
18
|
+
import { DeviceSwitch, PreviewFrame, type Device } from '../editor/PreviewFrame';
|
|
19
|
+
import { SettingsForm } from '../modules/SettingsForm';
|
|
20
|
+
|
|
21
|
+
type Settings = Record<string, unknown>;
|
|
22
|
+
|
|
23
|
+
const defaults = (schema: SettingField[]): Settings => Object.fromEntries(schema.map((f) => [f.key, f.default]));
|
|
24
|
+
|
|
25
|
+
export default function ThemeCustomizePage() {
|
|
26
|
+
const [params, setParams] = useSearchParams();
|
|
27
|
+
const { can } = useAuth();
|
|
28
|
+
const isSuper = can('appearance.themes');
|
|
29
|
+
const site = useSiteData();
|
|
30
|
+
const list = useAsync(() => api.themes.list(), []);
|
|
31
|
+
const themes = list.data?.themes ?? [];
|
|
32
|
+
const themeId = params.get('theme') || themes.find((t) => t.active)?.id || '';
|
|
33
|
+
const detail = useAsync(() => (themeId ? api.themes.detail(themeId) : Promise.resolve(null)), [themeId]);
|
|
34
|
+
const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});
|
|
35
|
+
const [path, setPath] = useState('/');
|
|
36
|
+
const [device, setDevice] = useState<Device>('desktop');
|
|
37
|
+
const [activating, setActivating] = useState(false);
|
|
38
|
+
|
|
39
|
+
const initial = useMemo(() => detail.data?.settings ?? null, [detail.data?.settings]);
|
|
40
|
+
const save = useCallback(
|
|
41
|
+
async (value: Settings) => {
|
|
42
|
+
try {
|
|
43
|
+
const r = await api.themes.saveSettings(themeId, value);
|
|
44
|
+
setFieldErrors({});
|
|
45
|
+
return r.settings;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (e instanceof ApiError && e.fields) setFieldErrors(e.fields);
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[themeId]
|
|
52
|
+
);
|
|
53
|
+
const ed = useEditable<Settings>(initial, save, { successMessage: 'Options du thème enregistrées' });
|
|
54
|
+
|
|
55
|
+
const t = detail.data;
|
|
56
|
+
const payload = useMemo(() => (t?.descriptor ? { theme: { descriptor: t.descriptor, settings: ed.value ?? t.settings } } : {}), [t?.descriptor, t?.settings, ed.value]);
|
|
57
|
+
|
|
58
|
+
const pages = site.pages
|
|
59
|
+
.filter((p) => p.status === 'published')
|
|
60
|
+
.sort((x, y) => x.path.localeCompare(y.path))
|
|
61
|
+
.map((p) => ({ value: p.path, label: p.path === '/' ? 'Accueil' : p.title }));
|
|
62
|
+
|
|
63
|
+
const activate = async () => {
|
|
64
|
+
if (!t) return;
|
|
65
|
+
setActivating(true);
|
|
66
|
+
try {
|
|
67
|
+
if (ed.dirty && !(await ed.commit())) return;
|
|
68
|
+
await api.themes.activate(t.id);
|
|
69
|
+
toast.success(`${t.name} est maintenant le thème du site`);
|
|
70
|
+
detail.reload();
|
|
71
|
+
list.reload();
|
|
72
|
+
} catch (e) {
|
|
73
|
+
toast.error(errorMessage(e));
|
|
74
|
+
} finally {
|
|
75
|
+
setActivating(false);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if ((list.loading && !list.data) || (detail.loading && !detail.data)) return <PageSkeleton />;
|
|
80
|
+
if (list.error && !list.data) return <ErrorState message={list.error} onRetry={list.reload} />;
|
|
81
|
+
if (!themeId) {
|
|
82
|
+
return <EmptyState icon={SlidersHorizontal} title="Aucun thème actif" description="Installez puis activez un thème depuis Apparence > Thèmes." />;
|
|
83
|
+
}
|
|
84
|
+
if (detail.error && !detail.data) return <ErrorState message={detail.error} onRetry={detail.reload} />;
|
|
85
|
+
if (!t) return null;
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="space-y-6">
|
|
89
|
+
<PageHeader
|
|
90
|
+
breadcrumb={
|
|
91
|
+
<Link to="/themes" className="hover:text-slate-800">
|
|
92
|
+
Thèmes
|
|
93
|
+
</Link>
|
|
94
|
+
}
|
|
95
|
+
title={
|
|
96
|
+
<span className="flex items-center gap-3">
|
|
97
|
+
Personnaliser « {t.name} »
|
|
98
|
+
{t.active ? (
|
|
99
|
+
<Badge tone="success" dot>
|
|
100
|
+
Actif
|
|
101
|
+
</Badge>
|
|
102
|
+
) : (
|
|
103
|
+
<Badge tone="info">Aperçu</Badge>
|
|
104
|
+
)}
|
|
105
|
+
</span>
|
|
106
|
+
}
|
|
107
|
+
description={t.active ? 'Les options s’appliquent au site dès leur enregistrement.' : 'Ce thème n’est pas encore actif : les visiteurs voient toujours le thème actuel.'}
|
|
108
|
+
actions={
|
|
109
|
+
<>
|
|
110
|
+
{themes.length > 1 ? (
|
|
111
|
+
<div className="w-52">
|
|
112
|
+
<Select
|
|
113
|
+
value={t.id}
|
|
114
|
+
onChange={(id) => setParams({ theme: id })}
|
|
115
|
+
options={themes.map((x) => ({ value: x.id, label: x.active ? `${x.name} (actif)` : x.name }))}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
) : null}
|
|
119
|
+
{!t.active && isSuper ? (
|
|
120
|
+
<Button variant="primary" icon={CheckCircle2} loading={activating} disabled={!t.descriptor} onClick={() => void activate()}>
|
|
121
|
+
{ed.dirty ? 'Enregistrer et activer' : 'Activer ce thème'}
|
|
122
|
+
</Button>
|
|
123
|
+
) : null}
|
|
124
|
+
</>
|
|
125
|
+
}
|
|
126
|
+
/>
|
|
127
|
+
|
|
128
|
+
{!t.descriptor ? (
|
|
129
|
+
<Alert tone="danger" icon={ShieldAlert} title="Aperçu indisponible">
|
|
130
|
+
{t.status.message}
|
|
131
|
+
</Alert>
|
|
132
|
+
) : null}
|
|
133
|
+
|
|
134
|
+
<div className="grid gap-6 xl:grid-cols-[minmax(0,0.8fr)_minmax(0,1.4fr)]">
|
|
135
|
+
<div className="min-w-0 space-y-4">
|
|
136
|
+
{t.settingsSchema.length && ed.value ? (
|
|
137
|
+
<>
|
|
138
|
+
<fieldset disabled={!can('appearance.customize')} className="min-w-0">
|
|
139
|
+
<SettingsForm fields={t.settingsSchema} value={ed.value} errors={fieldErrors} onChange={(p) => ed.patch(p)} />
|
|
140
|
+
</fieldset>
|
|
141
|
+
<Button size="sm" variant="ghost" icon={RotateCcw} onClick={() => ed.patch(defaults(t.settingsSchema))}>
|
|
142
|
+
Options par défaut du thème
|
|
143
|
+
</Button>
|
|
144
|
+
</>
|
|
145
|
+
) : (
|
|
146
|
+
<EmptyState icon={SlidersHorizontal} title="Aucune option" description="Ce thème ne propose pas de réglage." />
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
<div className="min-w-0 xl:sticky xl:top-20 xl:self-start">
|
|
150
|
+
<div className="flex h-[calc(100vh-7rem)] min-h-[520px] flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm">
|
|
151
|
+
<div className="flex items-center gap-2 border-b border-slate-200 px-3 py-2">
|
|
152
|
+
<span className="flex items-center gap-1.5 text-xs font-semibold text-slate-600">
|
|
153
|
+
{t.active ? <span className="h-2 w-2 animate-pulse rounded-full bg-emerald-500" /> : <Eye className="h-3.5 w-3.5" />}
|
|
154
|
+
{t.active ? 'Aperçu en direct' : `Aperçu de ${t.name}`}
|
|
155
|
+
</span>
|
|
156
|
+
<div className="ml-auto w-48">
|
|
157
|
+
<Select value={path} onChange={setPath} options={pages.length ? pages : [{ value: '/', label: 'Accueil' }]} />
|
|
158
|
+
</div>
|
|
159
|
+
<DeviceSwitch value={device} onChange={setDevice} />
|
|
160
|
+
</div>
|
|
161
|
+
<div className="min-h-0 flex-1">
|
|
162
|
+
<PreviewFrame path={path} payload={payload} device={device} />
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
<SaveBar dirty={ed.dirty} saving={ed.saving} onSave={ed.commit} onReset={ed.reset} blocker={ed.blocker} />
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapify
|
|
3
|
+
* © 2026 NOVALABS WEB DESIGN — Tunisie
|
|
4
|
+
* Contact : contact@novalabs.tn · +216 24 734 647
|
|
5
|
+
* Tous droits réservés. Toute reproduction, modification ou diffusion sans autorisation écrite est interdite.
|
|
6
|
+
*/
|
|
7
|
+
import { useMemo, useState, type ReactNode } from 'react';
|
|
8
|
+
import { Link } from 'react-router-dom';
|
|
9
|
+
import { ArrowUpCircle, CheckCircle2, Download, Eye, FlaskConical, LayoutTemplate, Paintbrush, PackageSearch, RefreshCw, Search, ShieldAlert, ShieldCheck, Trash2 } from 'lucide-react';
|
|
10
|
+
import { toast } from 'sonner';
|
|
11
|
+
import type { InstalledThemeInfo, MarketplaceListing, StagedPackageInfo } from '../../../server/modules/types';
|
|
12
|
+
import { useAuth } from '../context/AuthContext';
|
|
13
|
+
import { useSite } from '../context/SiteContext';
|
|
14
|
+
import { api } from '../lib/api';
|
|
15
|
+
import { errorMessage, useAsync } from '../lib/hooks';
|
|
16
|
+
import { fmtBytes } from '../lib/format';
|
|
17
|
+
import { Alert, Badge, Button, Card, EmptyState, ErrorState, Input, PageHeader, PageSkeleton, Tabs } from '../ui/primitives';
|
|
18
|
+
import { useConfirm } from '../ui/overlays';
|
|
19
|
+
import { ImportPackageButton, InstallDialog } from '../modules/InstallDialog';
|
|
20
|
+
import { ModuleStatusBadge, PRICING_LABEL } from '../modules/labels';
|
|
21
|
+
|
|
22
|
+
type Tab = 'installed' | 'add';
|
|
23
|
+
type CatalogTheme = MarketplaceListing['modules'][number];
|
|
24
|
+
|
|
25
|
+
function Screenshot({ src, name, children }: { src?: string; name: string; children?: ReactNode }) {
|
|
26
|
+
return (
|
|
27
|
+
<div className="relative aspect-[4/3] overflow-hidden rounded-t-xl border-b border-slate-200 bg-slate-100">
|
|
28
|
+
{src ? (
|
|
29
|
+
<img src={src} alt={`Aperçu du thème ${name}`} loading="lazy" className="h-full w-full object-cover object-top" />
|
|
30
|
+
) : (
|
|
31
|
+
<div className="flex h-full items-center justify-center text-slate-300">
|
|
32
|
+
<LayoutTemplate className="h-12 w-12" />
|
|
33
|
+
</div>
|
|
34
|
+
)}
|
|
35
|
+
{children}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function SignatureNote({ signed }: { signed: boolean }) {
|
|
41
|
+
return signed ? (
|
|
42
|
+
<span className="inline-flex items-center gap-1 text-emerald-700">
|
|
43
|
+
<ShieldCheck className="h-3.5 w-3.5" /> Signé NOVALABS
|
|
44
|
+
</span>
|
|
45
|
+
) : (
|
|
46
|
+
<span className="inline-flex items-center gap-1 text-amber-700">
|
|
47
|
+
<FlaskConical className="h-3.5 w-3.5" /> Non signé
|
|
48
|
+
</span>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function InstalledCard({ t, isSuper, busy, onActivate, onDelete }: { t: InstalledThemeInfo; isSuper: boolean; busy: boolean; onActivate: () => void; onDelete: () => void }) {
|
|
53
|
+
const blocked = t.status.code !== 'active' && t.status.code !== 'disabled';
|
|
54
|
+
return (
|
|
55
|
+
<Card padded={false} className={t.active ? 'ring-2 ring-brand-500' : undefined}>
|
|
56
|
+
<Screenshot src={t.screenshot} name={t.name}>
|
|
57
|
+
{t.active ? (
|
|
58
|
+
<span className="absolute left-3 top-3 inline-flex items-center gap-1.5 rounded-full bg-emerald-600 px-2.5 py-1 text-xs font-semibold text-white shadow">
|
|
59
|
+
<CheckCircle2 className="h-3.5 w-3.5" /> Thème actif
|
|
60
|
+
</span>
|
|
61
|
+
) : null}
|
|
62
|
+
</Screenshot>
|
|
63
|
+
<div className="space-y-3 p-4">
|
|
64
|
+
<div className="flex items-start justify-between gap-3">
|
|
65
|
+
<div className="min-w-0">
|
|
66
|
+
<p className="truncate text-[15px] font-semibold text-slate-900">{t.name}</p>
|
|
67
|
+
<p className="text-xs text-slate-500">
|
|
68
|
+
v{t.version} · {t.author.name}
|
|
69
|
+
</p>
|
|
70
|
+
</div>
|
|
71
|
+
{blocked ? <ModuleStatusBadge code={t.status.code} /> : <Badge tone={t.pricing === 'free' ? 'success' : 'brand'}>{PRICING_LABEL[t.pricing]}</Badge>}
|
|
72
|
+
</div>
|
|
73
|
+
<p className="line-clamp-2 text-sm text-slate-600">{t.description}</p>
|
|
74
|
+
{blocked ? (
|
|
75
|
+
<p className="flex items-start gap-1.5 text-xs text-rose-700">
|
|
76
|
+
<ShieldAlert className="mt-0.5 h-3.5 w-3.5 shrink-0" /> {t.status.message}
|
|
77
|
+
</p>
|
|
78
|
+
) : null}
|
|
79
|
+
<div className="flex flex-wrap items-center gap-2 border-t border-slate-100 pt-3">
|
|
80
|
+
{t.active ? (
|
|
81
|
+
<Link to={`/themes/customize?theme=${encodeURIComponent(t.id)}`}>
|
|
82
|
+
<Button size="sm" variant="primary" icon={Paintbrush}>
|
|
83
|
+
Personnaliser
|
|
84
|
+
</Button>
|
|
85
|
+
</Link>
|
|
86
|
+
) : (
|
|
87
|
+
<>
|
|
88
|
+
<Link to={`/themes/customize?theme=${encodeURIComponent(t.id)}`}>
|
|
89
|
+
<Button size="sm" icon={Eye} disabled={blocked}>
|
|
90
|
+
Aperçu
|
|
91
|
+
</Button>
|
|
92
|
+
</Link>
|
|
93
|
+
{isSuper ? (
|
|
94
|
+
<Button size="sm" variant="primary" loading={busy} disabled={blocked} onClick={onActivate}>
|
|
95
|
+
Activer
|
|
96
|
+
</Button>
|
|
97
|
+
) : null}
|
|
98
|
+
{isSuper ? (
|
|
99
|
+
<Button size="sm" variant="ghost" icon={Trash2} className="ml-auto text-rose-600 hover:bg-rose-50" onClick={onDelete}>
|
|
100
|
+
<span className="sr-only">Supprimer</span>
|
|
101
|
+
</Button>
|
|
102
|
+
) : null}
|
|
103
|
+
</>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</Card>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function CatalogCard({ t, busy, canInstall, onInstall }: { t: CatalogTheme; busy: boolean; canInstall: boolean; onInstall: () => void }) {
|
|
112
|
+
const installed = t.installedVersion !== null;
|
|
113
|
+
return (
|
|
114
|
+
<Card padded={false} className="flex flex-col">
|
|
115
|
+
<Screenshot src={t.screenshot} name={t.name} />
|
|
116
|
+
<div className="flex flex-1 flex-col p-4">
|
|
117
|
+
<div className="flex items-start justify-between gap-3">
|
|
118
|
+
<div className="min-w-0">
|
|
119
|
+
<p className="truncate text-[15px] font-semibold text-slate-900">{t.name}</p>
|
|
120
|
+
<p className="text-xs text-slate-500">
|
|
121
|
+
v{t.version} · {t.author.name}
|
|
122
|
+
</p>
|
|
123
|
+
</div>
|
|
124
|
+
<Badge tone={t.pricing === 'free' ? 'success' : 'brand'}>{PRICING_LABEL[t.pricing]}</Badge>
|
|
125
|
+
</div>
|
|
126
|
+
<p className="mt-2 flex-1 text-sm text-slate-600">{t.description}</p>
|
|
127
|
+
<div className="mt-3 flex flex-wrap items-center gap-1.5 text-xs text-slate-500">
|
|
128
|
+
{t.category ? <Badge tone="neutral">{t.category}</Badge> : null}
|
|
129
|
+
<SignatureNote signed={t.signed} />
|
|
130
|
+
<span>· {fmtBytes(t.size)}</span>
|
|
131
|
+
</div>
|
|
132
|
+
<div className="mt-4 flex items-center justify-between gap-2 border-t border-slate-100 pt-3">
|
|
133
|
+
{installed ? (
|
|
134
|
+
<span className="inline-flex items-center gap-1.5 text-xs font-medium text-emerald-700">
|
|
135
|
+
<CheckCircle2 className="h-4 w-4" /> Installé (v{t.installedVersion})
|
|
136
|
+
</span>
|
|
137
|
+
) : !t.compatible ? (
|
|
138
|
+
<span className="text-xs text-rose-700">Requiert Snapify {t.engines.snapify}</span>
|
|
139
|
+
) : (
|
|
140
|
+
<span />
|
|
141
|
+
)}
|
|
142
|
+
{canInstall && (t.updateAvailable || !installed) ? (
|
|
143
|
+
<Button size="sm" variant="primary" icon={t.updateAvailable ? ArrowUpCircle : Download} loading={busy} disabled={!t.compatible} onClick={onInstall}>
|
|
144
|
+
{t.updateAvailable ? 'Mettre à jour' : 'Installer'}
|
|
145
|
+
</Button>
|
|
146
|
+
) : null}
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</Card>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default function ThemesPage() {
|
|
154
|
+
const { can } = useAuth();
|
|
155
|
+
const { reload: reloadSite } = useSite();
|
|
156
|
+
const isSuper = can('appearance.themes');
|
|
157
|
+
const confirm = useConfirm();
|
|
158
|
+
const [tab, setTab] = useState<Tab>('installed');
|
|
159
|
+
const installed = useAsync(() => api.themes.list(), []);
|
|
160
|
+
const [refresh, setRefresh] = useState(0);
|
|
161
|
+
const catalog = useAsync(() => (tab === 'add' ? api.modules.marketplace(refresh > 0) : Promise.resolve(null)), [tab, refresh]);
|
|
162
|
+
const [query, setQuery] = useState('');
|
|
163
|
+
const [busy, setBusy] = useState<string | null>(null);
|
|
164
|
+
const [staged, setStaged] = useState<StagedPackageInfo | null>(null);
|
|
165
|
+
|
|
166
|
+
const themes = installed.data?.themes ?? [];
|
|
167
|
+
const catalogThemes = useMemo(() => {
|
|
168
|
+
const q = query.trim().toLowerCase();
|
|
169
|
+
const list = (catalog.data?.modules ?? []).filter((m) => m.kind === 'theme');
|
|
170
|
+
return q ? list.filter((m) => `${m.name} ${m.description} ${m.category ?? ''} ${m.author.name}`.toLowerCase().includes(q)) : list;
|
|
171
|
+
}, [catalog.data, query]);
|
|
172
|
+
|
|
173
|
+
const activate = async (t: InstalledThemeInfo) => {
|
|
174
|
+
setBusy(t.id);
|
|
175
|
+
try {
|
|
176
|
+
await api.themes.activate(t.id);
|
|
177
|
+
toast.success(`${t.name} est maintenant le thème du site`);
|
|
178
|
+
installed.reload();
|
|
179
|
+
void reloadSite();
|
|
180
|
+
} catch (e) {
|
|
181
|
+
toast.error(errorMessage(e));
|
|
182
|
+
} finally {
|
|
183
|
+
setBusy(null);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const remove = async (t: InstalledThemeInfo) => {
|
|
188
|
+
const ok = await confirm({
|
|
189
|
+
title: `Supprimer « ${t.name} » ?`,
|
|
190
|
+
message: 'Le thème et ses options seront supprimés. Le contenu du site n’est pas touché. Vous pourrez le réinstaller depuis la marketplace.',
|
|
191
|
+
confirmLabel: 'Supprimer',
|
|
192
|
+
danger: true,
|
|
193
|
+
});
|
|
194
|
+
if (!ok) return;
|
|
195
|
+
try {
|
|
196
|
+
await api.themes.uninstall(t.id);
|
|
197
|
+
toast.success(`${t.name} supprimé`);
|
|
198
|
+
installed.reload();
|
|
199
|
+
} catch (e) {
|
|
200
|
+
toast.error(errorMessage(e));
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const stage = async (id: string) => {
|
|
205
|
+
setBusy(id);
|
|
206
|
+
try {
|
|
207
|
+
setStaged(await api.modules.stage(id));
|
|
208
|
+
} catch (e) {
|
|
209
|
+
toast.error(errorMessage(e));
|
|
210
|
+
} finally {
|
|
211
|
+
setBusy(null);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const afterInstall = () => {
|
|
216
|
+
installed.reload();
|
|
217
|
+
catalog.reload();
|
|
218
|
+
setTab('installed');
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
if (installed.loading && !installed.data) return <PageSkeleton />;
|
|
222
|
+
if (installed.error && !installed.data) return <ErrorState message={installed.error} onRetry={installed.reload} />;
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<div className="space-y-6">
|
|
226
|
+
<PageHeader
|
|
227
|
+
title="Thèmes"
|
|
228
|
+
description="Le thème définit l’apparence du site : en-tête, pied de page, mise en forme des blocs. Le contenu reste le même quel que soit le thème."
|
|
229
|
+
actions={isSuper ? <ImportPackageButton kind="theme" onInstalled={afterInstall} /> : null}
|
|
230
|
+
/>
|
|
231
|
+
|
|
232
|
+
{installed.data?.devMode ? (
|
|
233
|
+
<Alert tone="warning" icon={FlaskConical} title="Mode développeur actif">
|
|
234
|
+
Les thèmes non signés peuvent être installés. Désactivez <code>SNAPIFY_MODULES_DEV_MODE</code> en production.
|
|
235
|
+
</Alert>
|
|
236
|
+
) : null}
|
|
237
|
+
|
|
238
|
+
<Tabs<Tab>
|
|
239
|
+
value={tab}
|
|
240
|
+
onChange={setTab}
|
|
241
|
+
tabs={[
|
|
242
|
+
{ value: 'installed', label: 'Installés', badge: <Badge tone="neutral">{themes.length}</Badge> },
|
|
243
|
+
...(isSuper ? [{ value: 'add' as const, label: 'Ajouter un thème', icon: Download }] : []),
|
|
244
|
+
]}
|
|
245
|
+
/>
|
|
246
|
+
|
|
247
|
+
{tab === 'installed' ? (
|
|
248
|
+
themes.length === 0 ? (
|
|
249
|
+
<EmptyState icon={LayoutTemplate} title="Aucun thème installé" description="Installez un thème depuis l’onglet « Ajouter un thème »." />
|
|
250
|
+
) : (
|
|
251
|
+
<div className="grid gap-5 md:grid-cols-2 2xl:grid-cols-3">
|
|
252
|
+
{themes.map((t) => (
|
|
253
|
+
<InstalledCard key={t.id} t={t} isSuper={isSuper} busy={busy === t.id} onActivate={() => void activate(t)} onDelete={() => void remove(t)} />
|
|
254
|
+
))}
|
|
255
|
+
</div>
|
|
256
|
+
)
|
|
257
|
+
) : !catalog.data && !catalog.error ? (
|
|
258
|
+
<PageSkeleton />
|
|
259
|
+
) : catalog.error && !catalog.data ? (
|
|
260
|
+
<ErrorState message={catalog.error} onRetry={catalog.reload} />
|
|
261
|
+
) : (
|
|
262
|
+
<div className="space-y-5">
|
|
263
|
+
{catalog.data?.error ? (
|
|
264
|
+
<Alert tone="warning" title="Catalogue distant indisponible">
|
|
265
|
+
{catalog.data.error} Le catalogue local est affiché à la place.
|
|
266
|
+
</Alert>
|
|
267
|
+
) : null}
|
|
268
|
+
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
|
269
|
+
<div className="relative w-full sm:max-w-xs">
|
|
270
|
+
<Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400" />
|
|
271
|
+
<Input value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Rechercher un thème" className="pl-9" />
|
|
272
|
+
</div>
|
|
273
|
+
<Button icon={RefreshCw} loading={catalog.loading} onClick={() => setRefresh((n) => n + 1)}>
|
|
274
|
+
Actualiser
|
|
275
|
+
</Button>
|
|
276
|
+
</div>
|
|
277
|
+
{catalogThemes.length === 0 ? (
|
|
278
|
+
<EmptyState icon={PackageSearch} title="Aucun thème trouvé" description={query ? 'Essayez un autre mot-clé.' : 'Le catalogue ne propose pas encore de thème.'} />
|
|
279
|
+
) : (
|
|
280
|
+
<div className="grid gap-5 md:grid-cols-2 2xl:grid-cols-3">
|
|
281
|
+
{catalogThemes.map((t) => (
|
|
282
|
+
<CatalogCard key={t.id} t={t} busy={busy === t.id} canInstall={isSuper} onInstall={() => void stage(t.id)} />
|
|
283
|
+
))}
|
|
284
|
+
</div>
|
|
285
|
+
)}
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
|
|
289
|
+
<InstallDialog staged={staged} onClose={() => setStaged(null)} onInstalled={afterInstall} />
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
292
|
+
}
|