create-nextblock 0.2.78 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-nextblock.js +740 -459
- package/package.json +1 -2
- package/scripts/sync-template.js +18 -1
- package/templates/nextblock-template/.browserslistrc +11 -0
- package/templates/nextblock-template/.swcrc +30 -30
- package/templates/nextblock-template/README.md +23 -114
- package/templates/nextblock-template/app/(auth-pages)/post-sign-in/page.tsx +27 -28
- package/templates/nextblock-template/app/(auth-pages)/sign-in/page.tsx +50 -25
- package/templates/nextblock-template/app/(auth-pages)/sign-up/page.tsx +111 -56
- package/templates/nextblock-template/app/(auth-pages)/two-factor/actions.ts +91 -0
- package/templates/nextblock-template/app/(auth-pages)/two-factor/components/TwoFactorForm.tsx +118 -0
- package/templates/nextblock-template/app/(auth-pages)/two-factor/page.tsx +51 -0
- package/templates/nextblock-template/app/.well-known/ucp/route.ts +16 -0
- package/templates/nextblock-template/app/[slug]/PageClientContent.tsx +48 -28
- package/templates/nextblock-template/app/[slug]/page.tsx +63 -6
- package/templates/nextblock-template/app/[slug]/page.utils.ts +374 -157
- package/templates/nextblock-template/app/[slug]/pageClientActions.ts +7 -0
- package/templates/nextblock-template/app/actions/consent.ts +57 -0
- package/templates/nextblock-template/app/actions/formActions.ts +130 -11
- package/templates/nextblock-template/app/actions/languageActions.ts +31 -30
- package/templates/nextblock-template/app/actions/package-actions.ts +183 -0
- package/templates/nextblock-template/app/actions/postActions.ts +146 -48
- package/templates/nextblock-template/app/actions/twoFactorEmail.ts +21 -0
- package/templates/nextblock-template/app/actions/visualEditingActions.test.ts +179 -0
- package/templates/nextblock-template/app/actions/visualEditingActions.ts +345 -0
- package/templates/nextblock-template/app/actions.ts +67 -12
- package/templates/nextblock-template/app/api/ai/cortex/build-widget/route.ts +153 -0
- package/templates/nextblock-template/app/api/ai/generate-blocks/route.ts +96 -0
- package/templates/nextblock-template/app/api/ai/global-agent/route.ts +965 -0
- package/templates/nextblock-template/app/api/checkout/freemius/sync/route.ts +29 -0
- package/templates/nextblock-template/app/api/checkout/route.ts +146 -0
- package/templates/nextblock-template/app/api/cms/full-backup/export/route.ts +33 -0
- package/templates/nextblock-template/app/api/cms/full-backup/restore/route.ts +63 -0
- package/templates/nextblock-template/app/api/cron/reset-sandbox/route.ts +3413 -17
- package/templates/nextblock-template/app/api/cron/reset-sandbox/sandboxResetSql.ts +7830 -0
- package/templates/nextblock-template/app/api/cron/sync-currencies/route.ts +35 -0
- package/templates/nextblock-template/app/api/custom-blocks/db-relations/route.ts +92 -0
- package/templates/nextblock-template/app/api/custom-blocks/editor-definitions/route.ts +43 -0
- package/templates/nextblock-template/app/api/draft/disable/route.ts +25 -0
- package/templates/nextblock-template/app/api/draft/route.ts +93 -0
- package/templates/nextblock-template/app/api/draft/start/route.ts +77 -0
- package/templates/nextblock-template/app/api/media/library/route.ts +65 -0
- package/templates/nextblock-template/app/api/media/r2-presigned/route.ts +53 -0
- package/templates/nextblock-template/app/api/media/record/route.ts +160 -0
- package/templates/nextblock-template/app/api/search/route.ts +43 -0
- package/templates/nextblock-template/app/api/visual-editing/block-draft/route.ts +47 -0
- package/templates/nextblock-template/app/api/visual-editing/product-draft/route.ts +47 -0
- package/templates/nextblock-template/app/api/webhooks/freemius/route.ts +34 -0
- package/templates/nextblock-template/app/api/webhooks/stripe/route.ts +27 -0
- package/templates/nextblock-template/app/article/[slug]/PostClientContent.tsx +392 -128
- package/templates/nextblock-template/app/article/[slug]/page.tsx +179 -127
- package/templates/nextblock-template/app/article/[slug]/page.utils.ts +262 -77
- package/templates/nextblock-template/app/auth/callback/route.ts +31 -58
- package/templates/nextblock-template/app/cart/page.tsx +7 -0
- package/templates/nextblock-template/app/checkout/UcpCartHydrator.tsx +20 -0
- package/templates/nextblock-template/app/checkout/page.tsx +52 -0
- package/templates/nextblock-template/app/checkout/success/actions.ts +136 -0
- package/templates/nextblock-template/app/checkout/success/page.tsx +186 -0
- package/templates/nextblock-template/app/cms/CmsClientLayout.tsx +163 -33
- package/templates/nextblock-template/app/cms/blocks/actions.ts +424 -235
- package/templates/nextblock-template/app/cms/blocks/components/BackgroundSelector.tsx +212 -151
- package/templates/nextblock-template/app/cms/blocks/components/BlockEditorArea.tsx +41 -20
- package/templates/nextblock-template/app/cms/blocks/components/BlockEditorModal.tsx +152 -19
- package/templates/nextblock-template/app/cms/blocks/components/BlockTypeCard.tsx +25 -17
- package/templates/nextblock-template/app/cms/blocks/components/BlockTypeSelector.tsx +200 -18
- package/templates/nextblock-template/app/cms/blocks/components/ColumnEditor.tsx +33 -16
- package/templates/nextblock-template/app/cms/blocks/components/CustomBlockEditorPreview.tsx +160 -0
- package/templates/nextblock-template/app/cms/blocks/components/EditableBlock.tsx +37 -18
- package/templates/nextblock-template/app/cms/blocks/components/MediaLibraryModal.tsx +149 -67
- package/templates/nextblock-template/app/cms/blocks/components/SectionConfigPanel.tsx +108 -31
- package/templates/nextblock-template/app/cms/blocks/editors/DynamicCustomBlockEditor.tsx +167 -0
- package/templates/nextblock-template/app/cms/blocks/editors/FeaturedProductBlockEditor.tsx +31 -0
- package/templates/nextblock-template/app/cms/blocks/editors/FormBlockEditor.tsx +2 -2
- package/templates/nextblock-template/app/cms/blocks/editors/HeadingBlockEditor.tsx +1 -1
- package/templates/nextblock-template/app/cms/blocks/editors/ImageBlockEditor.tsx +29 -29
- package/templates/nextblock-template/app/cms/blocks/editors/PostsGridBlockEditor.tsx +14 -18
- package/templates/nextblock-template/app/cms/blocks/editors/ProductGridBlockEditor.tsx +41 -0
- package/templates/nextblock-template/app/cms/blocks/editors/SectionBlockEditor.tsx +318 -118
- package/templates/nextblock-template/app/cms/blocks/editors/TextBlockEditor.tsx +98 -21
- package/templates/nextblock-template/app/cms/blocks/editors/VideoEmbedBlockEditor.tsx +1 -1
- package/templates/nextblock-template/app/cms/components/ContentLanguageSwitcher.tsx +27 -9
- package/templates/nextblock-template/app/cms/components/CopyContentFromLanguage.tsx +1 -1
- package/templates/nextblock-template/app/cms/components/CortexAiActiveContext.tsx +23 -0
- package/templates/nextblock-template/app/cms/components/CortexAiPageContext.tsx +58 -0
- package/templates/nextblock-template/app/cms/components/CortexGlobalAgentChat.tsx +1507 -0
- package/templates/nextblock-template/app/cms/components/DraftStatusActions.tsx +145 -0
- package/templates/nextblock-template/app/cms/components/FeatureImageField.tsx +244 -0
- package/templates/nextblock-template/app/cms/components/FeedbackModal.tsx +38 -24
- package/templates/nextblock-template/app/cms/coupons/[id]/edit/page.tsx +16 -0
- package/templates/nextblock-template/app/cms/coupons/page.tsx +16 -0
- package/templates/nextblock-template/app/cms/custom-blocks/[id]/edit/page.tsx +66 -0
- package/templates/nextblock-template/app/cms/custom-blocks/actions.ts +519 -0
- package/templates/nextblock-template/app/cms/custom-blocks/components/BlockComposer.tsx +1522 -0
- package/templates/nextblock-template/app/cms/custom-blocks/components/BlocksLibraryTransferControls.tsx +256 -0
- package/templates/nextblock-template/app/cms/custom-blocks/components/DBRelationSelect.tsx +384 -0
- package/templates/nextblock-template/app/cms/custom-blocks/components/ImageR2Picker.tsx +221 -0
- package/templates/nextblock-template/app/cms/custom-blocks/new/page.tsx +12 -0
- package/templates/nextblock-template/app/cms/custom-blocks/page.tsx +438 -0
- package/templates/nextblock-template/app/cms/dashboard/actions.ts +228 -98
- package/templates/nextblock-template/app/cms/dashboard/components/DashboardComponents.tsx +200 -0
- package/templates/nextblock-template/app/cms/dashboard/page.tsx +182 -154
- package/templates/nextblock-template/app/cms/import-export/ContentTransferControls.tsx +391 -0
- package/templates/nextblock-template/app/cms/import-export/actions.ts +226 -0
- package/templates/nextblock-template/app/cms/layout.tsx +29 -10
- package/templates/nextblock-template/app/cms/media/UploadFolderContext.tsx +22 -22
- package/templates/nextblock-template/app/cms/media/actions.ts +45 -124
- package/templates/nextblock-template/app/cms/media/components/DeleteMediaButtonClient.tsx +1 -1
- package/templates/nextblock-template/app/cms/media/components/MediaEditForm.tsx +26 -26
- package/templates/nextblock-template/app/cms/media/components/MediaGridClient.tsx +69 -64
- package/templates/nextblock-template/app/cms/media/components/MediaPickerDialog.tsx +227 -158
- package/templates/nextblock-template/app/cms/media/components/MediaUploadForm.tsx +101 -89
- package/templates/nextblock-template/app/cms/media/page.tsx +1 -1
- package/templates/nextblock-template/app/cms/navigation/components/NavigationItemForm.tsx +2 -2
- package/templates/nextblock-template/app/cms/orders/[id]/MarkPaidButton.tsx +44 -0
- package/templates/nextblock-template/app/cms/orders/[id]/page.tsx +16 -0
- package/templates/nextblock-template/app/cms/orders/actions.ts +201 -0
- package/templates/nextblock-template/app/cms/orders/page.tsx +20 -0
- package/templates/nextblock-template/app/cms/orders/types.ts +20 -0
- package/templates/nextblock-template/app/cms/pages/[id]/edit/EditPageClient.tsx +156 -121
- package/templates/nextblock-template/app/cms/pages/[id]/edit/page.tsx +79 -26
- package/templates/nextblock-template/app/cms/pages/actions.ts +54 -38
- package/templates/nextblock-template/app/cms/pages/components/DeletePageButtonClient.tsx +1 -1
- package/templates/nextblock-template/app/cms/pages/components/PageForm.tsx +267 -116
- package/templates/nextblock-template/app/cms/pages/page.tsx +25 -18
- package/templates/nextblock-template/app/cms/payments/page.tsx +16 -0
- package/templates/nextblock-template/app/cms/posts/[id]/edit/page.tsx +132 -90
- package/templates/nextblock-template/app/cms/posts/actions.ts +71 -72
- package/templates/nextblock-template/app/cms/posts/components/DeletePostButtonClient.tsx +1 -1
- package/templates/nextblock-template/app/cms/posts/components/PostForm.tsx +256 -245
- package/templates/nextblock-template/app/cms/posts/new/page.tsx +1 -1
- package/templates/nextblock-template/app/cms/posts/page.tsx +20 -13
- package/templates/nextblock-template/app/cms/products/ClientNotionEditor.tsx +16 -0
- package/templates/nextblock-template/app/cms/products/ProductFormClientShell.tsx +56 -0
- package/templates/nextblock-template/app/cms/products/[id]/edit/page.tsx +292 -0
- package/templates/nextblock-template/app/cms/products/attributes/page.tsx +12 -0
- package/templates/nextblock-template/app/cms/products/categories/page.tsx +12 -0
- package/templates/nextblock-template/app/cms/products/inventory/page.tsx +13 -0
- package/templates/nextblock-template/app/cms/products/new/page.tsx +143 -0
- package/templates/nextblock-template/app/cms/products/page.tsx +42 -0
- package/templates/nextblock-template/app/cms/products/productFormData.ts +133 -0
- package/templates/nextblock-template/app/cms/products/settings/page.tsx +5 -0
- package/templates/nextblock-template/app/cms/promotions/PromotionsWorkspace.tsx +456 -0
- package/templates/nextblock-template/app/cms/promotions/actions.ts +115 -0
- package/templates/nextblock-template/app/cms/promotions/page.tsx +31 -0
- package/templates/nextblock-template/app/cms/revisions/RevisionHistoryButton.tsx +2 -2
- package/templates/nextblock-template/app/cms/revisions/actions.ts +285 -285
- package/templates/nextblock-template/app/cms/revisions/service.ts +19 -16
- package/templates/nextblock-template/app/cms/revisions/utils.ts +8 -3
- package/templates/nextblock-template/app/cms/settings/backup-restore/BackupRestoreWorkspace.tsx +1004 -0
- package/templates/nextblock-template/app/cms/settings/backup-restore/page.tsx +29 -0
- package/templates/nextblock-template/app/cms/settings/bot-protection/actions.ts +93 -0
- package/templates/nextblock-template/app/cms/settings/bot-protection/components/BotProtectionForm.tsx +129 -0
- package/templates/nextblock-template/app/cms/settings/bot-protection/page.tsx +24 -0
- package/templates/nextblock-template/app/cms/settings/copyright/actions.ts +1 -1
- package/templates/nextblock-template/app/cms/settings/copyright/components/CopyrightForm.tsx +2 -2
- package/templates/nextblock-template/app/cms/settings/copyright/page.tsx +1 -1
- package/templates/nextblock-template/app/cms/settings/cortex-ai/SandboxCortexAiSettingsClient.tsx +496 -0
- package/templates/nextblock-template/app/cms/settings/cortex-ai/StoredCortexAiSettingsClient.tsx +410 -0
- package/templates/nextblock-template/app/cms/settings/cortex-ai/actions.ts +248 -0
- package/templates/nextblock-template/app/cms/settings/cortex-ai/page.tsx +80 -0
- package/templates/nextblock-template/app/cms/settings/currencies/actions.ts +331 -0
- package/templates/nextblock-template/app/cms/settings/currencies/page.tsx +494 -0
- package/templates/nextblock-template/app/cms/settings/extra-translations/ExtraTranslationsWorkspace.tsx +767 -0
- package/templates/nextblock-template/app/cms/settings/extra-translations/actions.ts +203 -44
- package/templates/nextblock-template/app/cms/settings/extra-translations/page.tsx +93 -242
- package/templates/nextblock-template/app/cms/settings/global-css/actions.ts +65 -0
- package/templates/nextblock-template/app/cms/settings/global-css/components/GlobalCssForm.tsx +46 -0
- package/templates/nextblock-template/app/cms/settings/global-css/page.tsx +24 -0
- package/templates/nextblock-template/app/cms/settings/languages/components/DeleteLanguageButton.tsx +1 -1
- package/templates/nextblock-template/app/cms/settings/languages/components/LanguageForm.tsx +2 -2
- package/templates/nextblock-template/app/cms/settings/languages/page.tsx +1 -1
- package/templates/nextblock-template/app/cms/settings/logos/[id]/edit/page.tsx +7 -7
- package/templates/nextblock-template/app/cms/settings/logos/actions.ts +82 -6
- package/templates/nextblock-template/app/cms/settings/logos/components/BrandingSettingsForm.tsx +339 -0
- package/templates/nextblock-template/app/cms/settings/logos/components/DeleteLogoButton.tsx +21 -18
- package/templates/nextblock-template/app/cms/settings/logos/components/LogoForm.tsx +20 -16
- package/templates/nextblock-template/app/cms/settings/logos/components/SiteSeoSettingsForm.tsx +133 -0
- package/templates/nextblock-template/app/cms/settings/logos/new/page.tsx +8 -8
- package/templates/nextblock-template/app/cms/settings/logos/page.tsx +120 -82
- package/templates/nextblock-template/app/cms/settings/logos/types.ts +8 -8
- package/templates/nextblock-template/app/cms/settings/packages/activation-form.tsx +84 -0
- package/templates/nextblock-template/app/cms/settings/packages/package-card.tsx +122 -0
- package/templates/nextblock-template/app/cms/settings/packages/page.tsx +49 -0
- package/templates/nextblock-template/app/cms/settings/privacy/actions.ts +53 -0
- package/templates/nextblock-template/app/cms/settings/privacy/components/PrivacyForm.tsx +196 -0
- package/templates/nextblock-template/app/cms/settings/privacy/page.tsx +26 -0
- package/templates/nextblock-template/app/cms/settings/security/actions.ts +251 -0
- package/templates/nextblock-template/app/cms/settings/security/components/SecurityPanel.tsx +453 -0
- package/templates/nextblock-template/app/cms/settings/security/page.tsx +13 -0
- package/templates/nextblock-template/app/cms/settings/taxes/page.tsx +21 -0
- package/templates/nextblock-template/app/cms/shipping/page.tsx +20 -0
- package/templates/nextblock-template/app/cms/users/[id]/edit/page.tsx +28 -23
- package/templates/nextblock-template/app/cms/users/actions.ts +105 -40
- package/templates/nextblock-template/app/cms/users/components/DeleteUserButton.tsx +1 -1
- package/templates/nextblock-template/app/cms/users/components/UserForm.tsx +65 -152
- package/templates/nextblock-template/app/cms/users/page.tsx +15 -10
- package/templates/nextblock-template/app/globals.css +9 -0
- package/templates/nextblock-template/app/layout.tsx +372 -120
- package/templates/nextblock-template/app/lib/seo.test.ts +52 -0
- package/templates/nextblock-template/app/lib/seo.ts +279 -0
- package/templates/nextblock-template/app/lib/site-settings.ts +87 -0
- package/templates/nextblock-template/app/lib/sitemap-utils.ts +224 -39
- package/templates/nextblock-template/app/lib/ucp/protocol.ts +190 -0
- package/templates/nextblock-template/app/lib/ucp/server.test.ts +56 -0
- package/templates/nextblock-template/app/lib/ucp/server.ts +1914 -0
- package/templates/nextblock-template/app/page.tsx +165 -73
- package/templates/nextblock-template/app/product/[slug]/page.tsx +433 -0
- package/templates/nextblock-template/app/profile/ProfileAccountSidebar.tsx +73 -0
- package/templates/nextblock-template/app/profile/ProfilePageHeader.tsx +16 -0
- package/templates/nextblock-template/app/profile/ProfilePageMissingState.tsx +9 -0
- package/templates/nextblock-template/app/profile/account-data.ts +37 -0
- package/templates/nextblock-template/app/profile/account-links.ts +22 -0
- package/templates/nextblock-template/app/profile/account-types.ts +11 -0
- package/templates/nextblock-template/app/profile/orders/CustomerOrdersPageClient.tsx +124 -0
- package/templates/nextblock-template/app/profile/orders/[id]/CustomerOrderDetailPageClient.tsx +79 -0
- package/templates/nextblock-template/app/profile/orders/[id]/page.tsx +32 -0
- package/templates/nextblock-template/app/profile/orders/page.tsx +19 -0
- package/templates/nextblock-template/app/profile/page.tsx +51 -0
- package/templates/nextblock-template/app/profile/password/PasswordSettingsPageClient.tsx +128 -0
- package/templates/nextblock-template/app/profile/password/actions.ts +59 -0
- package/templates/nextblock-template/app/profile/password/page.tsx +27 -0
- package/templates/nextblock-template/app/providers.tsx +55 -17
- package/templates/nextblock-template/app/robots.txt/route.ts +11 -1
- package/templates/nextblock-template/app/sitemap.ts +128 -0
- package/templates/nextblock-template/app/ucp/v1/carts/[id]/cancel/route.ts +38 -0
- package/templates/nextblock-template/app/ucp/v1/carts/[id]/route.ts +68 -0
- package/templates/nextblock-template/app/ucp/v1/carts/route.ts +35 -0
- package/templates/nextblock-template/app/ucp/v1/catalog/lookup/route.ts +35 -0
- package/templates/nextblock-template/app/ucp/v1/catalog/product/route.ts +35 -0
- package/templates/nextblock-template/app/ucp/v1/catalog/search/route.ts +34 -0
- package/templates/nextblock-template/components/AppShell.tsx +154 -0
- package/templates/nextblock-template/components/BlockRenderer.tsx +210 -64
- package/templates/nextblock-template/components/CartDrawerLoader.tsx +7 -0
- package/templates/nextblock-template/components/CartTranslator.tsx +210 -0
- package/templates/nextblock-template/components/CurrentContentSetter.tsx +25 -0
- package/templates/nextblock-template/components/DeferredCartDrawer.tsx +23 -0
- package/templates/nextblock-template/components/DeferredCartTranslator.tsx +51 -0
- package/templates/nextblock-template/components/DeferredGlobalSearch.tsx +68 -0
- package/templates/nextblock-template/components/DeferredGoogleTagManager.tsx +70 -0
- package/templates/nextblock-template/components/DeferredSpeedInsights.tsx +69 -0
- package/templates/nextblock-template/components/FeatureImageHero.tsx +47 -0
- package/templates/nextblock-template/components/GitHubLoginButton.tsx +36 -0
- package/templates/nextblock-template/components/GlobalSearch.tsx +557 -0
- package/templates/nextblock-template/components/Header.tsx +49 -41
- package/templates/nextblock-template/components/LanguageSwitcher.tsx +55 -32
- package/templates/nextblock-template/components/ResponsiveNav.tsx +138 -43
- package/templates/nextblock-template/components/blocks/PostCardSkeleton.tsx +12 -8
- package/templates/nextblock-template/components/blocks/PostsGridBlock.tsx +12 -55
- package/templates/nextblock-template/components/blocks/PostsGridClient.tsx +42 -37
- package/templates/nextblock-template/components/blocks/TestimonialBlock.tsx +6 -2
- package/templates/nextblock-template/components/blocks/ecommerceRendererLoaders.ts +23 -0
- package/templates/nextblock-template/components/blocks/publicRendererLoaders.ts +25 -0
- package/templates/nextblock-template/components/blocks/renderers/ButtonBlockRenderer.tsx +92 -84
- package/templates/nextblock-template/components/blocks/renderers/CartBlockRenderer.tsx +17 -0
- package/templates/nextblock-template/components/blocks/renderers/CheckoutBlockRenderer.tsx +19 -0
- package/templates/nextblock-template/components/blocks/renderers/ClientTextBlockRenderer.tsx +262 -8
- package/templates/nextblock-template/components/blocks/renderers/FeaturedProductBlockRenderer.tsx +22 -0
- package/templates/nextblock-template/components/blocks/renderers/FormBlockRenderer.tsx +320 -37
- package/templates/nextblock-template/components/blocks/renderers/HeadingBlockRenderer.tsx +11 -8
- package/templates/nextblock-template/components/blocks/renderers/ImageBlockRenderer.tsx +12 -3
- package/templates/nextblock-template/components/blocks/renderers/PostsGridBlockRenderer.tsx +18 -13
- package/templates/nextblock-template/components/blocks/renderers/ProductDetailsBlockRenderer.tsx +90 -0
- package/templates/nextblock-template/components/blocks/renderers/ProductGridBlockRenderer.tsx +31 -0
- package/templates/nextblock-template/components/blocks/renderers/SectionBlockRenderer.tsx +424 -55
- package/templates/nextblock-template/components/blocks/renderers/SectionSlider.tsx +137 -0
- package/templates/nextblock-template/components/blocks/renderers/TestimonialBlockRenderer.tsx +57 -0
- package/templates/nextblock-template/components/blocks/renderers/TextBlockRenderer.tsx +37 -22
- package/templates/nextblock-template/components/blocks/renderers/VideoEmbedBlockRenderer.tsx +23 -15
- package/templates/nextblock-template/components/blocks/renderers/inline/AlertWidgetRenderer.tsx +1 -3
- package/templates/nextblock-template/components/blocks/renderers/inline/CtaWidgetRenderer.tsx +1 -3
- package/templates/nextblock-template/components/blocks/types.ts +7 -6
- package/templates/nextblock-template/components/env-var-warning.tsx +3 -3
- package/templates/nextblock-template/components/form-message.tsx +32 -26
- package/templates/nextblock-template/components/header-auth.tsx +69 -17
- package/templates/nextblock-template/components/privacy/ConsentBanner.tsx +127 -0
- package/templates/nextblock-template/components/privacy/ConsentGatedAnalytics.tsx +59 -0
- package/templates/nextblock-template/components/renderers/CachedDynamicLayoutEngine.tsx +28 -0
- package/templates/nextblock-template/components/renderers/DynamicLayoutEngine.test.tsx +166 -0
- package/templates/nextblock-template/components/renderers/DynamicLayoutEngine.tsx +464 -0
- package/templates/nextblock-template/components/theme-switcher.tsx +8 -8
- package/templates/nextblock-template/components/visual-editing/DeferredVisualEditing.tsx +21 -0
- package/templates/nextblock-template/components/visual-editing/NextblockVisualEditing.tsx +1172 -0
- package/templates/nextblock-template/context/AuthContext.tsx +23 -90
- package/templates/nextblock-template/context/CurrentContentContext.tsx +10 -4
- package/templates/nextblock-template/context/LanguageContext.tsx +16 -16
- package/templates/nextblock-template/context/language-rest-client.ts +31 -0
- package/templates/nextblock-template/docs/01-PROJECT-OVERVIEW.md +94 -0
- package/templates/nextblock-template/docs/02-ECOMMERCE-CAPABILITIES.md +364 -0
- package/templates/nextblock-template/docs/03-CMS-AND-EDITOR.md +202 -0
- package/templates/nextblock-template/docs/04-DATABASE-AND-AUTH.md +252 -0
- package/templates/nextblock-template/docs/05-DEVELOPER-GUIDE.md +238 -0
- package/templates/nextblock-template/docs/06-CLI-AND-SCAFFOLDING.md +125 -0
- package/templates/nextblock-template/docs/07-BLOCK-SDK-AND-EXTENSIBILITY.md +146 -0
- package/templates/nextblock-template/docs/08-NEXTBLOCK-CORTEX-AI-ARCHITECTURE.md +1319 -0
- package/templates/nextblock-template/docs/09-LIVE-DRAFT-MODE.md +104 -0
- package/templates/nextblock-template/docs/10-CUSTOM-BLOCKS.md +222 -0
- package/templates/nextblock-template/docs/README.md +34 -0
- package/templates/nextblock-template/docs/TECHNICAL_SPECIFICATION.md +12507 -0
- package/templates/nextblock-template/hooks/use-hotkeys.ts +21 -14
- package/templates/nextblock-template/hooks/useGlobalSearch.ts +101 -0
- package/templates/nextblock-template/index.d.ts +2 -0
- package/templates/nextblock-template/lib/ai-block-generation.ts +339 -0
- package/templates/nextblock-template/lib/ai-client.ts +247 -0
- package/templates/nextblock-template/lib/ai-config.ts +81 -0
- package/templates/nextblock-template/lib/ai-cortex-widget-builder.ts +125 -0
- package/templates/nextblock-template/lib/ai-global-agent-custom-block-tools.ts +363 -0
- package/templates/nextblock-template/lib/ai-global-agent-db-tools.test.ts +405 -0
- package/templates/nextblock-template/lib/ai-global-agent-db-tools.ts +1228 -0
- package/templates/nextblock-template/lib/ai-global-agent-ecommerce.ts +5 -0
- package/templates/nextblock-template/lib/ai-global-agent-tools-stats.test.ts +223 -0
- package/templates/nextblock-template/lib/ai-global-agent-tools.test.ts +2183 -0
- package/templates/nextblock-template/lib/ai-global-agent-tools.ts +4807 -0
- package/templates/nextblock-template/lib/ai-key-crypto.test.ts +70 -0
- package/templates/nextblock-template/lib/ai-key-crypto.ts +132 -0
- package/templates/nextblock-template/lib/ai-model-catalog.test.ts +49 -0
- package/templates/nextblock-template/lib/ai-model-catalog.ts +41 -0
- package/templates/nextblock-template/lib/ai-model-registry.test.ts +231 -0
- package/templates/nextblock-template/lib/ai-model-registry.ts +522 -0
- package/templates/nextblock-template/lib/auth/cookies.ts +47 -0
- package/templates/nextblock-template/lib/auth/crypto.ts +42 -0
- package/templates/nextblock-template/lib/auth/trustedDevices.ts +92 -0
- package/templates/nextblock-template/lib/auth/twoFactor.ts +167 -0
- package/templates/nextblock-template/lib/auth-redirects.ts +46 -0
- package/templates/nextblock-template/lib/blocks/FeaturedProductBlock.tsx +94 -0
- package/templates/nextblock-template/lib/blocks/ProductGridBlock.tsx +137 -0
- package/templates/nextblock-template/lib/blocks/README.md +13 -670
- package/templates/nextblock-template/lib/blocks/blockRegistry.ts +138 -56
- package/templates/nextblock-template/lib/blocks/blockTypes.ts +18 -0
- package/templates/nextblock-template/lib/blocks/ecommerce-block-schemas.ts +31 -0
- package/templates/nextblock-template/lib/cms-transfer/csv.test.ts +77 -0
- package/templates/nextblock-template/lib/cms-transfer/csv.ts +399 -0
- package/templates/nextblock-template/lib/cms-transfer/server.ts +2243 -0
- package/templates/nextblock-template/lib/cms-transfer/types.ts +145 -0
- package/templates/nextblock-template/lib/cortex-widget-registry.test.ts +199 -0
- package/templates/nextblock-template/lib/cortex-widget-registry.ts +88 -0
- package/templates/nextblock-template/lib/cortex-widget-schema.test.tsx +237 -0
- package/templates/nextblock-template/lib/cortex-widget-schema.ts +393 -0
- package/templates/nextblock-template/lib/custom-block-definitions.ts +87 -0
- package/templates/nextblock-template/lib/custom-block-r2-upload-shared.ts +178 -0
- package/templates/nextblock-template/lib/custom-block-r2-upload.test.ts +140 -0
- package/templates/nextblock-template/lib/custom-block-r2-upload.ts +68 -0
- package/templates/nextblock-template/lib/custom-block-relation-registry.ts +256 -0
- package/templates/nextblock-template/lib/custom-block-relations.test.ts +227 -0
- package/templates/nextblock-template/lib/custom-block-relations.ts +279 -0
- package/templates/nextblock-template/lib/custom-block-safelist.ts +14 -0
- package/templates/nextblock-template/lib/editor/dynamic-extension-core.test.ts +172 -0
- package/templates/nextblock-template/lib/editor/dynamic-extension-core.ts +213 -0
- package/templates/nextblock-template/lib/editor/dynamic-extension-loader.ts +22 -0
- package/templates/nextblock-template/lib/editor/dynamic-extensions.tsx +193 -0
- package/templates/nextblock-template/lib/full-backup/manifest.test.ts +121 -0
- package/templates/nextblock-template/lib/full-backup/manifest.ts +206 -0
- package/templates/nextblock-template/lib/full-backup/server.ts +743 -0
- package/templates/nextblock-template/lib/media/resolveMediaUrl.ts +45 -0
- package/templates/nextblock-template/lib/posts/readTime.ts +60 -0
- package/templates/nextblock-template/lib/privacy/consent-client.ts +57 -0
- package/templates/nextblock-template/lib/privacy/settings.ts +103 -0
- package/templates/nextblock-template/lib/privacy/types.ts +67 -0
- package/templates/nextblock-template/lib/promotions/server.test.ts +74 -0
- package/templates/nextblock-template/lib/promotions/server.ts +741 -0
- package/templates/nextblock-template/lib/resolve-block-relations.test.ts +142 -0
- package/templates/nextblock-template/lib/resolve-block-relations.ts +255 -0
- package/templates/nextblock-template/lib/search/server.ts +585 -0
- package/templates/nextblock-template/lib/search/types.ts +27 -0
- package/templates/nextblock-template/lib/visual-editing/draft-content.test.ts +105 -0
- package/templates/nextblock-template/lib/visual-editing/draft-content.ts +380 -0
- package/templates/nextblock-template/lib/visual-editing/draft-route.test.ts +42 -0
- package/templates/nextblock-template/lib/visual-editing/draft-route.ts +82 -0
- package/templates/nextblock-template/lib/visual-editing/edit-info.test.ts +143 -0
- package/templates/nextblock-template/lib/visual-editing/edit-info.ts +94 -0
- package/templates/nextblock-template/lib/visual-editing/mutations.ts +190 -0
- package/templates/nextblock-template/lib/visual-editing/product-drafts.test.ts +81 -0
- package/templates/nextblock-template/lib/visual-editing/product-drafts.ts +511 -0
- package/templates/nextblock-template/lib/visual-editing/types.ts +122 -0
- package/templates/nextblock-template/lib/zod-config.ts +5 -0
- package/templates/nextblock-template/next.config.js +190 -66
- package/templates/nextblock-template/package.json +34 -30
- package/templates/nextblock-template/proxy.ts +435 -253
- package/templates/nextblock-template/public/images/NBcover.webp +0 -0
- package/templates/nextblock-template/public/images/cap.webp +0 -0
- package/templates/nextblock-template/public/images/commerce-plan.webp +0 -0
- package/templates/nextblock-template/public/images/commerce-square.webp +0 -0
- package/templates/nextblock-template/public/images/commerce-wide.webp +0 -0
- package/templates/nextblock-template/public/images/cortex-ai-square.webp +0 -0
- package/templates/nextblock-template/public/images/cortex-ai.webp +0 -0
- package/templates/nextblock-template/public/images/extensibility.webp +0 -0
- package/templates/nextblock-template/public/images/goals.webp +0 -0
- package/templates/nextblock-template/public/images/included.webp +0 -0
- package/templates/nextblock-template/public/images/nx-graph.webp +0 -0
- package/templates/nextblock-template/public/images/pants.webp +0 -0
- package/templates/nextblock-template/public/images/t-shirt.webp +0 -0
- package/templates/nextblock-template/scripts/validate-editor-block-schema.ts +112 -0
- package/templates/nextblock-template/scripts/verify-cortex-ai-build-widget.tsx +100 -0
- package/templates/nextblock-template/scripts/verify-cortex-ai-generate-blocks.ts +62 -0
- package/templates/nextblock-template/scripts/verify-cortex-ai-global-tools.ts +537 -0
- package/templates/nextblock-template/scripts/verify-cortex-ai-routing.ts +58 -0
- package/templates/nextblock-template/scripts/verify-custom-block-definitions.ts +188 -0
- package/templates/nextblock-template/scripts/verify-dynamic-custom-block-extensions.ts +123 -0
- package/templates/nextblock-template/scripts/verify-dynamic-layout-engine.tsx +133 -0
- package/templates/nextblock-template/scripts/verify-milestone-2-custom-blocks.ts +65 -0
- package/templates/nextblock-template/tailwind.config.js +1 -0
- package/templates/nextblock-template/tools/configure-supabase-auth.js +282 -0
- package/templates/nextblock-template/tools/deploy-supabase.js +69 -71
- package/templates/nextblock-template/tsconfig.json +52 -66
- package/templates/nextblock-template/tsconfig.tsbuildinfo +1 -1
- package/templates/nextblock-template/types/jsdom.d.ts +6 -0
- package/templates/nextblock-template/app/force-styles.tsx +0 -31
- package/templates/nextblock-template/app/sitemap.xml/route.ts +0 -63
- package/templates/nextblock-template/components/blocks/renderers/HeroBlockRenderer.tsx +0 -273
- package/templates/nextblock-template/docs/How to Create a Custom Block.md +0 -149
- package/templates/nextblock-template/docs/cms-application-overview.md +0 -56
- package/templates/nextblock-template/docs/cms-architecture-overview.md +0 -73
- package/templates/nextblock-template/docs/files-structure.md +0 -426
- package/templates/nextblock-template/docs/tiptap-bundle-optimization-summary.md +0 -174
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import { Button } from "@nextblock-cms/ui";
|
|
5
|
+
import { toast } from "react-hot-toast";
|
|
6
|
+
import { useRouter } from "next/navigation";
|
|
7
|
+
import { CloudLightning, Trash2, Loader2 } from "lucide-react";
|
|
8
|
+
import {
|
|
9
|
+
publishVisualEditingDraft,
|
|
10
|
+
discardVisualEditingDraft,
|
|
11
|
+
publishVisualEditingProductDraft,
|
|
12
|
+
discardVisualEditingProductDraft,
|
|
13
|
+
} from "../../actions/visualEditingActions";
|
|
14
|
+
|
|
15
|
+
interface DraftStatusActionsProps {
|
|
16
|
+
parentId: string | number;
|
|
17
|
+
parentType: "page" | "post" | "product";
|
|
18
|
+
hasDraft: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function DraftStatusActions({
|
|
22
|
+
parentId,
|
|
23
|
+
parentType,
|
|
24
|
+
hasDraft,
|
|
25
|
+
}: DraftStatusActionsProps) {
|
|
26
|
+
const router = useRouter();
|
|
27
|
+
const [isPublishing, setIsPublishing] = useState(false);
|
|
28
|
+
const [isDiscarding, setIsDiscarding] = useState(false);
|
|
29
|
+
|
|
30
|
+
if (!hasDraft) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const handlePublish = async () => {
|
|
35
|
+
setIsPublishing(true);
|
|
36
|
+
const toastId = toast.loading("Publishing changes live...");
|
|
37
|
+
try {
|
|
38
|
+
let res;
|
|
39
|
+
if (parentType === "product") {
|
|
40
|
+
res = await publishVisualEditingProductDraft(String(parentId));
|
|
41
|
+
} else {
|
|
42
|
+
res = await publishVisualEditingDraft(
|
|
43
|
+
parentType as "page" | "post",
|
|
44
|
+
Number(parentId)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (res && "error" in res && res.error) {
|
|
49
|
+
toast.error(`Publish failed: ${res.error}`, { id: toastId });
|
|
50
|
+
} else {
|
|
51
|
+
toast.success("Changes published live successfully!", { id: toastId });
|
|
52
|
+
router.refresh();
|
|
53
|
+
// Give NextJS server components a tiny bit of time to refresh, then reload the page
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
window.location.reload();
|
|
56
|
+
}, 800);
|
|
57
|
+
}
|
|
58
|
+
} catch (err: any) {
|
|
59
|
+
toast.error(`Error publishing: ${err.message || err}`, { id: toastId });
|
|
60
|
+
} finally {
|
|
61
|
+
setIsPublishing(false);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const handleDiscard = async () => {
|
|
66
|
+
if (!window.confirm("Are you sure you want to discard all draft changes? This action cannot be undone.")) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setIsDiscarding(true);
|
|
70
|
+
const toastId = toast.loading("Discarding draft changes...");
|
|
71
|
+
try {
|
|
72
|
+
let res;
|
|
73
|
+
if (parentType === "product") {
|
|
74
|
+
res = await discardVisualEditingProductDraft(String(parentId));
|
|
75
|
+
} else {
|
|
76
|
+
res = await discardVisualEditingDraft(
|
|
77
|
+
parentType as "page" | "post",
|
|
78
|
+
Number(parentId)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (res && "error" in res && res.error) {
|
|
83
|
+
toast.error(`Discard failed: ${res.error}`, { id: toastId });
|
|
84
|
+
} else {
|
|
85
|
+
toast.success("Draft changes discarded successfully.", { id: toastId });
|
|
86
|
+
router.refresh();
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
window.location.reload();
|
|
89
|
+
}, 800);
|
|
90
|
+
}
|
|
91
|
+
} catch (err: any) {
|
|
92
|
+
toast.error(`Error discarding: ${err.message || err}`, { id: toastId });
|
|
93
|
+
} finally {
|
|
94
|
+
setIsDiscarding(false);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div
|
|
100
|
+
data-nextblock-draft-toolbar
|
|
101
|
+
className="fixed bottom-6 left-1/2 z-[1000] flex -translate-x-1/2 items-center gap-3.5 rounded-full border border-amber-500/30 bg-background/95 px-4 py-2 text-sm shadow-xl backdrop-blur-md transition-all duration-300 ease-in-out animate-in fade-in slide-in-from-bottom-5"
|
|
102
|
+
>
|
|
103
|
+
<div className="flex items-center gap-2 px-1">
|
|
104
|
+
<div className="relative flex h-2.5 w-2.5">
|
|
105
|
+
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"></span>
|
|
106
|
+
<span className="relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"></span>
|
|
107
|
+
</div>
|
|
108
|
+
<span className="font-semibold text-amber-800 dark:text-amber-300 text-[11px] uppercase tracking-wider select-none">
|
|
109
|
+
Unpublished Draft
|
|
110
|
+
</span>
|
|
111
|
+
</div>
|
|
112
|
+
<div className="h-4 w-[1px] bg-border" />
|
|
113
|
+
<div className="flex items-center gap-2">
|
|
114
|
+
<Button
|
|
115
|
+
variant="outline"
|
|
116
|
+
size="sm"
|
|
117
|
+
className="h-8 rounded-full border-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-500/10 hover:text-amber-900 dark:hover:text-amber-200 px-3.5 text-xs"
|
|
118
|
+
onClick={handleDiscard}
|
|
119
|
+
disabled={isDiscarding || isPublishing}
|
|
120
|
+
>
|
|
121
|
+
{isDiscarding ? (
|
|
122
|
+
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
|
123
|
+
) : (
|
|
124
|
+
<Trash2 className="mr-1.5 h-3.5 w-3.5" />
|
|
125
|
+
)}
|
|
126
|
+
Discard
|
|
127
|
+
</Button>
|
|
128
|
+
<Button
|
|
129
|
+
variant="default"
|
|
130
|
+
size="sm"
|
|
131
|
+
className="h-8 rounded-full bg-amber-600 hover:bg-amber-500 text-white border-0 shadow-md shadow-amber-600/10 px-4 text-xs font-medium"
|
|
132
|
+
onClick={handlePublish}
|
|
133
|
+
disabled={isDiscarding || isPublishing}
|
|
134
|
+
>
|
|
135
|
+
{isPublishing ? (
|
|
136
|
+
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
|
137
|
+
) : (
|
|
138
|
+
<CloudLightning className="mr-1.5 h-3.5 w-3.5" />
|
|
139
|
+
)}
|
|
140
|
+
Publish
|
|
141
|
+
</Button>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type KeyboardEvent, useCallback, useEffect, useState } from "react";
|
|
4
|
+
import Image from "next/image";
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogClose,
|
|
9
|
+
DialogContent,
|
|
10
|
+
DialogFooter,
|
|
11
|
+
DialogHeader,
|
|
12
|
+
DialogTitle,
|
|
13
|
+
DialogTrigger,
|
|
14
|
+
Input,
|
|
15
|
+
Label,
|
|
16
|
+
Separator,
|
|
17
|
+
Spinner,
|
|
18
|
+
} from "@nextblock-cms/ui";
|
|
19
|
+
import type { Database } from "@nextblock-cms/db";
|
|
20
|
+
|
|
21
|
+
import { resolveMediaUrl } from "../../../lib/media/resolveMediaUrl";
|
|
22
|
+
import { getMediaItems } from "../media/actions";
|
|
23
|
+
import MediaImage from "../media/components/MediaImage";
|
|
24
|
+
import MediaUploadForm from "../media/components/MediaUploadForm";
|
|
25
|
+
|
|
26
|
+
type Media = Database["public"]["Tables"]["media"]["Row"];
|
|
27
|
+
|
|
28
|
+
interface FeatureImageFieldProps {
|
|
29
|
+
initialImageId?: string | null;
|
|
30
|
+
initialImageUrl?: string | null;
|
|
31
|
+
onImageIdChange?: (imageId: string | null) => void;
|
|
32
|
+
uploadFolder: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default function FeatureImageField({
|
|
36
|
+
initialImageId,
|
|
37
|
+
initialImageUrl,
|
|
38
|
+
onImageIdChange,
|
|
39
|
+
uploadFolder,
|
|
40
|
+
}: FeatureImageFieldProps) {
|
|
41
|
+
const [selectedFeatureImage, setSelectedFeatureImage] = useState<{
|
|
42
|
+
id: string | null;
|
|
43
|
+
url: string | null;
|
|
44
|
+
}>({
|
|
45
|
+
id: initialImageId || null,
|
|
46
|
+
url: initialImageUrl || null,
|
|
47
|
+
});
|
|
48
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
49
|
+
const [mediaItems, setMediaItems] = useState<Media[]>([]);
|
|
50
|
+
const [mediaLoading, setMediaLoading] = useState(false);
|
|
51
|
+
const [mediaError, setMediaError] = useState<string | null>(null);
|
|
52
|
+
const [mediaPage, setMediaPage] = useState(1);
|
|
53
|
+
const [hasMoreMedia, setHasMoreMedia] = useState(true);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
setSelectedFeatureImage({
|
|
57
|
+
id: initialImageId || null,
|
|
58
|
+
url: initialImageUrl || null,
|
|
59
|
+
});
|
|
60
|
+
}, [initialImageId, initialImageUrl]);
|
|
61
|
+
|
|
62
|
+
const loadMedia = useCallback(
|
|
63
|
+
async (pageToLoad = 1, append = false) => {
|
|
64
|
+
setMediaLoading(true);
|
|
65
|
+
setMediaError(null);
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const result = await getMediaItems(pageToLoad, 20);
|
|
69
|
+
if (result.error) {
|
|
70
|
+
setMediaError(result.error);
|
|
71
|
+
if (!append) setMediaItems([]);
|
|
72
|
+
} else if (result.data) {
|
|
73
|
+
setMediaItems((prev) =>
|
|
74
|
+
append ? [...prev, ...(result.data || [])] : result.data || []
|
|
75
|
+
);
|
|
76
|
+
setHasMoreMedia(result.hasMore !== undefined ? result.hasMore : false);
|
|
77
|
+
setMediaPage(pageToLoad);
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
setMediaError("An unexpected error occurred while fetching media.");
|
|
81
|
+
if (!append) setMediaItems([]);
|
|
82
|
+
} finally {
|
|
83
|
+
setMediaLoading(false);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
[]
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (isModalOpen) {
|
|
91
|
+
setMediaPage(1);
|
|
92
|
+
setHasMoreMedia(true);
|
|
93
|
+
loadMedia(1, false);
|
|
94
|
+
}
|
|
95
|
+
}, [isModalOpen, loadMedia]);
|
|
96
|
+
|
|
97
|
+
const handleImageSelectInModal = (image: Media) => {
|
|
98
|
+
const imageUrl = resolveMediaUrl(image.file_path || image.object_key);
|
|
99
|
+
|
|
100
|
+
if (!imageUrl) {
|
|
101
|
+
setMediaError("Selected image is missing a valid path.");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
setSelectedFeatureImage({ id: image.id, url: imageUrl });
|
|
106
|
+
onImageIdChange?.(image.id);
|
|
107
|
+
setIsModalOpen(false);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const handleRemoveImage = () => {
|
|
111
|
+
setSelectedFeatureImage({ id: null, url: null });
|
|
112
|
+
onImageIdChange?.(null);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const handleImageSelectKeyDown = (event: KeyboardEvent<HTMLDivElement>, image: Media) => {
|
|
116
|
+
if (event.key !== "Enter" && event.key !== " ") {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
handleImageSelectInModal(image);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div>
|
|
126
|
+
<Label htmlFor="feature_image_id">Feature Image</Label>
|
|
127
|
+
<Input type="hidden" id="feature_image_id" name="feature_image_id" value={selectedFeatureImage.id || ""} />
|
|
128
|
+
<div className="mt-2">
|
|
129
|
+
{selectedFeatureImage.url && (
|
|
130
|
+
<div className="mb-4">
|
|
131
|
+
<Image
|
|
132
|
+
src={selectedFeatureImage.url}
|
|
133
|
+
alt="Selected feature image"
|
|
134
|
+
width={200}
|
|
135
|
+
height={200}
|
|
136
|
+
className="rounded-md object-cover"
|
|
137
|
+
/>
|
|
138
|
+
<Button
|
|
139
|
+
type="button"
|
|
140
|
+
variant="link"
|
|
141
|
+
className="mt-2 px-0 text-red-600"
|
|
142
|
+
onClick={handleRemoveImage}
|
|
143
|
+
>
|
|
144
|
+
Remove Image
|
|
145
|
+
</Button>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
<Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>
|
|
149
|
+
<DialogTrigger asChild>
|
|
150
|
+
<Button type="button" variant="outline">
|
|
151
|
+
{selectedFeatureImage.id ? "Change Feature Image" : "Select Feature Image"}
|
|
152
|
+
</Button>
|
|
153
|
+
</DialogTrigger>
|
|
154
|
+
<DialogContent className="flex max-h-[90vh] flex-col sm:max-w-[90vw]">
|
|
155
|
+
<DialogHeader>
|
|
156
|
+
<DialogTitle>Select Feature Image</DialogTitle>
|
|
157
|
+
</DialogHeader>
|
|
158
|
+
<div className="p-1">
|
|
159
|
+
<MediaUploadForm
|
|
160
|
+
returnJustData={true}
|
|
161
|
+
defaultFolder={uploadFolder}
|
|
162
|
+
onUploadSuccess={(newlyUploadedMedia) => {
|
|
163
|
+
setMediaItems((prevItems) => [
|
|
164
|
+
newlyUploadedMedia,
|
|
165
|
+
...prevItems.filter((item) => item.id !== newlyUploadedMedia.id),
|
|
166
|
+
]);
|
|
167
|
+
handleImageSelectInModal(newlyUploadedMedia);
|
|
168
|
+
}}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
171
|
+
<Separator className="my-4" />
|
|
172
|
+
<div className="flex-grow overflow-y-auto py-4" id="media-modal-scroll-area">
|
|
173
|
+
{mediaLoading && mediaItems.length === 0 && (
|
|
174
|
+
<p className="text-center text-muted-foreground">Loading media...</p>
|
|
175
|
+
)}
|
|
176
|
+
{mediaError && <p className="text-center text-red-600">{mediaError}</p>}
|
|
177
|
+
{!mediaLoading && !mediaError && mediaItems.length === 0 && (
|
|
178
|
+
<p className="text-center text-muted-foreground">No media items found. Try uploading some first.</p>
|
|
179
|
+
)}
|
|
180
|
+
|
|
181
|
+
{mediaItems.length > 0 && (
|
|
182
|
+
<div className="grid grid-cols-[repeat(auto-fill,minmax(0,150px))] gap-3">
|
|
183
|
+
{mediaItems.map((item) => {
|
|
184
|
+
const imageUrl = resolveMediaUrl(item.file_path || item.object_key);
|
|
185
|
+
|
|
186
|
+
if (!item.file_type?.startsWith("image/") || !imageUrl) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<div
|
|
192
|
+
key={item.id}
|
|
193
|
+
className="group relative aspect-square cursor-pointer overflow-hidden rounded-lg border bg-muted/20 shadow-sm transition-all hover:ring-2 hover:ring-primary"
|
|
194
|
+
onClick={() => handleImageSelectInModal(item)}
|
|
195
|
+
onKeyDown={(event) => handleImageSelectKeyDown(event, item)}
|
|
196
|
+
tabIndex={0}
|
|
197
|
+
role="button"
|
|
198
|
+
aria-label={`Select ${item.file_name}`}
|
|
199
|
+
>
|
|
200
|
+
<MediaImage
|
|
201
|
+
src={imageUrl}
|
|
202
|
+
alt={item.description || item.file_name}
|
|
203
|
+
width={item.width || 300}
|
|
204
|
+
height={item.height || 300}
|
|
205
|
+
blurDataURL={item.blur_data_url}
|
|
206
|
+
className="h-full w-full object-cover transition-transform group-hover:scale-105"
|
|
207
|
+
/>
|
|
208
|
+
<div className="absolute inset-0 flex flex-col justify-end bg-gradient-to-t from-black/60 via-black/10 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100">
|
|
209
|
+
<p className="truncate text-xs text-white" title={item.file_name}>
|
|
210
|
+
{item.file_name}
|
|
211
|
+
</p>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
})}
|
|
216
|
+
</div>
|
|
217
|
+
)}
|
|
218
|
+
{!mediaLoading && hasMoreMedia && mediaItems.length > 0 && (
|
|
219
|
+
<div className="mt-6 text-center">
|
|
220
|
+
<Button type="button" onClick={() => loadMedia(mediaPage + 1, true)} variant="outline" disabled={mediaLoading}>
|
|
221
|
+
{mediaLoading ? (
|
|
222
|
+
<>
|
|
223
|
+
<Spinner className="mr-2 h-4 w-4" /> Loading...
|
|
224
|
+
</>
|
|
225
|
+
) : (
|
|
226
|
+
"Load More"
|
|
227
|
+
)}
|
|
228
|
+
</Button>
|
|
229
|
+
</div>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
<DialogFooter className="mt-auto border-t pt-4">
|
|
233
|
+
<DialogClose asChild>
|
|
234
|
+
<Button type="button" variant="outline" onClick={() => setMediaError(null)}>
|
|
235
|
+
Cancel
|
|
236
|
+
</Button>
|
|
237
|
+
</DialogClose>
|
|
238
|
+
</DialogFooter>
|
|
239
|
+
</DialogContent>
|
|
240
|
+
</Dialog>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { useState } from "react"
|
|
4
|
-
import { useAuth } from
|
|
3
|
+
import { useEffect, useState } from "react"
|
|
4
|
+
import { useAuth } from '../../../context/AuthContext';
|
|
5
5
|
import { usePathname } from "next/navigation"
|
|
6
6
|
import { toast } from "react-hot-toast"
|
|
7
|
-
import { submitFeedback } from
|
|
7
|
+
import { submitFeedback } from '../../actions/feedback';
|
|
8
8
|
import {
|
|
9
9
|
Dialog,
|
|
10
10
|
DialogContent,
|
|
@@ -29,13 +29,18 @@ interface FeedbackModalProps {
|
|
|
29
29
|
sidebarOpen?: boolean
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function FeedbackModal({ sidebarOpen = true }: FeedbackModalProps) {
|
|
33
|
-
const [
|
|
34
|
-
const [
|
|
35
|
-
const [
|
|
32
|
+
export function FeedbackModal({ sidebarOpen = true }: FeedbackModalProps) {
|
|
33
|
+
const [mounted, setMounted] = useState(false)
|
|
34
|
+
const [open, setOpen] = useState(false)
|
|
35
|
+
const [loading, setLoading] = useState(false)
|
|
36
|
+
const [subject, setSubject] = useState("suggestion")
|
|
36
37
|
const [message, setMessage] = useState("")
|
|
37
|
-
const { user, profile } = useAuth()
|
|
38
|
-
const pathname = usePathname()
|
|
38
|
+
const { user, profile } = useAuth()
|
|
39
|
+
const pathname = usePathname()
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
setMounted(true)
|
|
43
|
+
}, [])
|
|
39
44
|
|
|
40
45
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
41
46
|
e.preventDefault()
|
|
@@ -68,21 +73,30 @@ export function FeedbackModal({ sidebarOpen = true }: FeedbackModalProps) {
|
|
|
68
73
|
} finally {
|
|
69
74
|
setLoading(false)
|
|
70
75
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const trigger = (
|
|
79
|
+
<button
|
|
80
|
+
className={cn(
|
|
81
|
+
"flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-all w-full text-left",
|
|
82
|
+
"text-slate-600 hover:text-primary hover:bg-primary/5 dark:text-slate-300 dark:hover:bg-primary/10"
|
|
83
|
+
)}
|
|
84
|
+
type="button"
|
|
85
|
+
>
|
|
86
|
+
<MessageSquarePlus className="h-5 w-5" />
|
|
87
|
+
{sidebarOpen && <span>Feedback</span>}
|
|
88
|
+
</button>
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
if (!mounted) {
|
|
92
|
+
return trigger
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
97
|
+
<DialogTrigger asChild>
|
|
98
|
+
{trigger}
|
|
99
|
+
</DialogTrigger>
|
|
86
100
|
<DialogContent className="sm:max-w-[425px]">
|
|
87
101
|
<DialogHeader>
|
|
88
102
|
<DialogTitle>Send Feedback</DialogTitle>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EditCouponPage as EditCouponPageUI } from '@nextblock-cms/ecommerce/server';
|
|
2
|
+
import { verifyPackageOnline } from '@nextblock-cms/db/server';
|
|
3
|
+
import { redirect } from 'next/navigation';
|
|
4
|
+
|
|
5
|
+
export default async function EditCouponPage({
|
|
6
|
+
params,
|
|
7
|
+
}: {
|
|
8
|
+
params: Promise<{ id: string }>;
|
|
9
|
+
}) {
|
|
10
|
+
const isOnline = await verifyPackageOnline('ecommerce');
|
|
11
|
+
if (!isOnline) {
|
|
12
|
+
redirect('/cms/settings/packages');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return <EditCouponPageUI params={params} />;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CouponsPage as CouponsPageUI } from '@nextblock-cms/ecommerce/server';
|
|
2
|
+
import { verifyPackageOnline } from '@nextblock-cms/db/server';
|
|
3
|
+
import { redirect } from 'next/navigation';
|
|
4
|
+
|
|
5
|
+
export default async function CouponsPage({
|
|
6
|
+
searchParams,
|
|
7
|
+
}: {
|
|
8
|
+
searchParams: Promise<{ status?: string; q?: string }>;
|
|
9
|
+
}) {
|
|
10
|
+
const isOnline = await verifyPackageOnline('ecommerce');
|
|
11
|
+
if (!isOnline) {
|
|
12
|
+
redirect('/cms/settings/packages');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return <CouponsPageUI searchParams={await searchParams} />;
|
|
16
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Link from "next/link";
|
|
3
|
+
import { ArrowLeft, AlertCircle } from "lucide-react";
|
|
4
|
+
import { Button } from "@nextblock-cms/ui";
|
|
5
|
+
import { BlockComposer } from "../../components/BlockComposer";
|
|
6
|
+
import { getCustomBlockDefinition } from "../../actions";
|
|
7
|
+
|
|
8
|
+
interface EditCustomBlockPageProps {
|
|
9
|
+
params: Promise<{
|
|
10
|
+
id: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const dynamic = "force-dynamic";
|
|
15
|
+
|
|
16
|
+
export default async function EditCustomBlockPage(props: EditCustomBlockPageProps) {
|
|
17
|
+
const params = await props.params;
|
|
18
|
+
const blockId = params.id;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const res = await getCustomBlockDefinition(blockId);
|
|
22
|
+
|
|
23
|
+
if (!res.success || !res.data) {
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex flex-col items-center justify-center text-center py-16 px-4 max-w-md mx-auto">
|
|
26
|
+
<div className="h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center text-destructive mb-4">
|
|
27
|
+
<AlertCircle className="h-6 w-6" />
|
|
28
|
+
</div>
|
|
29
|
+
<h3 className="text-lg font-semibold">Block Not Found</h3>
|
|
30
|
+
<p className="text-sm text-muted-foreground mt-2">
|
|
31
|
+
The custom block definition you are trying to edit could not be loaded. It may have been deleted or does not exist.
|
|
32
|
+
</p>
|
|
33
|
+
<Button asChild className="mt-6" variant="outline">
|
|
34
|
+
<Link href="/cms/custom-blocks">
|
|
35
|
+
<ArrowLeft className="mr-2 h-4 w-4" /> Back to Blocks
|
|
36
|
+
</Link>
|
|
37
|
+
</Button>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div className="w-full">
|
|
44
|
+
<BlockComposer initialData={res.data} mode="edit" />
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error("Error loading custom block definition for edit:", err);
|
|
49
|
+
return (
|
|
50
|
+
<div className="flex flex-col items-center justify-center text-center py-16 px-4 max-w-md mx-auto">
|
|
51
|
+
<div className="h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center text-destructive mb-4">
|
|
52
|
+
<AlertCircle className="h-6 w-6" />
|
|
53
|
+
</div>
|
|
54
|
+
<h3 className="text-lg font-semibold">Unexpected Error</h3>
|
|
55
|
+
<p className="text-sm text-muted-foreground mt-2">
|
|
56
|
+
An error occurred while trying to load the custom block definition. Please try again.
|
|
57
|
+
</p>
|
|
58
|
+
<Button asChild className="mt-6" variant="outline">
|
|
59
|
+
<Link href="/cms/custom-blocks">
|
|
60
|
+
<ArrowLeft className="mr-2 h-4 w-4" /> Back to Blocks
|
|
61
|
+
</Link>
|
|
62
|
+
</Button>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|