create-pet-adopt 0.0.0 → 0.3.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/LICENSE +21 -0
- package/README.md +120 -0
- package/index.js +920 -0
- package/package.json +43 -1
- package/template/.env.example +136 -0
- package/template/.pet-adopt/template.json +581 -0
- package/template/LICENSE +21 -0
- package/template/README.md +109 -0
- package/template/_gitignore +28 -0
- package/template/_pnpm-lock.yaml +9251 -0
- package/template/assets/sample-pet.png +0 -0
- package/template/components.json +25 -0
- package/template/docker-compose.yml +110 -0
- package/template/drizzle/pg/0000_initial.sql +176 -0
- package/template/drizzle/pg/0001_greedy_the_renegades.sql +1 -0
- package/template/drizzle/pg/0002_fuzzy_the_renegades.sql +1 -0
- package/template/drizzle/pg/0003_thin_multiple_man.sql +1 -0
- package/template/drizzle/pg/0004_boring_norman_osborn.sql +15 -0
- package/template/drizzle/pg/0005_bitter_proemial_gods.sql +3 -0
- package/template/drizzle/pg/0006_friendly_black_knight.sql +2 -0
- package/template/drizzle/pg/0007_wise_ozymandias.sql +11 -0
- package/template/drizzle/pg/0008_messy_human_fly.sql +2 -0
- package/template/drizzle/pg/0009_amused_lady_bullseye.sql +1 -0
- package/template/drizzle/pg/0010_cute_mauler.sql +7 -0
- package/template/drizzle/pg/0011_clear_purple_man.sql +3 -0
- package/template/drizzle/pg/0012_tiresome_gunslinger.sql +2 -0
- package/template/drizzle/pg/0013_awesome_wong.sql +18 -0
- package/template/drizzle/pg/0014_fantastic_sumo.sql +12 -0
- package/template/drizzle/pg/0015_pink_carnage.sql +12 -0
- package/template/drizzle/pg/0016_sloppy_king_bedlam.sql +2 -0
- package/template/drizzle/pg/0017_steep_warhawk.sql +15 -0
- package/template/drizzle/pg/0018_mixed_otto_octavius.sql +4 -0
- package/template/drizzle/pg/0019_talented_rocket_raccoon.sql +1 -0
- package/template/drizzle/pg/0020_worthless_zodiak.sql +19 -0
- package/template/drizzle/pg/0021_adorable_squadron_supreme.sql +1 -0
- package/template/drizzle/pg/0022_soft_pixie.sql +5 -0
- package/template/drizzle/pg/0023_fluffy_quasar.sql +1 -0
- package/template/drizzle/pg/0024_uneven_ken_ellis.sql +2 -0
- package/template/drizzle/pg/0025_rich_white_queen.sql +3 -0
- package/template/drizzle/pg/0026_spooky_komodo.sql +16 -0
- package/template/drizzle/pg/0027_big_thunderbolts.sql +2 -0
- package/template/drizzle/pg/meta/0000_snapshot.json +1265 -0
- package/template/drizzle/pg/meta/0001_snapshot.json +1272 -0
- package/template/drizzle/pg/meta/0002_snapshot.json +1278 -0
- package/template/drizzle/pg/meta/0003_snapshot.json +1284 -0
- package/template/drizzle/pg/meta/0004_snapshot.json +1401 -0
- package/template/drizzle/pg/meta/0005_snapshot.json +1401 -0
- package/template/drizzle/pg/meta/0006_snapshot.json +1414 -0
- package/template/drizzle/pg/meta/0007_snapshot.json +1485 -0
- package/template/drizzle/pg/meta/0008_snapshot.json +1504 -0
- package/template/drizzle/pg/meta/0009_snapshot.json +1510 -0
- package/template/drizzle/pg/meta/0010_snapshot.json +1556 -0
- package/template/drizzle/pg/meta/0011_snapshot.json +1574 -0
- package/template/drizzle/pg/meta/0012_snapshot.json +1586 -0
- package/template/drizzle/pg/meta/0013_snapshot.json +1730 -0
- package/template/drizzle/pg/meta/0014_snapshot.json +1805 -0
- package/template/drizzle/pg/meta/0015_snapshot.json +1883 -0
- package/template/drizzle/pg/meta/0016_snapshot.json +1897 -0
- package/template/drizzle/pg/meta/0017_snapshot.json +2013 -0
- package/template/drizzle/pg/meta/0018_snapshot.json +1988 -0
- package/template/drizzle/pg/meta/0019_snapshot.json +1994 -0
- package/template/drizzle/pg/meta/0020_snapshot.json +2108 -0
- package/template/drizzle/pg/meta/0021_snapshot.json +2114 -0
- package/template/drizzle/pg/meta/0022_snapshot.json +2126 -0
- package/template/drizzle/pg/meta/0023_snapshot.json +2132 -0
- package/template/drizzle/pg/meta/0024_snapshot.json +2151 -0
- package/template/drizzle/pg/meta/0025_snapshot.json +2169 -0
- package/template/drizzle/pg/meta/0026_snapshot.json +2294 -0
- package/template/drizzle/pg/meta/0027_snapshot.json +2330 -0
- package/template/drizzle/pg/meta/_journal.json +202 -0
- package/template/drizzle/sqlite/0000_initial.sql +176 -0
- package/template/drizzle/sqlite/0001_easy_sebastian_shaw.sql +1 -0
- package/template/drizzle/sqlite/0002_past_king_cobra.sql +1 -0
- package/template/drizzle/sqlite/0003_organic_masked_marvel.sql +1 -0
- package/template/drizzle/sqlite/0004_panoramic_inhumans.sql +15 -0
- package/template/drizzle/sqlite/0005_small_sunset_bain.sql +19 -0
- package/template/drizzle/sqlite/0006_narrow_medusa.sql +2 -0
- package/template/drizzle/sqlite/0007_gray_grandmaster.sql +10 -0
- package/template/drizzle/sqlite/0008_chief_toxin.sql +1 -0
- package/template/drizzle/sqlite/0009_vengeful_tag.sql +1 -0
- package/template/drizzle/sqlite/0010_kind_klaw.sql +7 -0
- package/template/drizzle/sqlite/0011_overrated_meltdown.sql +3 -0
- package/template/drizzle/sqlite/0012_robust_next_avengers.sql +2 -0
- package/template/drizzle/sqlite/0013_melodic_kitty_pryde.sql +18 -0
- package/template/drizzle/sqlite/0014_stormy_cyclops.sql +12 -0
- package/template/drizzle/sqlite/0015_parallel_mongu.sql +11 -0
- package/template/drizzle/sqlite/0016_grey_quicksilver.sql +2 -0
- package/template/drizzle/sqlite/0017_daily_psylocke.sql +15 -0
- package/template/drizzle/sqlite/0018_whole_redwing.sql +4 -0
- package/template/drizzle/sqlite/0019_spotty_mandroid.sql +1 -0
- package/template/drizzle/sqlite/0020_wild_wendell_rand.sql +19 -0
- package/template/drizzle/sqlite/0021_calm_lockheed.sql +1 -0
- package/template/drizzle/sqlite/0022_lonely_emma_frost.sql +5 -0
- package/template/drizzle/sqlite/0023_elite_tony_stark.sql +1 -0
- package/template/drizzle/sqlite/0024_little_lily_hollister.sql +1 -0
- package/template/drizzle/sqlite/0025_tough_shotgun.sql +3 -0
- package/template/drizzle/sqlite/0026_faithful_mephistopheles.sql +16 -0
- package/template/drizzle/sqlite/0027_rapid_arclight.sql +2 -0
- package/template/drizzle/sqlite/meta/0000_snapshot.json +1237 -0
- package/template/drizzle/sqlite/meta/0001_snapshot.json +1245 -0
- package/template/drizzle/sqlite/meta/0002_snapshot.json +1252 -0
- package/template/drizzle/sqlite/meta/0003_snapshot.json +1259 -0
- package/template/drizzle/sqlite/meta/0004_snapshot.json +1369 -0
- package/template/drizzle/sqlite/meta/0005_snapshot.json +1369 -0
- package/template/drizzle/sqlite/meta/0006_snapshot.json +1384 -0
- package/template/drizzle/sqlite/meta/0007_snapshot.json +1459 -0
- package/template/drizzle/sqlite/meta/0008_snapshot.json +1479 -0
- package/template/drizzle/sqlite/meta/0009_snapshot.json +1486 -0
- package/template/drizzle/sqlite/meta/0010_snapshot.json +1533 -0
- package/template/drizzle/sqlite/meta/0011_snapshot.json +1554 -0
- package/template/drizzle/sqlite/meta/0012_snapshot.json +1568 -0
- package/template/drizzle/sqlite/meta/0013_snapshot.json +1687 -0
- package/template/drizzle/sqlite/meta/0014_snapshot.json +1769 -0
- package/template/drizzle/sqlite/meta/0015_snapshot.json +1852 -0
- package/template/drizzle/sqlite/meta/0016_snapshot.json +1867 -0
- package/template/drizzle/sqlite/meta/0017_snapshot.json +1973 -0
- package/template/drizzle/sqlite/meta/0018_snapshot.json +1944 -0
- package/template/drizzle/sqlite/meta/0019_snapshot.json +1951 -0
- package/template/drizzle/sqlite/meta/0020_snapshot.json +2077 -0
- package/template/drizzle/sqlite/meta/0021_snapshot.json +2084 -0
- package/template/drizzle/sqlite/meta/0022_snapshot.json +2098 -0
- package/template/drizzle/sqlite/meta/0023_snapshot.json +2105 -0
- package/template/drizzle/sqlite/meta/0024_snapshot.json +2125 -0
- package/template/drizzle/sqlite/meta/0025_snapshot.json +2146 -0
- package/template/drizzle/sqlite/meta/0026_snapshot.json +2265 -0
- package/template/drizzle/sqlite/meta/0027_snapshot.json +2280 -0
- package/template/drizzle/sqlite/meta/_journal.json +202 -0
- package/template/drizzle.pg.config.ts +8 -0
- package/template/drizzle.sqlite.config.ts +8 -0
- package/template/eslint.config.mjs +22 -0
- package/template/next.config.ts +153 -0
- package/template/package.json +102 -0
- package/template/pet-adopt.blocks.ts +9 -0
- package/template/pet-adopt.config.ts +17 -0
- package/template/pnpm-workspace.yaml +19 -0
- package/template/postcss.config.mjs +5 -0
- package/template/scripts/check-routes.ts +405 -0
- package/template/scripts/check-schemas.ts +58 -0
- package/template/scripts/migrate-all.ts +25 -0
- package/template/scripts/migrate-on-build.ts +71 -0
- package/template/scripts/migrate.ts +20 -0
- package/template/scripts/plugin-generate.ts +92 -0
- package/template/scripts/reset-password.ts +45 -0
- package/template/scripts/reset-two-factor.ts +53 -0
- package/template/scripts/seed.ts +79 -0
- package/template/scripts/setup-env.ts +91 -0
- package/template/scripts/storage-check.ts +53 -0
- package/template/src/app/(admin)/admin/account/AccountForms.tsx +194 -0
- package/template/src/app/(admin)/admin/account/page.tsx +59 -0
- package/template/src/app/(admin)/admin/activity/page.tsx +76 -0
- package/template/src/app/(admin)/admin/authentication/archived/page.tsx +24 -0
- package/template/src/app/(admin)/admin/authentication/layout.tsx +20 -0
- package/template/src/app/(admin)/admin/authentication/page.tsx +36 -0
- package/template/src/app/(admin)/admin/authentication/providers/page.tsx +33 -0
- package/template/src/app/(admin)/admin/email/layout.tsx +21 -0
- package/template/src/app/(admin)/admin/email/page.tsx +43 -0
- package/template/src/app/(admin)/admin/email/templates/page.tsx +38 -0
- package/template/src/app/(admin)/admin/error.tsx +36 -0
- package/template/src/app/(admin)/admin/layout.tsx +26 -0
- package/template/src/app/(admin)/admin/loading.tsx +9 -0
- package/template/src/app/(admin)/admin/media/[id]/page.tsx +97 -0
- package/template/src/app/(admin)/admin/media/page.tsx +34 -0
- package/template/src/app/(admin)/admin/media/search-params.ts +16 -0
- package/template/src/app/(admin)/admin/page.tsx +79 -0
- package/template/src/app/(admin)/admin/pages/PageForm.tsx +604 -0
- package/template/src/app/(admin)/admin/pages/[id]/page.tsx +51 -0
- package/template/src/app/(admin)/admin/pages/new/page.tsx +19 -0
- package/template/src/app/(admin)/admin/pages/page.tsx +49 -0
- package/template/src/app/(admin)/admin/pets/PetForm.tsx +437 -0
- package/template/src/app/(admin)/admin/pets/[id]/page.tsx +41 -0
- package/template/src/app/(admin)/admin/pets/new/page.tsx +26 -0
- package/template/src/app/(admin)/admin/pets/page.tsx +70 -0
- package/template/src/app/(admin)/admin/pets/search-params.ts +16 -0
- package/template/src/app/(admin)/admin/plugins/[plugin]/[[...path]]/page.tsx +73 -0
- package/template/src/app/(admin)/admin/plugins/page.tsx +66 -0
- package/template/src/app/(admin)/admin/settings/SettingsForm.tsx +644 -0
- package/template/src/app/(admin)/admin/settings/email/page.tsx +9 -0
- package/template/src/app/(admin)/admin/settings/page.tsx +40 -0
- package/template/src/app/(admin)/admin/settings/templates/page.tsx +9 -0
- package/template/src/app/(admin)/admin/theme/[id]/page.tsx +28 -0
- package/template/src/app/(admin)/admin/theme/page.tsx +30 -0
- package/template/src/app/(admin)/admin/users/page.tsx +33 -0
- package/template/src/app/(admin)/layout.tsx +75 -0
- package/template/src/app/(admin)/providers.tsx +42 -0
- package/template/src/app/(auth)/admin/confirm-email/page.tsx +40 -0
- package/template/src/app/(auth)/admin/invite/page.tsx +38 -0
- package/template/src/app/(auth)/admin/login/DemoSignIn.tsx +69 -0
- package/template/src/app/(auth)/admin/login/page.tsx +83 -0
- package/template/src/app/(auth)/admin/reset-password/page.tsx +73 -0
- package/template/src/app/(auth)/error.tsx +9 -0
- package/template/src/app/(auth)/layout.tsx +71 -0
- package/template/src/app/(editor)/EditorToast.tsx +43 -0
- package/template/src/app/(editor)/edit/[id]/PageEditor.tsx +586 -0
- package/template/src/app/(editor)/edit/[id]/actions.ts +139 -0
- package/template/src/app/(editor)/edit/[id]/page.tsx +76 -0
- package/template/src/app/(editor)/edit/[id]/preview/page.tsx +81 -0
- package/template/src/app/(editor)/edit/email/[id]/EmailEditor.tsx +236 -0
- package/template/src/app/(editor)/edit/email/[id]/page.tsx +64 -0
- package/template/src/app/(editor)/edit/theme-preview/page.tsx +94 -0
- package/template/src/app/(editor)/editor.css +223 -0
- package/template/src/app/(editor)/error.tsx +32 -0
- package/template/src/app/(editor)/layout.tsx +67 -0
- package/template/src/app/(frontend)/[slug]/page.tsx +53 -0
- package/template/src/app/(frontend)/fonts.ts +8 -0
- package/template/src/app/(frontend)/layout.tsx +107 -0
- package/template/src/app/(frontend)/not-found.tsx +16 -0
- package/template/src/app/(frontend)/page.tsx +42 -0
- package/template/src/app/(frontend)/pets/[slug]/page.tsx +92 -0
- package/template/src/app/(frontend)/pets/page.tsx +42 -0
- package/template/src/app/(frontend)/styles.css +537 -0
- package/template/src/app/(setup)/error.tsx +9 -0
- package/template/src/app/(setup)/layout.tsx +41 -0
- package/template/src/app/(setup)/setup/page.tsx +105 -0
- package/template/src/app/(setup)/setup/storage-check.ts +43 -0
- package/template/src/app/api/auth/[...all]/route.ts +144 -0
- package/template/src/app/health/route.ts +9 -0
- package/template/src/app/media/[...path]/route.ts +45 -0
- package/template/src/app/media/email/[name]/route.ts +60 -0
- package/template/src/app/robots.ts +19 -0
- package/template/src/app/sitemap.ts +24 -0
- package/template/src/components/admin/AdminNav.tsx +153 -0
- package/template/src/components/admin/AdminShell.tsx +107 -0
- package/template/src/components/admin/DemoNotice.tsx +31 -0
- package/template/src/components/admin/EmailConfirmBanner.tsx +44 -0
- package/template/src/components/admin/EmptyState.tsx +10 -0
- package/template/src/components/admin/ErrorSummary.tsx +72 -0
- package/template/src/components/admin/MediaDetails.tsx +218 -0
- package/template/src/components/admin/MediaGrid.tsx +307 -0
- package/template/src/components/admin/MediaLibrary.tsx +103 -0
- package/template/src/components/admin/MediaPager.tsx +66 -0
- package/template/src/components/admin/PageHeader.tsx +22 -0
- package/template/src/components/admin/PhoneInput.tsx +128 -0
- package/template/src/components/admin/PluginWidgetBoundary.tsx +38 -0
- package/template/src/components/admin/PluginWidgets.tsx +51 -0
- package/template/src/components/admin/RemountOnNavigate.tsx +37 -0
- package/template/src/components/admin/StatusBadge.tsx +16 -0
- package/template/src/components/admin/UploadPhotosDialog.tsx +387 -0
- package/template/src/components/admin/UserAvatar.tsx +18 -0
- package/template/src/components/admin/UserMenu.tsx +118 -0
- package/template/src/components/admin/ViewSiteLink.tsx +24 -0
- package/template/src/components/admin/account/ConnectedProviders.tsx +91 -0
- package/template/src/components/admin/account/DeleteAccountCard.tsx +136 -0
- package/template/src/components/admin/account/EmailCard.tsx +137 -0
- package/template/src/components/admin/account/ProfilePicture.tsx +159 -0
- package/template/src/components/admin/activity/ActivityFilters.tsx +146 -0
- package/template/src/components/admin/activity/ActivityLog.tsx +159 -0
- package/template/src/components/admin/activity/RecentActivity.tsx +52 -0
- package/template/src/components/admin/demo-mode.tsx +17 -0
- package/template/src/components/admin/nav-items.ts +47 -0
- package/template/src/components/admin/pages/PageDetails.tsx +198 -0
- package/template/src/components/admin/pages/PageVersions.tsx +296 -0
- package/template/src/components/admin/pages/PagesTable.tsx +467 -0
- package/template/src/components/admin/pets/FilterBar.tsx +154 -0
- package/template/src/components/admin/pets/PetCard.tsx +170 -0
- package/template/src/components/admin/pets/PetList.tsx +112 -0
- package/template/src/components/admin/pets/PetListSkeleton.tsx +84 -0
- package/template/src/components/admin/pets/PetPagination.tsx +91 -0
- package/template/src/components/admin/pets/form/AgeFields.tsx +132 -0
- package/template/src/components/admin/pets/form/LocationFields.tsx +231 -0
- package/template/src/components/admin/pets/form/MediaPickerDialog.tsx +359 -0
- package/template/src/components/admin/pets/form/PhotosField.tsx +176 -0
- package/template/src/components/admin/pets/form/RichTextField.tsx +438 -0
- package/template/src/components/admin/pets/form/SeoImageField.tsx +87 -0
- package/template/src/components/admin/pets/form/SeoPreview.tsx +142 -0
- package/template/src/components/admin/pets/form/fields.tsx +434 -0
- package/template/src/components/admin/pets/form/rich-text-extensions.ts +45 -0
- package/template/src/components/admin/pets/timeline/PetTimeline.tsx +297 -0
- package/template/src/components/admin/pets/timeline/TimelineEntryForm.tsx +289 -0
- package/template/src/components/admin/pets/timeline/TimelinePhotosField.tsx +173 -0
- package/template/src/components/admin/plugins/PluginNotReady.tsx +28 -0
- package/template/src/components/admin/plugins/PluginOverview.tsx +121 -0
- package/template/src/components/admin/plugins/SendTestEmail.tsx +70 -0
- package/template/src/components/admin/settings/AuthProviders.tsx +373 -0
- package/template/src/components/admin/settings/AuthenticationNav.tsx +42 -0
- package/template/src/components/admin/settings/EmailNav.tsx +40 -0
- package/template/src/components/admin/settings/EmailSettingsForm.tsx +325 -0
- package/template/src/components/admin/settings/EmailTemplates.tsx +551 -0
- package/template/src/components/admin/settings/RegionFields.tsx +203 -0
- package/template/src/components/admin/site-time.tsx +26 -0
- package/template/src/components/admin/theme/ThemeEditor.tsx +467 -0
- package/template/src/components/admin/theme/ThemeLibrary.tsx +339 -0
- package/template/src/components/admin/theme/ThemeSwatches.tsx +30 -0
- package/template/src/components/admin/theme/theme-utils.ts +32 -0
- package/template/src/components/admin/two-factor/BackupCodeList.tsx +54 -0
- package/template/src/components/admin/two-factor/TwoFactorCard.tsx +237 -0
- package/template/src/components/admin/two-factor/TwoFactorRequired.tsx +52 -0
- package/template/src/components/admin/two-factor/TwoFactorSetup.tsx +180 -0
- package/template/src/components/admin/use-unsaved-changes.tsx +101 -0
- package/template/src/components/admin/users/ArchivedAccounts.tsx +159 -0
- package/template/src/components/admin/users/InviteDialogs.tsx +131 -0
- package/template/src/components/admin/users/TwoFactorRoles.tsx +80 -0
- package/template/src/components/admin/users/UserDialogs.tsx +681 -0
- package/template/src/components/admin/users/UsersTable.tsx +374 -0
- package/template/src/components/admin/view-only.tsx +43 -0
- package/template/src/components/auth/AcceptInviteForm.tsx +123 -0
- package/template/src/components/auth/AuthNav.tsx +80 -0
- package/template/src/components/auth/ConfirmEmailForm.tsx +73 -0
- package/template/src/components/auth/LoginForm.tsx +250 -0
- package/template/src/components/auth/PageError.tsx +37 -0
- package/template/src/components/auth/ProviderSignIn.tsx +53 -0
- package/template/src/components/auth/ResetPasswordForm.tsx +267 -0
- package/template/src/components/demo/DemoBanner.tsx +38 -0
- package/template/src/components/demo/SiteDemoBanner.tsx +22 -0
- package/template/src/components/demo/wording.ts +21 -0
- package/template/src/components/setup/SetupAccountForm.tsx +93 -0
- package/template/src/components/setup/SetupDone.tsx +95 -0
- package/template/src/components/setup/SetupNav.tsx +49 -0
- package/template/src/components/setup/SetupSampleContent.tsx +67 -0
- package/template/src/components/setup/SetupSiteForm.tsx +104 -0
- package/template/src/components/setup/SetupThemePicker.tsx +73 -0
- package/template/src/components/setup/SkipSetup.tsx +35 -0
- package/template/src/components/site/BuilderContent.tsx +46 -0
- package/template/src/components/site/CopyButton.tsx +28 -0
- package/template/src/components/site/ImageCarousel.tsx +52 -0
- package/template/src/components/site/PetCard.tsx +32 -0
- package/template/src/components/site/PetCatalog.tsx +106 -0
- package/template/src/components/site/PetGallery.tsx +75 -0
- package/template/src/components/site/PetTimeline.tsx +82 -0
- package/template/src/components/site/RemountOnNavigate.tsx +13 -0
- package/template/src/components/site/RichText.tsx +56 -0
- package/template/src/components/site/SmartLink.tsx +37 -0
- package/template/src/components/site/SocialIcons.tsx +26 -0
- package/template/src/components/site/ThemePreviewBridge.tsx +29 -0
- package/template/src/components/site/ThemeStyle.tsx +22 -0
- package/template/src/components/site/ThemeToggle.tsx +36 -0
- package/template/src/components/site/WhatsAppButton.tsx +27 -0
- package/template/src/components/site/timeline-format.ts +20 -0
- package/template/src/db/client.ts +702 -0
- package/template/src/db/compare-tables.ts +41 -0
- package/template/src/db/migrate.ts +28 -0
- package/template/src/db/plugin-migrations.ts +167 -0
- package/template/src/db/schema/pg.ts +484 -0
- package/template/src/db/schema/sqlite.ts +492 -0
- package/template/src/instrumentation.ts +110 -0
- package/template/src/lib/activity.ts +29 -0
- package/template/src/lib/admin/call-action.ts +19 -0
- package/template/src/lib/admin/initials.ts +9 -0
- package/template/src/lib/admin/media-cache.ts +16 -0
- package/template/src/lib/admin/media-page.ts +3 -0
- package/template/src/lib/admin/pet-form.ts +242 -0
- package/template/src/lib/admin/pets-cache.ts +22 -0
- package/template/src/lib/admin/unwrap-client.ts +11 -0
- package/template/src/lib/admin/unwrap.ts +38 -0
- package/template/src/lib/admin/use-media-list.ts +41 -0
- package/template/src/lib/admin/use-pet-list.ts +58 -0
- package/template/src/lib/age.ts +117 -0
- package/template/src/lib/auth-provider-errors.ts +38 -0
- package/template/src/lib/cache.ts +69 -0
- package/template/src/lib/color-mode.ts +48 -0
- package/template/src/lib/demo.ts +78 -0
- package/template/src/lib/email-address.ts +9 -0
- package/template/src/lib/email-template.ts +691 -0
- package/template/src/lib/links.ts +78 -0
- package/template/src/lib/mail-error.ts +38 -0
- package/template/src/lib/media-name.ts +31 -0
- package/template/src/lib/options.ts +134 -0
- package/template/src/lib/pagination.ts +28 -0
- package/template/src/lib/pet-placeholders.ts +34 -0
- package/template/src/lib/pet-seo.ts +40 -0
- package/template/src/lib/pet-timeline.ts +62 -0
- package/template/src/lib/phone.ts +129 -0
- package/template/src/lib/places.ts +84 -0
- package/template/src/lib/queries.ts +549 -0
- package/template/src/lib/revalidate.ts +32 -0
- package/template/src/lib/rich-text.ts +215 -0
- package/template/src/lib/seo.ts +121 -0
- package/template/src/lib/slugify.ts +11 -0
- package/template/src/lib/theme.ts +546 -0
- package/template/src/lib/utils.ts +2 -0
- package/template/src/lib/whatsapp.ts +29 -0
- package/template/src/lib/zod-schema/auth.ts +56 -0
- package/template/src/lib/zod-schema/page.ts +57 -0
- package/template/src/lib/zod-schema/pet-timeline.ts +118 -0
- package/template/src/lib/zod-schema/pet.ts +172 -0
- package/template/src/lib/zod-schema/settings.ts +162 -0
- package/template/src/plugins/host.ts +117 -0
- package/template/src/plugins/icon.ts +89 -0
- package/template/src/plugins/registry.ts +369 -0
- package/template/src/plugins/storage-rules.ts +87 -0
- package/template/src/plugins/storage.ts +184 -0
- package/template/src/puck/actions.ts +46 -0
- package/template/src/puck/config.tsx +1693 -0
- package/template/src/puck/data.ts +196 -0
- package/template/src/puck/demo-mode.tsx +20 -0
- package/template/src/puck/email-config.tsx +267 -0
- package/template/src/puck/icons.tsx +76 -0
- package/template/src/puck/media-picker.tsx +273 -0
- package/template/src/puck/padding.tsx +71 -0
- package/template/src/puck/pet-page-config.tsx +511 -0
- package/template/src/puck/pet-picker.tsx +40 -0
- package/template/src/puck/plugin-block-data.ts +91 -0
- package/template/src/puck/plugin-blocks.tsx +235 -0
- package/template/src/puck/plugin-choice-field.tsx +87 -0
- package/template/src/puck/sanitize.ts +107 -0
- package/template/src/puck/server.ts +36 -0
- package/template/src/puck/types.ts +41 -0
- package/template/src/server/actions/activity.ts +48 -0
- package/template/src/server/actions/auth-providers.ts +171 -0
- package/template/src/server/actions/auth.ts +217 -0
- package/template/src/server/actions/demo.ts +30 -0
- package/template/src/server/actions/email-change.ts +80 -0
- package/template/src/server/actions/email-templates.ts +144 -0
- package/template/src/server/actions/email.ts +70 -0
- package/template/src/server/actions/media.ts +127 -0
- package/template/src/server/actions/pages.ts +159 -0
- package/template/src/server/actions/password-reset.ts +80 -0
- package/template/src/server/actions/pet-timeline.ts +75 -0
- package/template/src/server/actions/pets.ts +74 -0
- package/template/src/server/actions/places.ts +36 -0
- package/template/src/server/actions/settings.ts +29 -0
- package/template/src/server/actions/setup.ts +72 -0
- package/template/src/server/actions/themes.ts +80 -0
- package/template/src/server/actions/two-factor.ts +306 -0
- package/template/src/server/actions/users.ts +200 -0
- package/template/src/server/activity.ts +409 -0
- package/template/src/server/auth-errors.ts +17 -0
- package/template/src/server/auth-providers.ts +359 -0
- package/template/src/server/auth.ts +266 -0
- package/template/src/server/avatars.ts +263 -0
- package/template/src/server/demo-site.ts +169 -0
- package/template/src/server/email-change.ts +278 -0
- package/template/src/server/email-templates.ts +350 -0
- package/template/src/server/email.ts +442 -0
- package/template/src/server/invites.ts +143 -0
- package/template/src/server/media-url.ts +20 -0
- package/template/src/server/media.ts +236 -0
- package/template/src/server/pages.ts +812 -0
- package/template/src/server/password-reset.ts +158 -0
- package/template/src/server/pending-links.ts +46 -0
- package/template/src/server/pet-timeline.ts +181 -0
- package/template/src/server/pets.ts +555 -0
- package/template/src/server/places.ts +113 -0
- package/template/src/server/privacy.ts +21 -0
- package/template/src/server/provider-endpoints.ts +94 -0
- package/template/src/server/provider-guard.ts +157 -0
- package/template/src/server/result.ts +280 -0
- package/template/src/server/sample-content.ts +368 -0
- package/template/src/server/search-text.ts +43 -0
- package/template/src/server/secret-box.ts +38 -0
- package/template/src/server/session.ts +154 -0
- package/template/src/server/settings.ts +361 -0
- package/template/src/server/setup.ts +110 -0
- package/template/src/server/sitemap.ts +88 -0
- package/template/src/server/storage.ts +267 -0
- package/template/src/server/strip-metadata.ts +357 -0
- package/template/src/server/themes.ts +195 -0
- package/template/src/server/throttle.ts +258 -0
- package/template/src/server/two-factor-codes.ts +32 -0
- package/template/src/server/two-factor.ts +158 -0
- package/template/src/server/types.ts +198 -0
- package/template/src/server/uploads.ts +137 -0
- package/template/src/server/users.ts +500 -0
- package/template/tsconfig.json +44 -0
- package/template/ui/components.json +25 -0
- package/template/ui/package.json +12 -0
- package/template/ui/src/components/alert-dialog.tsx +187 -0
- package/template/ui/src/components/avatar.tsx +108 -0
- package/template/ui/src/components/badge.tsx +51 -0
- package/template/ui/src/components/button.tsx +57 -0
- package/template/ui/src/components/card.tsx +102 -0
- package/template/ui/src/components/carousel.tsx +245 -0
- package/template/ui/src/components/checkbox.tsx +27 -0
- package/template/ui/src/components/combobox.tsx +297 -0
- package/template/ui/src/components/dialog.tsx +159 -0
- package/template/ui/src/components/dropdown-menu.tsx +265 -0
- package/template/ui/src/components/field.tsx +238 -0
- package/template/ui/src/components/input-group.tsx +158 -0
- package/template/ui/src/components/input.tsx +19 -0
- package/template/ui/src/components/label.tsx +19 -0
- package/template/ui/src/components/pagination.tsx +127 -0
- package/template/ui/src/components/popover.tsx +89 -0
- package/template/ui/src/components/radio-group.tsx +37 -0
- package/template/ui/src/components/select.tsx +200 -0
- package/template/ui/src/components/separator.tsx +24 -0
- package/template/ui/src/components/sheet.tsx +138 -0
- package/template/ui/src/components/sidebar.tsx +723 -0
- package/template/ui/src/components/skeleton.tsx +13 -0
- package/template/ui/src/components/switch.tsx +31 -0
- package/template/ui/src/components/table.tsx +115 -0
- package/template/ui/src/components/tabs.tsx +81 -0
- package/template/ui/src/components/textarea.tsx +17 -0
- package/template/ui/src/components/toggle.tsx +44 -0
- package/template/ui/src/components/tooltip.tsx +65 -0
- package/template/ui/src/hooks/use-mobile.ts +21 -0
- package/template/ui/src/lib/utils.ts +2 -0
- package/template/ui/src/styles/globals.css +145 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { cn } from '@pet-adopt/ui/lib/utils'
|
|
4
|
+
|
|
5
|
+
import { DEMO_DOCS_URL, demoNotice } from './wording'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The demo notice in the admin and on the sign-in screens (PET_ADOPT_DEMO=1): a slim band at the top
|
|
9
|
+
* of the page, in the page flow, in the theme's caution colours (--warn-bg / --warn-ink, readable in
|
|
10
|
+
* light and dark). A server component with no state: the layout decides whether to draw it.
|
|
11
|
+
*
|
|
12
|
+
* `besideSidebar` (the admin): the desktop sidebar is fixed to the window's left edge from the top,
|
|
13
|
+
* so it covers the band's left part. While an expanded desktop sidebar is on the page, the text
|
|
14
|
+
* starts after it (16rem, shadcn's sidebar width, plus the usual gutter); with the sidebar collapsed,
|
|
15
|
+
* on phones (a sheet) and on screens without it, at the edge. Scrolling, the band moves away and the
|
|
16
|
+
* admin's sticky header sticks at the top as before.
|
|
17
|
+
*/
|
|
18
|
+
export function DemoBanner({ resetMinutes, besideSidebar = false }: { resetMinutes: number; besideSidebar?: boolean }) {
|
|
19
|
+
return (
|
|
20
|
+
<section
|
|
21
|
+
aria-label="About this demo"
|
|
22
|
+
className={cn(
|
|
23
|
+
'w-full border-b border-border bg-(--warn-bg) px-4 py-1.5 text-sm text-(--warn-ink)',
|
|
24
|
+
besideSidebar && 'md:in-[body:has([data-slot=sidebar][data-state=expanded])]:pl-[17rem]',
|
|
25
|
+
)}
|
|
26
|
+
>
|
|
27
|
+
<p>
|
|
28
|
+
{demoNotice(resetMinutes)}{' '}
|
|
29
|
+
<a
|
|
30
|
+
href={DEMO_DOCS_URL}
|
|
31
|
+
className="rounded-sm font-semibold text-inherit underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current"
|
|
32
|
+
>
|
|
33
|
+
Read the docs
|
|
34
|
+
</a>
|
|
35
|
+
</p>
|
|
36
|
+
</section>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { DEMO_DOCS_URL, demoNotice } from './wording'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The demo notice on the public site and in the page and email builders (PET_ADOPT_DEMO=1): a slim
|
|
7
|
+
* band at the very top, in the page flow. Plain CSS on the theme's variables (`.demo-bar` rules in
|
|
8
|
+
* src/app/(frontend)/styles.css, which the editor layout loads too), because neither layout loads
|
|
9
|
+
* Tailwind. A server component with no state: the layout decides whether to draw it.
|
|
10
|
+
*
|
|
11
|
+
* `editor`: the builders' variant, full width and left-aligned like Puck's header. The editor layout
|
|
12
|
+
* also draws the previews shown in frames inside the admin; those leave it out (see styles.css).
|
|
13
|
+
*/
|
|
14
|
+
export function SiteDemoBanner({ resetMinutes, editor = false }: { resetMinutes: number; editor?: boolean }) {
|
|
15
|
+
return (
|
|
16
|
+
<section aria-label="About this demo" className={editor ? 'demo-bar demo-bar-editor' : 'demo-bar'}>
|
|
17
|
+
<p className={editor ? 'demo-bar-inner' : 'container demo-bar-inner'}>
|
|
18
|
+
{demoNotice(resetMinutes)} <a href={DEMO_DOCS_URL}>Read the docs</a>
|
|
19
|
+
</p>
|
|
20
|
+
</section>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// What the demo banners say (PET_ADOPT_DEMO=1, see src/lib/demo.ts). Pure: no server imports, so the
|
|
2
|
+
// public site, the builder, the admin and the sign-in page share it.
|
|
3
|
+
|
|
4
|
+
/** Where the banners send visitors who want Pet Adopt for themselves. */
|
|
5
|
+
export const DEMO_DOCS_URL = 'https://pet-adopt.dev'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* How often the demo is filled with the sample content again, as words: 60 minutes is "every hour",
|
|
9
|
+
* 1 is "every minute", 120 is "every 2 hours", 90 is "every 90 minutes".
|
|
10
|
+
*/
|
|
11
|
+
export function resetPhrase(minutes: number): string {
|
|
12
|
+
if (!Number.isInteger(minutes) || minutes < 1) return 'regularly'
|
|
13
|
+
if (minutes === 1) return 'every minute'
|
|
14
|
+
if (minutes === 60) return 'every hour'
|
|
15
|
+
if (minutes % 60 === 0) return `every ${minutes / 60} hours`
|
|
16
|
+
return `every ${minutes} minutes`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The banner's sentence, before its link. */
|
|
20
|
+
export const demoNotice = (resetMinutes: number) =>
|
|
21
|
+
`This is the Pet Adopt demo. Changes are shared with other visitors and reset ${resetPhrase(resetMinutes)}.`
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { Controller, useForm } from "react-hook-form";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
import { Button } from "@pet-adopt/ui/components/button";
|
|
10
|
+
import { Card, CardContent, CardFooter, CardHeader } from "@pet-adopt/ui/components/card";
|
|
11
|
+
import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from "@pet-adopt/ui/components/field";
|
|
12
|
+
import { Input } from "@pet-adopt/ui/components/input";
|
|
13
|
+
import { createFirstAdminAction } from "@/server/actions/setup";
|
|
14
|
+
|
|
15
|
+
// Setup step 1: the first admin account, with the key from the setup link (src/server/setup.ts).
|
|
16
|
+
// On success they are signed in and go on to the site's basics.
|
|
17
|
+
|
|
18
|
+
const schemaFor = (minLength: number) =>
|
|
19
|
+
z
|
|
20
|
+
.object({
|
|
21
|
+
name: z.string().trim().min(1, "Enter your name").max(80, "Use at most 80 characters"),
|
|
22
|
+
email: z.email("Enter a valid email address"),
|
|
23
|
+
password: z.string().min(minLength, `Use at least ${minLength} characters`).max(128, "Use at most 128 characters"),
|
|
24
|
+
confirm: z.string(),
|
|
25
|
+
})
|
|
26
|
+
.refine((v) => v.password === v.confirm, { path: ["confirm"], message: "The passwords do not match" });
|
|
27
|
+
type Values = z.infer<ReturnType<typeof schemaFor>>;
|
|
28
|
+
|
|
29
|
+
export function SetupAccountForm({ setupKey, minPasswordLength }: { setupKey: string; minPasswordLength: number }) {
|
|
30
|
+
const router = useRouter();
|
|
31
|
+
const form = useForm<Values>({ resolver: zodResolver(schemaFor(minPasswordLength)), defaultValues: { name: "", email: "", password: "", confirm: "" } });
|
|
32
|
+
|
|
33
|
+
const onSubmit = async (values: Values) => {
|
|
34
|
+
const result = await createFirstAdminAction({ key: setupKey, name: values.name, email: values.email, password: values.password });
|
|
35
|
+
if (result.ok) {
|
|
36
|
+
router.replace("/setup?step=site");
|
|
37
|
+
router.refresh();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let placed = false;
|
|
41
|
+
for (const [name, message] of Object.entries(result.fieldErrors ?? {})) {
|
|
42
|
+
if (name === "name" || name === "email" || name === "password") {
|
|
43
|
+
form.setError(name, { message });
|
|
44
|
+
placed = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!placed) form.setError("root", { message: result.error });
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const text = (name: "name" | "email" | "password" | "confirm", label: string, type: string, autoComplete: string, hint?: string) => (
|
|
51
|
+
<Controller
|
|
52
|
+
name={name}
|
|
53
|
+
control={form.control}
|
|
54
|
+
render={({ field, fieldState }) => (
|
|
55
|
+
<Field data-invalid={fieldState.invalid}>
|
|
56
|
+
<FieldLabel htmlFor={`setup-${name}`}>{label}</FieldLabel>
|
|
57
|
+
<Input id={`setup-${name}`} type={type} autoComplete={autoComplete} aria-invalid={fieldState.invalid} aria-describedby={hint ? `setup-${name}-hint` : undefined} {...field} />
|
|
58
|
+
{hint ? <FieldDescription id={`setup-${name}-hint`}>{hint}</FieldDescription> : null}
|
|
59
|
+
{fieldState.invalid && <FieldError errors={[fieldState.error]} />}
|
|
60
|
+
</Field>
|
|
61
|
+
)}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Card>
|
|
67
|
+
<CardHeader>
|
|
68
|
+
<h1 className="text-xl font-semibold">Create your admin account</h1>
|
|
69
|
+
<p className="text-sm text-muted-foreground">This is the first account of the site. It can do everything, including adding other people later.</p>
|
|
70
|
+
</CardHeader>
|
|
71
|
+
<CardContent>
|
|
72
|
+
<form id="setup-account-form" noValidate onSubmit={form.handleSubmit(onSubmit)}>
|
|
73
|
+
<FieldGroup>
|
|
74
|
+
{form.formState.errors.root?.message ? (
|
|
75
|
+
<p role="alert" className="text-sm text-destructive">
|
|
76
|
+
{form.formState.errors.root.message}
|
|
77
|
+
</p>
|
|
78
|
+
) : null}
|
|
79
|
+
{text("name", "Your name", "text", "name")}
|
|
80
|
+
{text("email", "Email", "email", "username", "You sign in with it. Reset links go there.")}
|
|
81
|
+
{text("password", "Password", "password", "new-password", `At least ${minPasswordLength} characters.`)}
|
|
82
|
+
{text("confirm", "Repeat password", "password", "new-password")}
|
|
83
|
+
</FieldGroup>
|
|
84
|
+
</form>
|
|
85
|
+
</CardContent>
|
|
86
|
+
<CardFooter className="justify-end">
|
|
87
|
+
<Button type="submit" form="setup-account-form" aria-disabled={form.formState.isSubmitting || undefined}>
|
|
88
|
+
{form.formState.isSubmitting ? "Creating…" : "Create account"}
|
|
89
|
+
</Button>
|
|
90
|
+
</CardFooter>
|
|
91
|
+
</Card>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
import { Button } from "@pet-adopt/ui/components/button";
|
|
8
|
+
import { EmailConfirmBanner } from "@/components/admin/EmailConfirmBanner";
|
|
9
|
+
import { finishSetupAction } from "@/server/actions/setup";
|
|
10
|
+
|
|
11
|
+
// Setup's last step: what is ready, what is left, and where to go next. Finishing ends the setup.
|
|
12
|
+
|
|
13
|
+
export function SetupDone({
|
|
14
|
+
storage,
|
|
15
|
+
emailReady,
|
|
16
|
+
needsConfirmation,
|
|
17
|
+
email,
|
|
18
|
+
}: {
|
|
19
|
+
/** From a test write to the bucket: where uploads go, and what failed (null when it worked). */
|
|
20
|
+
storage: { description: string | null; problem: string | null };
|
|
21
|
+
emailReady: boolean;
|
|
22
|
+
needsConfirmation: boolean;
|
|
23
|
+
email: string;
|
|
24
|
+
}) {
|
|
25
|
+
const router = useRouter();
|
|
26
|
+
const [pending, startTransition] = React.useTransition();
|
|
27
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
28
|
+
|
|
29
|
+
function finish() {
|
|
30
|
+
if (pending) return;
|
|
31
|
+
startTransition(async () => {
|
|
32
|
+
const result = await finishSetupAction({});
|
|
33
|
+
if (!result.ok) return setError(result.error);
|
|
34
|
+
router.replace("/admin");
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const checks = [
|
|
39
|
+
{
|
|
40
|
+
ok: !storage.problem,
|
|
41
|
+
label: storage.problem
|
|
42
|
+
? `Image storage does not work yet${storage.description ? ` (${storage.description})` : ""}: uploads will fail until the S3_* settings are right. ${storage.problem}`
|
|
43
|
+
: `Image storage works (${storage.description}).`,
|
|
44
|
+
},
|
|
45
|
+
{ ok: emailReady, label: emailReady ? "Email is set up." : "Email is not set up: no reset links, invites or form notifications until it is (Settings > Email)." },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<section className="flex flex-col gap-5">
|
|
50
|
+
<div>
|
|
51
|
+
<h1 className="text-xl font-semibold">You’re ready</h1>
|
|
52
|
+
<p className="text-sm text-muted-foreground">Here is what is set up, and some good next steps.</p>
|
|
53
|
+
</div>
|
|
54
|
+
<ul className="flex flex-col gap-2 text-sm">
|
|
55
|
+
{checks.map((check) => (
|
|
56
|
+
<li key={check.label} className="flex gap-2">
|
|
57
|
+
<span aria-hidden="true">{check.ok ? "✓" : "!"}</span>
|
|
58
|
+
<span>
|
|
59
|
+
<span className="sr-only">{check.ok ? "Done: " : "To do: "}</span>
|
|
60
|
+
{check.label}
|
|
61
|
+
</span>
|
|
62
|
+
</li>
|
|
63
|
+
))}
|
|
64
|
+
</ul>
|
|
65
|
+
{needsConfirmation ? <EmailConfirmBanner email={email} /> : null}
|
|
66
|
+
<div className="flex flex-col gap-2 text-sm">
|
|
67
|
+
<h2 className="font-medium">Next steps</h2>
|
|
68
|
+
<ul className="list-disc pl-5">
|
|
69
|
+
<li>
|
|
70
|
+
<Link href="/admin/pets/new" className="underline underline-offset-4">Add your first pet</Link>
|
|
71
|
+
</li>
|
|
72
|
+
<li>
|
|
73
|
+
<Link href="/admin/users" className="underline underline-offset-4">Invite your team</Link>
|
|
74
|
+
</li>
|
|
75
|
+
<li>
|
|
76
|
+
<Link href="/admin/account" className="underline underline-offset-4">Turn on two-factor sign-in</Link> for your account
|
|
77
|
+
</li>
|
|
78
|
+
<li>
|
|
79
|
+
<Link href="/admin/settings" className="underline underline-offset-4">Finish your site settings</Link>: logo, address, opening hours, menu
|
|
80
|
+
</li>
|
|
81
|
+
</ul>
|
|
82
|
+
</div>
|
|
83
|
+
{error ? (
|
|
84
|
+
<p role="alert" className="text-sm text-destructive">
|
|
85
|
+
{error}
|
|
86
|
+
</p>
|
|
87
|
+
) : null}
|
|
88
|
+
<div className="flex justify-end">
|
|
89
|
+
<Button type="button" onClick={finish} aria-disabled={pending || undefined}>
|
|
90
|
+
{pending ? "Finishing…" : "Go to the admin"}
|
|
91
|
+
</Button>
|
|
92
|
+
</div>
|
|
93
|
+
</section>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Link from 'next/link'
|
|
2
|
+
import { FiCheck } from 'react-icons/fi'
|
|
3
|
+
|
|
4
|
+
// The steps of the first-time setup, in order (src/app/(setup)/setup/page.tsx). Steps after the
|
|
5
|
+
// account are links, so any can be visited or skipped.
|
|
6
|
+
export const SETUP_STEPS = [
|
|
7
|
+
{ key: 'account', label: 'Your account' },
|
|
8
|
+
{ key: 'site', label: 'Your site' },
|
|
9
|
+
{ key: 'theme', label: 'Theme' },
|
|
10
|
+
{ key: 'sample', label: 'Sample content' },
|
|
11
|
+
{ key: 'email', label: 'Email' },
|
|
12
|
+
{ key: 'done', label: 'Done' },
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export type SetupStep = (typeof SETUP_STEPS)[number]['key']
|
|
16
|
+
|
|
17
|
+
export function SetupNav({ current }: { current: SetupStep }) {
|
|
18
|
+
const index = SETUP_STEPS.findIndex((step) => step.key === current)
|
|
19
|
+
return (
|
|
20
|
+
<nav aria-label="Setup steps">
|
|
21
|
+
<ol className="flex flex-wrap gap-x-4 gap-y-1 text-sm">
|
|
22
|
+
{SETUP_STEPS.map((step, i) => {
|
|
23
|
+
const here = step.key === current
|
|
24
|
+
const linkable = current !== 'account' && step.key !== 'account'
|
|
25
|
+
const done = i < index
|
|
26
|
+
// Steps before this one are passed (done or skipped): a tick, and words for screen readers.
|
|
27
|
+
const label = (
|
|
28
|
+
<>
|
|
29
|
+
{done ? <FiCheck aria-hidden className="mr-1 inline size-3.5" /> : null}
|
|
30
|
+
{`${i + 1}. ${step.label}`}
|
|
31
|
+
{done ? <span className="sr-only"> (done or skipped)</span> : null}
|
|
32
|
+
</>
|
|
33
|
+
)
|
|
34
|
+
return (
|
|
35
|
+
<li key={step.key} className={here ? 'font-semibold text-foreground' : 'text-muted-foreground'}>
|
|
36
|
+
{linkable && !here ? (
|
|
37
|
+
<Link href={`/setup?step=${step.key}`} className="underline underline-offset-4 hover:text-foreground">
|
|
38
|
+
{label}
|
|
39
|
+
</Link>
|
|
40
|
+
) : (
|
|
41
|
+
<span aria-current={here ? 'step' : undefined}>{label}</span>
|
|
42
|
+
)}
|
|
43
|
+
</li>
|
|
44
|
+
)
|
|
45
|
+
})}
|
|
46
|
+
</ol>
|
|
47
|
+
</nav>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useRouter } from "next/navigation";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
import { Button } from "@pet-adopt/ui/components/button";
|
|
8
|
+
import { addSampleContentAction, removeSampleContentAction } from "@/server/actions/setup";
|
|
9
|
+
|
|
10
|
+
// Setup step 4: example pets (with placeholder pictures) and an About page, so the site is not empty
|
|
11
|
+
// while you get going. They can be taken out again here, or deleted one by one later.
|
|
12
|
+
|
|
13
|
+
export function SetupSampleContent({ hasSample }: { hasSample: boolean }) {
|
|
14
|
+
const router = useRouter();
|
|
15
|
+
const [message, setMessage] = React.useState<{ text: string; isError: boolean } | null>(null);
|
|
16
|
+
const [pending, startTransition] = React.useTransition();
|
|
17
|
+
|
|
18
|
+
function add() {
|
|
19
|
+
if (pending) return;
|
|
20
|
+
startTransition(async () => {
|
|
21
|
+
const result = await addSampleContentAction();
|
|
22
|
+
if (!result.ok) return setMessage({ text: result.error, isError: true });
|
|
23
|
+
router.push("/setup?step=email");
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function remove() {
|
|
28
|
+
if (pending) return;
|
|
29
|
+
startTransition(async () => {
|
|
30
|
+
const result = await removeSampleContentAction();
|
|
31
|
+
setMessage(result.ok ? { text: `Removed ${result.data.pets} example pets.`, isError: false } : { text: result.error, isError: true });
|
|
32
|
+
router.refresh();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<section className="flex flex-col gap-4">
|
|
38
|
+
<div>
|
|
39
|
+
<h1 className="text-xl font-semibold">Sample content</h1>
|
|
40
|
+
<p className="text-sm text-muted-foreground">
|
|
41
|
+
Add a few example pets with placeholder pictures and an About page, to see how the site looks before your own pets are in. You can take them out
|
|
42
|
+
again later.
|
|
43
|
+
</p>
|
|
44
|
+
</div>
|
|
45
|
+
{message ? (
|
|
46
|
+
<p role={message.isError ? "alert" : "status"} className={`text-sm ${message.isError ? "text-destructive" : ""}`}>
|
|
47
|
+
{message.text}
|
|
48
|
+
</p>
|
|
49
|
+
) : null}
|
|
50
|
+
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
51
|
+
<Link href="/setup?step=email" className="text-sm underline underline-offset-4">
|
|
52
|
+
{hasSample ? "Continue" : "Skip this step"}
|
|
53
|
+
</Link>
|
|
54
|
+
<span className="flex flex-wrap gap-2">
|
|
55
|
+
{hasSample ? (
|
|
56
|
+
<Button type="button" variant="outline" onClick={remove} aria-disabled={pending || undefined}>
|
|
57
|
+
Remove sample content
|
|
58
|
+
</Button>
|
|
59
|
+
) : null}
|
|
60
|
+
<Button type="button" onClick={add} aria-disabled={pending || undefined}>
|
|
61
|
+
{pending ? "Working…" : hasSample ? "Add any that are missing" : "Add sample content"}
|
|
62
|
+
</Button>
|
|
63
|
+
</span>
|
|
64
|
+
</div>
|
|
65
|
+
</section>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useRouter } from "next/navigation";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
import { Button } from "@pet-adopt/ui/components/button";
|
|
8
|
+
import { Card, CardContent, CardFooter, CardHeader } from "@pet-adopt/ui/components/card";
|
|
9
|
+
import { Field, FieldDescription, FieldGroup, FieldLabel } from "@pet-adopt/ui/components/field";
|
|
10
|
+
import { Input } from "@pet-adopt/ui/components/input";
|
|
11
|
+
import { PhoneInput } from "@/components/admin/PhoneInput";
|
|
12
|
+
import { updateSettingsAction } from "@/server/actions/settings";
|
|
13
|
+
import type { SiteSetting } from "@/server/types";
|
|
14
|
+
|
|
15
|
+
// Setup step 2: the site's name, tagline and WhatsApp number (everything else is on Site settings).
|
|
16
|
+
// The server checks the values as on Site settings, and the number uses the same country picker, so
|
|
17
|
+
// it is sent with its country code (E.164) rather than read as the default country's.
|
|
18
|
+
|
|
19
|
+
export function SetupSiteForm({ settings }: { settings: SiteSetting }) {
|
|
20
|
+
const router = useRouter();
|
|
21
|
+
const [values, setValues] = React.useState({ siteName: settings.siteName, tagline: settings.tagline ?? "", whatsappNumber: settings.whatsappNumber ?? "" });
|
|
22
|
+
const [errors, setErrors] = React.useState<Record<string, string>>({});
|
|
23
|
+
const [formError, setFormError] = React.useState<string | null>(null);
|
|
24
|
+
const [pending, startTransition] = React.useTransition();
|
|
25
|
+
const set = (key: keyof typeof values) => (event: React.ChangeEvent<HTMLInputElement>) => setValues((v) => ({ ...v, [key]: event.target.value }));
|
|
26
|
+
|
|
27
|
+
function submit(event: React.FormEvent) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
if (pending) return;
|
|
30
|
+
startTransition(async () => {
|
|
31
|
+
const result = await updateSettingsAction({ siteName: values.siteName, tagline: values.tagline, whatsappNumber: values.whatsappNumber });
|
|
32
|
+
if (!result.ok) {
|
|
33
|
+
setErrors(result.fieldErrors ?? {});
|
|
34
|
+
setFormError(result.fieldErrors && Object.keys(result.fieldErrors).length ? null : result.error);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
router.push("/setup?step=theme");
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const describedBy = (key: keyof typeof values) => `setup-${key}-hint${errors[key] ? ` setup-${key}-error` : ""}`;
|
|
42
|
+
const errorText = (key: keyof typeof values) =>
|
|
43
|
+
errors[key] ? (
|
|
44
|
+
<p id={`setup-${key}-error`} className="text-sm text-destructive">
|
|
45
|
+
{errors[key]}
|
|
46
|
+
</p>
|
|
47
|
+
) : null;
|
|
48
|
+
|
|
49
|
+
const field = (key: keyof typeof values, label: string, hint: string, opts: { required?: boolean } = {}) => (
|
|
50
|
+
<Field data-invalid={errors[key] ? true : undefined}>
|
|
51
|
+
<FieldLabel htmlFor={`setup-${key}`}>
|
|
52
|
+
{label}
|
|
53
|
+
{opts.required ? <span className="font-normal text-muted-foreground"> (required)</span> : null}
|
|
54
|
+
</FieldLabel>
|
|
55
|
+
<Input id={`setup-${key}`} value={values[key]} onChange={set(key)} aria-invalid={errors[key] ? true : undefined} aria-describedby={describedBy(key)} />
|
|
56
|
+
<FieldDescription id={`setup-${key}-hint`}>{hint}</FieldDescription>
|
|
57
|
+
{errorText(key)}
|
|
58
|
+
</Field>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Card>
|
|
63
|
+
<CardHeader>
|
|
64
|
+
<h1 className="text-xl font-semibold">Your site</h1>
|
|
65
|
+
<p className="text-sm text-muted-foreground">The basics visitors see. Logo, address, menu and more are on Site settings later.</p>
|
|
66
|
+
</CardHeader>
|
|
67
|
+
<CardContent>
|
|
68
|
+
<form id="setup-site-form" noValidate onSubmit={submit}>
|
|
69
|
+
<FieldGroup>
|
|
70
|
+
{formError ? (
|
|
71
|
+
<p role="alert" className="text-sm text-destructive">
|
|
72
|
+
{formError}
|
|
73
|
+
</p>
|
|
74
|
+
) : null}
|
|
75
|
+
{field("siteName", "Site name", "Shown at the top of every page and in browser tabs.", { required: true })}
|
|
76
|
+
{field("tagline", "Tagline", "A short line under the name, like “Every pet deserves a loving home”.")}
|
|
77
|
+
<Field data-invalid={errors.whatsappNumber ? true : undefined}>
|
|
78
|
+
<FieldLabel htmlFor="setup-whatsappNumber">WhatsApp number</FieldLabel>
|
|
79
|
+
<PhoneInput
|
|
80
|
+
id="setup-whatsappNumber"
|
|
81
|
+
value={values.whatsappNumber}
|
|
82
|
+
onChange={(whatsappNumber) => setValues((v) => ({ ...v, whatsappNumber }))}
|
|
83
|
+
invalid={Boolean(errors.whatsappNumber)}
|
|
84
|
+
describedBy={describedBy("whatsappNumber")}
|
|
85
|
+
/>
|
|
86
|
+
<FieldDescription id="setup-whatsappNumber-hint">
|
|
87
|
+
Where visitors message you about a pet. Pick the country, then type the number; you can also paste one starting with +.
|
|
88
|
+
</FieldDescription>
|
|
89
|
+
{errorText("whatsappNumber")}
|
|
90
|
+
</Field>
|
|
91
|
+
</FieldGroup>
|
|
92
|
+
</form>
|
|
93
|
+
</CardContent>
|
|
94
|
+
<CardFooter className="flex justify-between gap-3">
|
|
95
|
+
<Link href="/setup?step=theme" className="text-sm underline underline-offset-4">
|
|
96
|
+
Skip this step
|
|
97
|
+
</Link>
|
|
98
|
+
<Button type="submit" form="setup-site-form" aria-disabled={pending || undefined}>
|
|
99
|
+
{pending ? "Saving…" : "Save and continue"}
|
|
100
|
+
</Button>
|
|
101
|
+
</CardFooter>
|
|
102
|
+
</Card>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useRouter } from "next/navigation";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
import { Button } from "@pet-adopt/ui/components/button";
|
|
8
|
+
import { PRESETS, PRESET_KEYS, type PresetKey } from "@/lib/theme";
|
|
9
|
+
import { activateThemeAction } from "@/server/actions/themes";
|
|
10
|
+
|
|
11
|
+
// Setup step 3: one of the built-in looks. Colours, fonts and shapes can be changed on Theme later.
|
|
12
|
+
|
|
13
|
+
export function SetupThemePicker({ current }: { current: string }) {
|
|
14
|
+
const router = useRouter();
|
|
15
|
+
const [picked, setPicked] = React.useState<PresetKey>((PRESET_KEYS as string[]).includes(current) ? (current as PresetKey) : "sunrise");
|
|
16
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
17
|
+
const [pending, startTransition] = React.useTransition();
|
|
18
|
+
|
|
19
|
+
function save() {
|
|
20
|
+
if (pending) return;
|
|
21
|
+
startTransition(async () => {
|
|
22
|
+
const result = await activateThemeAction({ preset: picked });
|
|
23
|
+
if (!result.ok) return setError(result.error);
|
|
24
|
+
router.push("/setup?step=sample");
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<section className="flex flex-col gap-4">
|
|
30
|
+
<div>
|
|
31
|
+
<h1 className="text-xl font-semibold">Pick a look</h1>
|
|
32
|
+
<p className="text-sm text-muted-foreground">You can change colours, fonts and shapes on Theme later.</p>
|
|
33
|
+
</div>
|
|
34
|
+
{error ? (
|
|
35
|
+
<p role="alert" className="text-sm text-destructive">
|
|
36
|
+
{error}
|
|
37
|
+
</p>
|
|
38
|
+
) : null}
|
|
39
|
+
<fieldset>
|
|
40
|
+
<legend className="sr-only">Themes</legend>
|
|
41
|
+
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
|
42
|
+
{PRESET_KEYS.map((key) => {
|
|
43
|
+
const preset = PRESETS[key];
|
|
44
|
+
const light = preset.light as { primary: string; bg: string; ink: string; tint?: string };
|
|
45
|
+
return (
|
|
46
|
+
<label
|
|
47
|
+
key={key}
|
|
48
|
+
className={`flex cursor-pointer flex-col gap-2 rounded-lg border p-3 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-ring ${picked === key ? "border-primary ring-2 ring-primary" : ""}`}
|
|
49
|
+
>
|
|
50
|
+
<input type="radio" name="theme" value={key} checked={picked === key} onChange={() => setPicked(key)} className="sr-only" />
|
|
51
|
+
{/* A small preview in the theme's own light colours. */}
|
|
52
|
+
<span aria-hidden="true" className="flex h-16 items-end gap-2 rounded-md border p-2" style={{ background: light.bg, color: light.ink }}>
|
|
53
|
+
<span className="text-sm font-bold">Aa</span>
|
|
54
|
+
<span className="ml-auto h-6 w-16 rounded" style={{ background: light.primary }} />
|
|
55
|
+
</span>
|
|
56
|
+
<span className="font-medium">{preset.label}</span>
|
|
57
|
+
<span className="text-sm text-muted-foreground">{preset.description}</span>
|
|
58
|
+
</label>
|
|
59
|
+
);
|
|
60
|
+
})}
|
|
61
|
+
</div>
|
|
62
|
+
</fieldset>
|
|
63
|
+
<div className="flex justify-between gap-3">
|
|
64
|
+
<Link href="/setup?step=sample" className="text-sm underline underline-offset-4">
|
|
65
|
+
Skip this step
|
|
66
|
+
</Link>
|
|
67
|
+
<Button type="button" onClick={save} aria-disabled={pending || undefined}>
|
|
68
|
+
{pending ? "Saving…" : "Use this look"}
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
</section>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useRouter } from "next/navigation";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
import { finishSetupAction } from "@/server/actions/setup";
|
|
7
|
+
|
|
8
|
+
/** "Skip the rest of the setup": ends it for good (everything stays in the normal settings). */
|
|
9
|
+
export function SkipSetup() {
|
|
10
|
+
const router = useRouter();
|
|
11
|
+
const [pending, startTransition] = React.useTransition();
|
|
12
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
13
|
+
|
|
14
|
+
function skip() {
|
|
15
|
+
if (pending) return;
|
|
16
|
+
startTransition(async () => {
|
|
17
|
+
const result = await finishSetupAction({ skipped: true });
|
|
18
|
+
if (!result.ok) return setError(result.error);
|
|
19
|
+
router.replace("/admin");
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className="flex flex-col items-center gap-1 border-t pt-4 text-sm">
|
|
25
|
+
<button type="button" onClick={skip} aria-disabled={pending || undefined} className="text-muted-foreground underline underline-offset-4">
|
|
26
|
+
{pending ? "Skipping…" : "Skip the rest of the setup"}
|
|
27
|
+
</button>
|
|
28
|
+
{error ? (
|
|
29
|
+
<p role="alert" className="text-destructive">
|
|
30
|
+
{error}
|
|
31
|
+
</p>
|
|
32
|
+
) : null}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Config, Data } from '@puckeditor/core'
|
|
2
|
+
import { Render, resolveAllData } from '@puckeditor/core/rsc'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
import { config } from '@/puck/config'
|
|
6
|
+
import { assignHeadingLevels } from '@/puck/data'
|
|
7
|
+
import { sanitizeLayout } from '@/puck/sanitize'
|
|
8
|
+
import type { CatalogParams, PetPageData } from '@/lib/queries'
|
|
9
|
+
import { petPageConfig } from '@/puck/pet-page-config'
|
|
10
|
+
import { buildSiteMetadata } from '@/puck/server'
|
|
11
|
+
|
|
12
|
+
// The typed config is widened here: saved JSON can't be checked against block types at compile time.
|
|
13
|
+
const looseConfig = config as unknown as Config
|
|
14
|
+
const loosePetConfig = petPageConfig as unknown as Config
|
|
15
|
+
|
|
16
|
+
// Renders saved Puck JSON on the server. Blocks that need live data (like the pet grid)
|
|
17
|
+
// are resolved here, so visitors get plain HTML with no editor code in the bundle.
|
|
18
|
+
//
|
|
19
|
+
// Heading structure: after the live data is in, the first heading on the page becomes its one
|
|
20
|
+
// <h1> and the rest follow from it (see assignHeadingLevels). A page with no headings at all gets a
|
|
21
|
+
// visually hidden <h1> with its `title`, so every page has exactly one.
|
|
22
|
+
export async function BuilderContent({
|
|
23
|
+
data,
|
|
24
|
+
title,
|
|
25
|
+
searchParams,
|
|
26
|
+
pet,
|
|
27
|
+
}: {
|
|
28
|
+
data: Data
|
|
29
|
+
title?: string
|
|
30
|
+
/** The page's query string, for blocks that read it (the Pet catalogue's filters). */
|
|
31
|
+
searchParams?: CatalogParams
|
|
32
|
+
/** A pet's page: draws `data` (the Pet page template) with the pet blocks, for this pet. */
|
|
33
|
+
pet?: PetPageData
|
|
34
|
+
}) {
|
|
35
|
+
const metadata = await buildSiteMetadata(searchParams, pet)
|
|
36
|
+
const blocks = pet ? loosePetConfig : looseConfig
|
|
37
|
+
// Checked again when drawn: a layout stored before the check existed must not break a page.
|
|
38
|
+
const resolved = await resolveAllData(sanitizeLayout(data, blocks), blocks, metadata)
|
|
39
|
+
const { data: leveled, hasH1 } = assignHeadingLevels(resolved)
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{!hasH1 && title ? <h1 className="sr-only">{title}</h1> : null}
|
|
43
|
+
<Render config={blocks} data={leveled} metadata={metadata} />
|
|
44
|
+
</>
|
|
45
|
+
)
|
|
46
|
+
}
|