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,446 @@
|
|
|
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, useMemo, useState } from 'react';
|
|
8
|
+
import { closestCenter, DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors, type DragEndEvent } from '@dnd-kit/core';
|
|
9
|
+
import { arrayMove, SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
10
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
11
|
+
import { ChevronDown, ChevronUp, Copy, CornerDownRight, ExternalLink, GripVertical, Menu as MenuIcon, Monitor, Pencil, Plus, Smartphone, Star, Trash2 } from 'lucide-react';
|
|
12
|
+
import type { MenuConfig, MenuItem } from '../../../server/cms/types';
|
|
13
|
+
import { api } from '../lib/api';
|
|
14
|
+
import { useEditable } from '../lib/hooks';
|
|
15
|
+
import { useSiteData, useSite } from '../context/SiteContext';
|
|
16
|
+
import { Badge, Button, Card, EmptyState, Field, Input, PageHeader, Select, Switch, Tabs } from '../ui/primitives';
|
|
17
|
+
import { Modal, useConfirm } from '../ui/overlays';
|
|
18
|
+
import { SaveBar } from '../ui/SaveBar';
|
|
19
|
+
import { LinkInput } from '../editor/fields';
|
|
20
|
+
|
|
21
|
+
const newId = () => `m-${crypto.randomUUID().slice(0, 8)}`;
|
|
22
|
+
const PROTECTED = new Set(['primary', 'mobile', 'footer']);
|
|
23
|
+
const slugifyMenu = (s: string) =>
|
|
24
|
+
s
|
|
25
|
+
.normalize('NFD')
|
|
26
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
27
|
+
.toLowerCase()
|
|
28
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
29
|
+
.replace(/^-|-$/g, '')
|
|
30
|
+
.slice(0, 40) || `menu-${Date.now().toString(36)}`;
|
|
31
|
+
|
|
32
|
+
function ItemModal({ item, onClose, onSave }: { item: MenuItem | null; onClose: () => void; onSave: (i: MenuItem) => void }) {
|
|
33
|
+
const site = useSiteData();
|
|
34
|
+
const [draft, setDraft] = useState<MenuItem | null>(item);
|
|
35
|
+
React.useEffect(() => setDraft(item), [item]);
|
|
36
|
+
if (!draft) return null;
|
|
37
|
+
const set = (p: Partial<MenuItem>) => setDraft({ ...draft, ...p });
|
|
38
|
+
const pageOptions = [
|
|
39
|
+
{ value: '', label: 'Choisir une page du site…' },
|
|
40
|
+
...site.pages.map((p) => ({ value: p.path, label: `${p.title} — ${p.path}` })),
|
|
41
|
+
...site.posts.filter((p) => p.status === 'published').map((p) => ({ value: `/blog/${p.slug}/`, label: `Article : ${p.title}` })),
|
|
42
|
+
];
|
|
43
|
+
const valid = draft.label.trim() && draft.path.trim();
|
|
44
|
+
return (
|
|
45
|
+
<Modal
|
|
46
|
+
open={!!item}
|
|
47
|
+
onClose={onClose}
|
|
48
|
+
title={item?.label ? 'Modifier le lien' : 'Nouveau lien'}
|
|
49
|
+
footer={
|
|
50
|
+
<>
|
|
51
|
+
<Button onClick={onClose}>Annuler</Button>
|
|
52
|
+
<Button
|
|
53
|
+
variant="primary"
|
|
54
|
+
disabled={!valid}
|
|
55
|
+
onClick={() => {
|
|
56
|
+
onSave({ ...draft, label: draft.label.trim(), path: draft.path.trim() });
|
|
57
|
+
onClose();
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
Valider
|
|
61
|
+
</Button>
|
|
62
|
+
</>
|
|
63
|
+
}
|
|
64
|
+
>
|
|
65
|
+
<div className="space-y-4">
|
|
66
|
+
<Field label="Libellé affiché">
|
|
67
|
+
<Input autoFocus value={draft.label} onChange={(e) => set({ label: e.target.value })} placeholder="Ex. : Nos expertises" />
|
|
68
|
+
</Field>
|
|
69
|
+
<Field label="Page de destination">
|
|
70
|
+
<Select
|
|
71
|
+
value={pageOptions.some((o) => o.value === draft.path) ? draft.path : ''}
|
|
72
|
+
onChange={(v) => {
|
|
73
|
+
if (!v) return;
|
|
74
|
+
const page = site.pages.find((p) => p.path === v);
|
|
75
|
+
set({ path: v, label: draft.label || page?.title || '' });
|
|
76
|
+
}}
|
|
77
|
+
options={pageOptions}
|
|
78
|
+
/>
|
|
79
|
+
</Field>
|
|
80
|
+
<Field label="Ou adresse personnalisée" hint="Chemin interne (/contact/), ancre (#offre) ou lien externe (https://…).">
|
|
81
|
+
<LinkInput value={draft.path} onChange={(v) => set({ path: v })} />
|
|
82
|
+
</Field>
|
|
83
|
+
<div className="divide-y divide-slate-100 rounded-xl border border-slate-200 px-4">
|
|
84
|
+
<div className="py-3">
|
|
85
|
+
<Switch checked={!!draft.openInNewTab} onChange={(v) => set({ openInNewTab: v })} label="Ouvrir dans un nouvel onglet" />
|
|
86
|
+
</div>
|
|
87
|
+
<div className="py-3">
|
|
88
|
+
<Switch checked={!!draft.highlight} onChange={(v) => set({ highlight: v })} label="Mettre en avant (bouton)" description="Affiche ce lien sous forme de bouton coloré, idéal pour « Contact »." />
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</Modal>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function Row({
|
|
97
|
+
item,
|
|
98
|
+
depth,
|
|
99
|
+
first,
|
|
100
|
+
last,
|
|
101
|
+
onEdit,
|
|
102
|
+
onDelete,
|
|
103
|
+
onMove,
|
|
104
|
+
onAddChild,
|
|
105
|
+
dragHandle,
|
|
106
|
+
}: {
|
|
107
|
+
item: MenuItem;
|
|
108
|
+
depth: 0 | 1;
|
|
109
|
+
first: boolean;
|
|
110
|
+
last: boolean;
|
|
111
|
+
onEdit: () => void;
|
|
112
|
+
onDelete: () => void;
|
|
113
|
+
onMove: (d: -1 | 1) => void;
|
|
114
|
+
onAddChild?: () => void;
|
|
115
|
+
dragHandle?: React.ReactNode;
|
|
116
|
+
}) {
|
|
117
|
+
return (
|
|
118
|
+
<div className={`flex items-center gap-2 rounded-lg border border-slate-200 bg-white px-2 py-2 ${depth ? 'ml-9' : ''}`}>
|
|
119
|
+
{depth ? <CornerDownRight className="ml-1 h-4 w-4 text-slate-300" /> : dragHandle}
|
|
120
|
+
<button type="button" onClick={onEdit} className="flex min-w-0 flex-1 items-center gap-3 text-left">
|
|
121
|
+
<span className="truncate text-sm font-medium text-slate-800">{item.label}</span>
|
|
122
|
+
<span className="truncate text-xs text-slate-400">{item.path}</span>
|
|
123
|
+
{item.highlight ? (
|
|
124
|
+
<Badge tone="brand">
|
|
125
|
+
<Star className="h-3 w-3" /> Bouton
|
|
126
|
+
</Badge>
|
|
127
|
+
) : null}
|
|
128
|
+
{item.openInNewTab ? (
|
|
129
|
+
<Badge>
|
|
130
|
+
<ExternalLink className="h-3 w-3" /> Nouvel onglet
|
|
131
|
+
</Badge>
|
|
132
|
+
) : null}
|
|
133
|
+
</button>
|
|
134
|
+
<div className="flex shrink-0 items-center">
|
|
135
|
+
{onAddChild ? (
|
|
136
|
+
<Button size="sm" variant="ghost" icon={Plus} onClick={onAddChild} title="Ajouter un sous-lien">
|
|
137
|
+
<span className="hidden md:inline">Sous-lien</span>
|
|
138
|
+
</Button>
|
|
139
|
+
) : null}
|
|
140
|
+
<Button size="icon" variant="ghost" disabled={first} onClick={() => onMove(-1)} title="Monter">
|
|
141
|
+
<ChevronUp className="h-4 w-4" />
|
|
142
|
+
</Button>
|
|
143
|
+
<Button size="icon" variant="ghost" disabled={last} onClick={() => onMove(1)} title="Descendre">
|
|
144
|
+
<ChevronDown className="h-4 w-4" />
|
|
145
|
+
</Button>
|
|
146
|
+
<Button size="icon" variant="ghost" onClick={onEdit} title="Modifier">
|
|
147
|
+
<Pencil className="h-4 w-4" />
|
|
148
|
+
</Button>
|
|
149
|
+
<Button size="icon" variant="ghost" className="text-rose-600 hover:bg-rose-50" onClick={onDelete} title="Supprimer">
|
|
150
|
+
<Trash2 className="h-4 w-4" />
|
|
151
|
+
</Button>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function SortableTopItem(props: { item: MenuItem; children: (handle: React.ReactNode) => React.ReactNode }) {
|
|
158
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: props.item.id });
|
|
159
|
+
const handle = (
|
|
160
|
+
<button type="button" className="cursor-grab rounded p-1 text-slate-400 hover:bg-slate-100 active:cursor-grabbing" {...attributes} {...listeners} title="Glisser pour réordonner">
|
|
161
|
+
<GripVertical className="h-4 w-4" />
|
|
162
|
+
</button>
|
|
163
|
+
);
|
|
164
|
+
return (
|
|
165
|
+
<div ref={setNodeRef} style={{ transform: CSS.Translate.toString(transform), transition }} className={isDragging ? 'relative z-10 opacity-90 shadow-lg' : ''}>
|
|
166
|
+
{props.children(handle)}
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function MenuPreview({ items, mode }: { items: MenuItem[]; mode: 'desktop' | 'mobile' }) {
|
|
172
|
+
const site = useSiteData();
|
|
173
|
+
if (mode === 'mobile') {
|
|
174
|
+
return (
|
|
175
|
+
<div className="mx-auto w-[260px] overflow-hidden rounded-[28px] border-[6px] border-slate-900 bg-white shadow-xl">
|
|
176
|
+
<div className="flex items-center justify-between border-b border-slate-100 px-4 py-3">
|
|
177
|
+
<span className="text-sm font-bold" style={{ color: site.branding.colors.navy }}>
|
|
178
|
+
{site.branding.siteName}
|
|
179
|
+
</span>
|
|
180
|
+
<MenuIcon className="h-4 w-4 text-slate-500" />
|
|
181
|
+
</div>
|
|
182
|
+
<ul className="max-h-[380px] overflow-y-auto p-3">
|
|
183
|
+
{items.map((i) => (
|
|
184
|
+
<li key={i.id}>
|
|
185
|
+
<span
|
|
186
|
+
className="block rounded-lg px-3 py-2.5 text-sm font-medium"
|
|
187
|
+
style={i.highlight ? { background: site.branding.colors.primary, color: '#fff', textAlign: 'center', marginTop: 8 } : { color: site.branding.colors.text }}
|
|
188
|
+
>
|
|
189
|
+
{i.label}
|
|
190
|
+
</span>
|
|
191
|
+
{i.children?.map((c) => (
|
|
192
|
+
<span key={c.id} className="block px-6 py-1.5 text-[13px] text-slate-500">
|
|
193
|
+
{c.label}
|
|
194
|
+
</span>
|
|
195
|
+
))}
|
|
196
|
+
</li>
|
|
197
|
+
))}
|
|
198
|
+
</ul>
|
|
199
|
+
</div>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
return (
|
|
203
|
+
<div className="overflow-hidden rounded-xl border border-slate-200 bg-white">
|
|
204
|
+
<div className="flex items-center gap-6 px-5 py-4">
|
|
205
|
+
<span className="shrink-0 text-sm font-bold" style={{ color: site.branding.colors.navy }}>
|
|
206
|
+
{site.branding.siteName}
|
|
207
|
+
</span>
|
|
208
|
+
<nav className="ml-auto flex flex-wrap items-center justify-end gap-x-5 gap-y-2">
|
|
209
|
+
{items.map((i) =>
|
|
210
|
+
i.highlight ? (
|
|
211
|
+
<span key={i.id} className="rounded-lg px-3.5 py-1.5 text-[13px] font-semibold text-white" style={{ background: site.branding.colors.primary }}>
|
|
212
|
+
{i.label}
|
|
213
|
+
</span>
|
|
214
|
+
) : (
|
|
215
|
+
<span key={i.id} className="flex items-center gap-1 text-[13px] font-medium" style={{ color: site.branding.colors.text }}>
|
|
216
|
+
{i.label}
|
|
217
|
+
{i.children?.length ? <ChevronDown className="h-3 w-3 opacity-60" /> : null}
|
|
218
|
+
</span>
|
|
219
|
+
)
|
|
220
|
+
)}
|
|
221
|
+
</nav>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export default function MenusPage() {
|
|
228
|
+
const site = useSiteData();
|
|
229
|
+
const { patchSite, reload } = useSite();
|
|
230
|
+
const confirm = useConfirm();
|
|
231
|
+
const [tab, setTab] = useState('primary');
|
|
232
|
+
const [editing, setEditing] = useState<{ item: MenuItem; parentId?: string; isNew: boolean } | null>(null);
|
|
233
|
+
const [creating, setCreating] = useState(false);
|
|
234
|
+
const [newLabel, setNewLabel] = useState('');
|
|
235
|
+
const [newIdVal, setNewIdVal] = useState('');
|
|
236
|
+
|
|
237
|
+
const save = useCallback(
|
|
238
|
+
async (menus: MenuConfig[]) => {
|
|
239
|
+
const original = site.menus;
|
|
240
|
+
for (const m of menus) {
|
|
241
|
+
const before = original.find((o) => o.id === m.id);
|
|
242
|
+
if (!before || JSON.stringify(before.items) !== JSON.stringify(m.items) || before.label !== m.label) {
|
|
243
|
+
await api.saveMenu(m.id, m.items, m.label);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
patchSite('menus', menus);
|
|
247
|
+
},
|
|
248
|
+
[site.menus, patchSite]
|
|
249
|
+
);
|
|
250
|
+
const ed = useEditable<MenuConfig[]>(site.menus, save, { successMessage: 'Menus enregistrés' });
|
|
251
|
+
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
252
|
+
|
|
253
|
+
const menus = ed.value || [];
|
|
254
|
+
const menu = menus.find((m) => m.id === tab) || menus[0];
|
|
255
|
+
const activeTab = menu?.id || tab;
|
|
256
|
+
const items = useMemo(() => menu?.items || [], [menu]);
|
|
257
|
+
const setItems = (next: MenuItem[]) => ed.setValue(menus.map((m) => (m.id === activeTab ? { ...m, items: next } : m)));
|
|
258
|
+
|
|
259
|
+
const upsert = (item: MenuItem, parentId?: string) => {
|
|
260
|
+
if (!parentId) {
|
|
261
|
+
setItems(items.some((i) => i.id === item.id) ? items.map((i) => (i.id === item.id ? { ...item, children: i.children } : i)) : [...items, item]);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
setItems(
|
|
265
|
+
items.map((p) =>
|
|
266
|
+
p.id !== parentId
|
|
267
|
+
? p
|
|
268
|
+
: { ...p, children: (p.children || []).some((c) => c.id === item.id) ? (p.children || []).map((c) => (c.id === item.id ? item : c)) : [...(p.children || []), item] }
|
|
269
|
+
)
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const remove = async (item: MenuItem, parentId?: string) => {
|
|
274
|
+
if (item.children?.length && !(await confirm({ title: 'Supprimer ce lien ?', message: `Ses ${item.children.length} sous-lien(s) seront également supprimés.`, confirmLabel: 'Supprimer', danger: true }))) return;
|
|
275
|
+
if (!parentId) setItems(items.filter((i) => i.id !== item.id));
|
|
276
|
+
else setItems(items.map((p) => (p.id === parentId ? { ...p, children: (p.children || []).filter((c) => c.id !== item.id) } : p)));
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const onDragEnd = (e: DragEndEvent) => {
|
|
280
|
+
if (!e.over || e.active.id === e.over.id) return;
|
|
281
|
+
setItems(arrayMove(items, items.findIndex((i) => i.id === e.active.id), items.findIndex((i) => i.id === e.over!.id)));
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const copyFromPrimary = async () => {
|
|
285
|
+
const primary = menus.find((m) => m.id === 'primary');
|
|
286
|
+
if (!primary) return;
|
|
287
|
+
if (items.length && !(await confirm({ title: 'Remplacer ce menu ?', message: 'Les liens actuels seront remplacés par ceux du menu principal.', confirmLabel: 'Remplacer' }))) return;
|
|
288
|
+
setItems(structuredClone(primary.items).map((i) => ({ ...i, id: newId(), children: i.children?.map((c) => ({ ...c, id: newId() })) })));
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const createMenu = async () => {
|
|
292
|
+
const id = (newIdVal.trim() || slugifyMenu(newLabel)).slice(0, 40);
|
|
293
|
+
const label = newLabel.trim() || id;
|
|
294
|
+
if (!id || menus.some((m) => m.id === id)) return;
|
|
295
|
+
await api.createMenu(id, label);
|
|
296
|
+
const next = [...menus, { id, label, items: [] as MenuItem[] }];
|
|
297
|
+
ed.setValue(next);
|
|
298
|
+
patchSite('menus', next);
|
|
299
|
+
setTab(id);
|
|
300
|
+
setCreating(false);
|
|
301
|
+
setNewLabel('');
|
|
302
|
+
setNewIdVal('');
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const deleteMenu = async () => {
|
|
306
|
+
if (!menu || PROTECTED.has(menu.id)) return;
|
|
307
|
+
if (!(await confirm({ title: 'Supprimer ce menu ?', message: `Le menu « ${menu.label} » sera définitivement retiré.`, confirmLabel: 'Supprimer', danger: true }))) return;
|
|
308
|
+
await api.deleteMenu(menu.id);
|
|
309
|
+
const next = menus.filter((m) => m.id !== menu.id);
|
|
310
|
+
ed.setValue(next);
|
|
311
|
+
patchSite('menus', next);
|
|
312
|
+
setTab(next[0]?.id || 'primary');
|
|
313
|
+
void reload();
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<div className="space-y-6">
|
|
318
|
+
<PageHeader
|
|
319
|
+
title="Menus"
|
|
320
|
+
description="Emplacements de navigation : principal, mobile, pied de page, colonnes footer, ou menus personnalisés."
|
|
321
|
+
actions={
|
|
322
|
+
<Button size="sm" variant="primary" icon={Plus} onClick={() => setCreating(true)}>
|
|
323
|
+
Nouveau menu
|
|
324
|
+
</Button>
|
|
325
|
+
}
|
|
326
|
+
/>
|
|
327
|
+
<Tabs
|
|
328
|
+
value={activeTab}
|
|
329
|
+
onChange={setTab}
|
|
330
|
+
tabs={menus.map((m) => ({
|
|
331
|
+
value: m.id,
|
|
332
|
+
label: m.label,
|
|
333
|
+
icon: m.id === 'mobile' ? Smartphone : m.id === 'primary' ? Monitor : MenuIcon,
|
|
334
|
+
}))}
|
|
335
|
+
/>
|
|
336
|
+
|
|
337
|
+
<div className="grid gap-6 xl:grid-cols-[1fr_420px]">
|
|
338
|
+
<Card>
|
|
339
|
+
<div className="mb-4 flex flex-wrap items-center justify-between gap-3">
|
|
340
|
+
<div>
|
|
341
|
+
<h2 className="text-[15px] font-semibold text-slate-900">{menu?.label}</h2>
|
|
342
|
+
<p className="text-xs text-slate-500">
|
|
343
|
+
id: <span className="font-mono">{menu?.id}</span> — glissez les liens pour les réordonner.
|
|
344
|
+
</p>
|
|
345
|
+
</div>
|
|
346
|
+
<div className="flex flex-wrap gap-2">
|
|
347
|
+
{activeTab !== 'primary' ? (
|
|
348
|
+
<Button size="sm" icon={Copy} onClick={() => void copyFromPrimary()}>
|
|
349
|
+
Copier le menu principal
|
|
350
|
+
</Button>
|
|
351
|
+
) : null}
|
|
352
|
+
{!PROTECTED.has(activeTab) ? (
|
|
353
|
+
<Button size="sm" variant="danger" icon={Trash2} onClick={() => void deleteMenu()}>
|
|
354
|
+
Supprimer le menu
|
|
355
|
+
</Button>
|
|
356
|
+
) : null}
|
|
357
|
+
<Button size="sm" variant="primary" icon={Plus} onClick={() => setEditing({ item: { id: newId(), label: '', path: '' }, isNew: true })}>
|
|
358
|
+
Ajouter un lien
|
|
359
|
+
</Button>
|
|
360
|
+
</div>
|
|
361
|
+
</div>
|
|
362
|
+
|
|
363
|
+
{items.length === 0 ? (
|
|
364
|
+
<EmptyState icon={MenuIcon} title="Menu vide" description="Ajoutez votre premier lien." />
|
|
365
|
+
) : (
|
|
366
|
+
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={onDragEnd}>
|
|
367
|
+
<SortableContext items={items.map((i) => i.id)} strategy={verticalListSortingStrategy}>
|
|
368
|
+
<div className="space-y-2">
|
|
369
|
+
{items.map((item, i) => (
|
|
370
|
+
<SortableTopItem key={item.id} item={item}>
|
|
371
|
+
{(handle) => (
|
|
372
|
+
<div className="space-y-2">
|
|
373
|
+
<Row
|
|
374
|
+
item={item}
|
|
375
|
+
depth={0}
|
|
376
|
+
first={i === 0}
|
|
377
|
+
last={i === items.length - 1}
|
|
378
|
+
dragHandle={handle}
|
|
379
|
+
onEdit={() => setEditing({ item, isNew: false })}
|
|
380
|
+
onDelete={() => void remove(item)}
|
|
381
|
+
onMove={(d) => setItems(arrayMove(items, i, i + d))}
|
|
382
|
+
onAddChild={activeTab !== 'footer' ? () => setEditing({ item: { id: newId(), label: '', path: '' }, parentId: item.id, isNew: true }) : undefined}
|
|
383
|
+
/>
|
|
384
|
+
{(item.children || []).map((c, ci, arr) => (
|
|
385
|
+
<Row
|
|
386
|
+
key={c.id}
|
|
387
|
+
item={c}
|
|
388
|
+
depth={1}
|
|
389
|
+
first={ci === 0}
|
|
390
|
+
last={ci === arr.length - 1}
|
|
391
|
+
onEdit={() => setEditing({ item: c, parentId: item.id, isNew: false })}
|
|
392
|
+
onDelete={() => void remove(c, item.id)}
|
|
393
|
+
onMove={(d) => setItems(items.map((p) => (p.id === item.id ? { ...p, children: arrayMove(arr, ci, ci + d) } : p)))}
|
|
394
|
+
/>
|
|
395
|
+
))}
|
|
396
|
+
</div>
|
|
397
|
+
)}
|
|
398
|
+
</SortableTopItem>
|
|
399
|
+
))}
|
|
400
|
+
</div>
|
|
401
|
+
</SortableContext>
|
|
402
|
+
</DndContext>
|
|
403
|
+
)}
|
|
404
|
+
</Card>
|
|
405
|
+
|
|
406
|
+
<div className="space-y-3 xl:sticky xl:top-20 xl:self-start">
|
|
407
|
+
<p className="text-xs font-semibold uppercase tracking-wide text-slate-500">Aperçu</p>
|
|
408
|
+
<MenuPreview items={items} mode={activeTab === 'mobile' ? 'mobile' : 'desktop'} />
|
|
409
|
+
</div>
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
<ItemModal item={editing?.item || null} onClose={() => setEditing(null)} onSave={(item) => upsert(item, editing?.parentId)} />
|
|
413
|
+
<Modal
|
|
414
|
+
open={creating}
|
|
415
|
+
onClose={() => setCreating(false)}
|
|
416
|
+
title="Nouveau menu"
|
|
417
|
+
footer={
|
|
418
|
+
<>
|
|
419
|
+
<Button onClick={() => setCreating(false)}>Annuler</Button>
|
|
420
|
+
<Button variant="primary" disabled={!newLabel.trim() && !newIdVal.trim()} onClick={() => void createMenu()}>
|
|
421
|
+
Créer
|
|
422
|
+
</Button>
|
|
423
|
+
</>
|
|
424
|
+
}
|
|
425
|
+
>
|
|
426
|
+
<div className="space-y-4">
|
|
427
|
+
<Field label="Libellé">
|
|
428
|
+
<Input
|
|
429
|
+
autoFocus
|
|
430
|
+
value={newLabel}
|
|
431
|
+
onChange={(e) => {
|
|
432
|
+
setNewLabel(e.target.value);
|
|
433
|
+
if (!newIdVal) setNewIdVal(slugifyMenu(e.target.value));
|
|
434
|
+
}}
|
|
435
|
+
placeholder="Ex. : Réseaux sociaux"
|
|
436
|
+
/>
|
|
437
|
+
</Field>
|
|
438
|
+
<Field label="Identifiant" hint="Utilisé par le thème et les widgets (ex. social, footer-col-1).">
|
|
439
|
+
<Input value={newIdVal} onChange={(e) => setNewIdVal(slugifyMenu(e.target.value))} className="font-mono" />
|
|
440
|
+
</Field>
|
|
441
|
+
</div>
|
|
442
|
+
</Modal>
|
|
443
|
+
<SaveBar dirty={ed.dirty} saving={ed.saving} onSave={ed.commit} onReset={ed.reset} blocker={ed.blocker} />
|
|
444
|
+
</div>
|
|
445
|
+
);
|
|
446
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Page d'administration fournie par un module (/administrator/m/<module>/<page>/…) : le bundle
|
|
9
|
+
* `admin.js` du module est chargé à la demande et reçoit les composants du back-office.
|
|
10
|
+
*/
|
|
11
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
12
|
+
import { useNavigate, useParams } from 'react-router-dom';
|
|
13
|
+
import { PuzzleIcon } from 'lucide-react';
|
|
14
|
+
import type { AdminModule } from '../../../sdk/admin';
|
|
15
|
+
import '../../runtime';
|
|
16
|
+
import { useAuth } from '../context/AuthContext';
|
|
17
|
+
import { api } from '../lib/api';
|
|
18
|
+
import { useAsync } from '../lib/hooks';
|
|
19
|
+
import { ADMIN_KIT, AdminScopeContext } from '../modules/kit';
|
|
20
|
+
import { useInstalledModules } from '../modules/labels';
|
|
21
|
+
import { EmptyState, ErrorState, PageSkeleton } from '../ui/primitives';
|
|
22
|
+
|
|
23
|
+
declare global {
|
|
24
|
+
// eslint-disable-next-line no-var
|
|
25
|
+
var __SNAPIFY_ADMIN__: typeof ADMIN_KIT | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const bundles = new Map<string, Promise<AdminModule | null>>();
|
|
29
|
+
|
|
30
|
+
function loadAdminBundle(id: string, script: string, style?: string): Promise<AdminModule | null> {
|
|
31
|
+
globalThis.__SNAPIFY_ADMIN__ = ADMIN_KIT;
|
|
32
|
+
let p = bundles.get(script);
|
|
33
|
+
if (!p) {
|
|
34
|
+
if (style && !document.querySelector(`link[data-snapify-admin="${id}"][href="${style}"]`)) {
|
|
35
|
+
const link = document.createElement('link');
|
|
36
|
+
link.rel = 'stylesheet';
|
|
37
|
+
link.href = style;
|
|
38
|
+
link.dataset.snapifyAdmin = id;
|
|
39
|
+
document.head.appendChild(link);
|
|
40
|
+
}
|
|
41
|
+
p = import(/* @vite-ignore */ script)
|
|
42
|
+
.then((m: { default?: AdminModule }) => (m.default && typeof m.default.pages === 'object' ? m.default : null))
|
|
43
|
+
.catch((e) => {
|
|
44
|
+
console.error(`[modules] administration de ${id} indisponible`, e);
|
|
45
|
+
return null;
|
|
46
|
+
});
|
|
47
|
+
bundles.set(script, p);
|
|
48
|
+
}
|
|
49
|
+
return p;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class PageBoundary extends React.Component<{ children: React.ReactNode }, { error: string | null }> {
|
|
53
|
+
state = { error: null as string | null };
|
|
54
|
+
static getDerivedStateFromError(e: unknown) {
|
|
55
|
+
return { error: e instanceof Error ? e.message : 'Erreur inconnue' };
|
|
56
|
+
}
|
|
57
|
+
componentDidCatch(e: unknown) {
|
|
58
|
+
console.error('[modules] page d’administration', e);
|
|
59
|
+
}
|
|
60
|
+
render() {
|
|
61
|
+
return this.state.error ? <ErrorState message={`Cette page du module a rencontré une erreur : ${this.state.error}`} /> : this.props.children;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default function ModuleAdminPage() {
|
|
66
|
+
const { moduleId = '', pageId = '', '*': rest = '' } = useParams();
|
|
67
|
+
const navigate = useNavigate();
|
|
68
|
+
const { user, can } = useAuth();
|
|
69
|
+
const installed = useInstalledModules();
|
|
70
|
+
const info = installed.find((m) => m.id === moduleId);
|
|
71
|
+
const detail = useAsync(() => api.modules.detail(moduleId), [moduleId]);
|
|
72
|
+
const [bundle, setBundle] = useState<AdminModule | null | undefined>(undefined);
|
|
73
|
+
const client = useMemo(() => api.modules.client(moduleId), [moduleId]);
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!info?.admin) return;
|
|
77
|
+
let alive = true;
|
|
78
|
+
void loadAdminBundle(info.id, info.admin.script, info.admin.style).then((b) => alive && setBundle(b));
|
|
79
|
+
return () => {
|
|
80
|
+
alive = false;
|
|
81
|
+
};
|
|
82
|
+
}, [info?.id, info?.admin?.script, info?.admin?.style]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
83
|
+
|
|
84
|
+
const page = info?.adminPages.find((p) => p.id === pageId);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (page) document.title = `${page.label} · Administration`;
|
|
87
|
+
}, [page]);
|
|
88
|
+
|
|
89
|
+
if (!installed.length || (info?.admin && bundle === undefined) || (detail.loading && !detail.data)) return <PageSkeleton />;
|
|
90
|
+
if (!info || !page) return <EmptyState icon={PuzzleIcon} title="Page introuvable" description="Ce module n’est pas installé ou ne propose pas cette page." />;
|
|
91
|
+
if (!info.admin) return <EmptyState icon={PuzzleIcon} title={`${info.name} est inactif`} description={info.status.message} />;
|
|
92
|
+
const Page = bundle?.pages[pageId];
|
|
93
|
+
if (!Page) return <ErrorState message="Le module n’a pas pu charger cette page." />;
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<AdminScopeContext.Provider value={info.id}>
|
|
97
|
+
<div data-snapify-scope={info.id}>
|
|
98
|
+
<PageBoundary key={`${moduleId}/${pageId}`}>
|
|
99
|
+
<Page
|
|
100
|
+
page={pageId}
|
|
101
|
+
subpath={rest ? `/${rest}` : ''}
|
|
102
|
+
navigate={(sub, opts) => navigate(opts?.absolute ? sub : `/m/${moduleId}/${pageId}${sub}`)}
|
|
103
|
+
api={client}
|
|
104
|
+
module={{ id: info.id, version: info.version }}
|
|
105
|
+
settings={detail.data?.settings ?? {}}
|
|
106
|
+
user={{ id: user?.id ?? '', name: user?.name ?? '', email: user?.email ?? '' }}
|
|
107
|
+
canConfigure={can('modules.settings')}
|
|
108
|
+
/>
|
|
109
|
+
</PageBoundary>
|
|
110
|
+
</div>
|
|
111
|
+
</AdminScopeContext.Provider>
|
|
112
|
+
);
|
|
113
|
+
}
|