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,511 @@
|
|
|
1
|
+
// The Pet page template's blocks (agreed with the owner): one layout, edited like any page, that
|
|
2
|
+
// draws every pet's page at /pets/<slug>. Its own block set: the pet blocks below only make sense
|
|
3
|
+
// where there is a pet, and they read it from Puck's metadata (`metadata.pet`: the pet in the
|
|
4
|
+
// address on the site, the "Preview with" pet in the editor). Around them, a curated few of the
|
|
5
|
+
// ordinary blocks (Text, Adoption steps, FAQ, Cost table, Call to action, Divider, Spacer), and the
|
|
6
|
+
// plugin blocks that ask to be offered here (`petPage` in pet-adopt.blocks.ts: the form builder's
|
|
7
|
+
// Form block), under "Plugins".
|
|
8
|
+
//
|
|
9
|
+
// Same rules as src/puck/config.tsx: no hooks or browser-only code (blocks render on the server and
|
|
10
|
+
// in the editor), headings through the heading helpers, and resolved props listed in
|
|
11
|
+
// TRANSIENT_PROPS (`similar`).
|
|
12
|
+
import Image from 'next/image'
|
|
13
|
+
import React from 'react'
|
|
14
|
+
import type { Config, Fields } from '@puckeditor/core'
|
|
15
|
+
|
|
16
|
+
import { PetCard } from '@/components/site/PetCard'
|
|
17
|
+
import { PetGallery } from '@/components/site/PetGallery'
|
|
18
|
+
import { PetTimeline } from '@/components/site/PetTimeline'
|
|
19
|
+
import { RichText } from '@/components/site/RichText'
|
|
20
|
+
import { WhatsAppButton } from '@/components/site/WhatsAppButton'
|
|
21
|
+
import type { PetCardData, PetPageData } from '@/lib/queries'
|
|
22
|
+
import { fillPetPlaceholders } from '@/lib/pet-placeholders'
|
|
23
|
+
import { compareTimelineNewestFirst, TIMELINE_ALIGNMENTS, type TimelineAlignment, type TimelineEntry } from '@/lib/pet-timeline'
|
|
24
|
+
import { fillMessage } from '@/lib/whatsapp'
|
|
25
|
+
|
|
26
|
+
import { config as siteConfig, headingClass, headingStyleField, Section, type HeadingStyle, type Level, type PuckComponents } from './config'
|
|
27
|
+
import { classToken } from './sanitize'
|
|
28
|
+
import { withPadding } from './padding'
|
|
29
|
+
import { withPluginBlocks } from './plugin-blocks'
|
|
30
|
+
import pluginBlocks from '../../pet-adopt.blocks'
|
|
31
|
+
import type { PuckSiteMetadata } from './types'
|
|
32
|
+
|
|
33
|
+
type Meta = { metadata: Record<string, unknown>; isEditing?: boolean }
|
|
34
|
+
const petOf = (puck: Meta) => (puck.metadata as Partial<PuckSiteMetadata>).pet ?? null
|
|
35
|
+
const siteOf = (puck: Meta) => (puck.metadata as Partial<PuckSiteMetadata>).site
|
|
36
|
+
|
|
37
|
+
/** In the editor before a pet is picked: says what the block will show. */
|
|
38
|
+
function NoPet({ what }: { what: string }) {
|
|
39
|
+
return (
|
|
40
|
+
<Section>
|
|
41
|
+
<p className="muted">{what} appears here. Pick a pet in “Preview with” to see it.</p>
|
|
42
|
+
</Section>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type PetGalleryProps = { thumbnails?: 'below' | 'above' }
|
|
47
|
+
type PetSummaryProps = Level & {
|
|
48
|
+
headingStyle?: HeadingStyle
|
|
49
|
+
/** The pet's main photo beside the summary. Missing means none (the original look). */
|
|
50
|
+
photo?: 'none' | 'left' | 'right'
|
|
51
|
+
/** The main photo's shape. Missing (or anything unknown) means rounded, the original look. */
|
|
52
|
+
photoShape?: 'rounded' | 'sharp' | 'round'
|
|
53
|
+
showStatus?: boolean
|
|
54
|
+
showFacts?: boolean
|
|
55
|
+
}
|
|
56
|
+
/** How the two sections of Pet health / Pet personality sit: side by side or one under the other. */
|
|
57
|
+
type ListsLayout = { layout?: 'columns' | 'rows'; rowGap?: 'default' | 'sm' | 'md' | 'lg' }
|
|
58
|
+
type PetHealthProps = Level & ListsLayout & {
|
|
59
|
+
heading?: string
|
|
60
|
+
showChecks?: boolean
|
|
61
|
+
showNotes?: boolean
|
|
62
|
+
}
|
|
63
|
+
type PetPersonalityProps = Level & ListsLayout & {
|
|
64
|
+
heading?: string
|
|
65
|
+
showTemperament?: boolean
|
|
66
|
+
showGoodWith?: boolean
|
|
67
|
+
showNotes?: boolean
|
|
68
|
+
}
|
|
69
|
+
type PetTimelineProps = Level & {
|
|
70
|
+
heading?: string
|
|
71
|
+
/** Where the line is: left, right, or the centre with entries taking turns. Missing means left. */
|
|
72
|
+
align?: TimelineAlignment
|
|
73
|
+
order?: 'newest' | 'oldest'
|
|
74
|
+
/** Entries shown before "Show all updates"; 0 means all of them. */
|
|
75
|
+
limit?: number
|
|
76
|
+
showPhotos?: boolean
|
|
77
|
+
showTime?: boolean
|
|
78
|
+
/** Render-only (resolveData): this pet has no updates. Never saved. */
|
|
79
|
+
empty?: boolean
|
|
80
|
+
}
|
|
81
|
+
type PetDescriptionProps = { showButton?: boolean; buttonLabel?: string }
|
|
82
|
+
type MorePetsProps = Level & {
|
|
83
|
+
heading?: string
|
|
84
|
+
count?: number
|
|
85
|
+
/** Resolved at render (metadata.fetchSimilarPets); never saved (TRANSIENT_PROPS). */
|
|
86
|
+
similar?: PetCardData[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type PetPageComponents = Pick<PuckComponents, 'TextSection' | 'AdoptionSteps' | 'Faq' | 'CostTable' | 'CallToAction' | 'Divider' | 'Spacer'> & {
|
|
90
|
+
PetGallery: PetGalleryProps
|
|
91
|
+
PetSummary: PetSummaryProps
|
|
92
|
+
PetHealth: PetHealthProps
|
|
93
|
+
PetPersonality: PetPersonalityProps
|
|
94
|
+
PetDescription: PetDescriptionProps
|
|
95
|
+
PetTimeline: PetTimelineProps
|
|
96
|
+
MorePets: MorePetsProps
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const toggle = (label: string) =>
|
|
100
|
+
({
|
|
101
|
+
type: 'radio',
|
|
102
|
+
label,
|
|
103
|
+
options: [
|
|
104
|
+
{ label: 'Show', value: true },
|
|
105
|
+
{ label: 'Hide', value: false },
|
|
106
|
+
],
|
|
107
|
+
}) as const
|
|
108
|
+
|
|
109
|
+
/** The facts list: only what the pet has. */
|
|
110
|
+
function facts(pet: PetPageData): Array<[string, string]> {
|
|
111
|
+
const rows: Array<[string, string | null]> = [
|
|
112
|
+
['Species', pet.speciesLabel],
|
|
113
|
+
['Breed', pet.breed],
|
|
114
|
+
['Sex', pet.sexLabel],
|
|
115
|
+
['Age', pet.ageLabel],
|
|
116
|
+
['Size', pet.sizeLabel],
|
|
117
|
+
['Colour', pet.color],
|
|
118
|
+
['Location', pet.location],
|
|
119
|
+
]
|
|
120
|
+
return rows.filter((row): row is [string, string] => Boolean(row[1]))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The Health and Personality blocks: an optional heading, then up to two short sections side by
|
|
125
|
+
* side. Section titles sit one level below the block's heading (or at block level without one).
|
|
126
|
+
*/
|
|
127
|
+
const listsLayoutFields = {
|
|
128
|
+
layout: {
|
|
129
|
+
type: 'radio',
|
|
130
|
+
label: 'Layout',
|
|
131
|
+
options: [
|
|
132
|
+
{ label: 'Side by side', value: 'columns' },
|
|
133
|
+
{ label: 'Stacked', value: 'rows' },
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
rowGap: {
|
|
137
|
+
type: 'select',
|
|
138
|
+
label: 'Gap between rows',
|
|
139
|
+
options: [
|
|
140
|
+
{ label: 'Default', value: 'default' },
|
|
141
|
+
{ label: 'Small', value: 'sm' },
|
|
142
|
+
{ label: 'Medium', value: 'md' },
|
|
143
|
+
{ label: 'Large', value: 'lg' },
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
} as const
|
|
147
|
+
|
|
148
|
+
function ListsBlock({
|
|
149
|
+
heading,
|
|
150
|
+
headingLevel,
|
|
151
|
+
sections,
|
|
152
|
+
empty,
|
|
153
|
+
isEditing,
|
|
154
|
+
layout,
|
|
155
|
+
rowGap,
|
|
156
|
+
}: Level & ListsLayout & {
|
|
157
|
+
heading?: string
|
|
158
|
+
sections: Array<{ title: string; items?: string[]; notes?: PetPageData['healthNotes'] }>
|
|
159
|
+
empty: string
|
|
160
|
+
isEditing?: boolean
|
|
161
|
+
}) {
|
|
162
|
+
const shown = sections.filter((section) => section.items?.length || section.notes)
|
|
163
|
+
if (!shown.length) return isEditing ? <NoPet what={empty} /> : <></>
|
|
164
|
+
const title = heading?.trim()
|
|
165
|
+
const Title = headingLevel === 1 ? 'h1' : 'h2'
|
|
166
|
+
const Sub = title ? (headingLevel === 1 ? 'h2' : 'h3') : 'h2'
|
|
167
|
+
return (
|
|
168
|
+
<Section>
|
|
169
|
+
{title ? <Title className="block-heading">{title}</Title> : null}
|
|
170
|
+
{/* Stacked, or side by side (which also stacks when there is no room): the row gap applies to both. */}
|
|
171
|
+
<div className={layout === 'rows' ? 'pet-page-lists pet-page-lists-rows' : 'pet-page-lists'} data-row-gap={rowGap && rowGap !== 'default' ? rowGap : undefined}>
|
|
172
|
+
{shown.map((section) => (
|
|
173
|
+
<section key={section.title} className="pet-profile-list">
|
|
174
|
+
<Sub className="minor-heading">{section.title}</Sub>
|
|
175
|
+
{section.items?.length ? (
|
|
176
|
+
<ul>
|
|
177
|
+
{section.items.map((item) => (
|
|
178
|
+
<li key={item}>{item}</li>
|
|
179
|
+
))}
|
|
180
|
+
</ul>
|
|
181
|
+
) : null}
|
|
182
|
+
{section.notes ? <RichText doc={section.notes} className="pet-notes" /> : null}
|
|
183
|
+
</section>
|
|
184
|
+
))}
|
|
185
|
+
</div>
|
|
186
|
+
</Section>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const shared = siteConfig.components
|
|
191
|
+
|
|
192
|
+
const petBlocks: Config<PetPageComponents> = {
|
|
193
|
+
root: { fields: {} },
|
|
194
|
+
categories: {
|
|
195
|
+
pet: { title: 'This pet', components: ['PetGallery', 'PetSummary', 'PetHealth', 'PetPersonality', 'PetDescription', 'PetTimeline', 'MorePets'] },
|
|
196
|
+
sections: { title: 'Sections', components: ['TextSection', 'AdoptionSteps', 'Faq', 'CostTable', 'CallToAction'] },
|
|
197
|
+
helpers: { title: 'Layout helpers', components: ['Spacer', 'Divider'] },
|
|
198
|
+
},
|
|
199
|
+
components: {
|
|
200
|
+
PetGallery: {
|
|
201
|
+
label: 'Pet gallery',
|
|
202
|
+
fields: {
|
|
203
|
+
thumbnails: {
|
|
204
|
+
type: 'radio',
|
|
205
|
+
label: 'Thumbnails',
|
|
206
|
+
options: [
|
|
207
|
+
{ label: 'Below the photo', value: 'below' },
|
|
208
|
+
{ label: 'Above the photo', value: 'above' },
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
} as Fields<PetGalleryProps>,
|
|
212
|
+
defaultProps: { thumbnails: 'below' },
|
|
213
|
+
// A large photo plus thumbnails that swap it (a client component; blocks stay hook-free).
|
|
214
|
+
render: ({ thumbnails, puck }) => {
|
|
215
|
+
const pet = petOf(puck)
|
|
216
|
+
if (!pet) return puck.isEditing ? <NoPet what="The pet’s photos" /> : <></>
|
|
217
|
+
if (!pet.photos.length) return <></>
|
|
218
|
+
return (
|
|
219
|
+
<Section>
|
|
220
|
+
<PetGallery key={pet.id} photos={pet.photos} name={pet.name} thumbnails={thumbnails === 'above' ? 'above' : 'below'} />
|
|
221
|
+
</Section>
|
|
222
|
+
)
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
PetSummary: {
|
|
227
|
+
label: 'Pet summary',
|
|
228
|
+
fields: {
|
|
229
|
+
headingStyle: headingStyleField,
|
|
230
|
+
photo: {
|
|
231
|
+
type: 'radio',
|
|
232
|
+
label: 'Main photo',
|
|
233
|
+
options: [
|
|
234
|
+
{ label: 'Hidden', value: 'none' },
|
|
235
|
+
{ label: 'Left', value: 'left' },
|
|
236
|
+
{ label: 'Right', value: 'right' },
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
photoShape: {
|
|
240
|
+
type: 'radio',
|
|
241
|
+
label: 'Main photo shape',
|
|
242
|
+
options: [
|
|
243
|
+
{ label: 'Rounded', value: 'rounded' },
|
|
244
|
+
{ label: 'Sharp', value: 'sharp' },
|
|
245
|
+
{ label: 'Round', value: 'round' },
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
showStatus: toggle('Status badge'),
|
|
249
|
+
showFacts: toggle('Facts (species, breed, sex, age, size, colour, location)'),
|
|
250
|
+
} as Fields<PetSummaryProps>,
|
|
251
|
+
defaultProps: { headingStyle: 'normal', photo: 'none', photoShape: 'rounded', showStatus: true, showFacts: true },
|
|
252
|
+
render: ({ headingLevel, headingStyle, photo, photoShape, showStatus, showFacts, puck }) => {
|
|
253
|
+
const pet = petOf(puck)
|
|
254
|
+
if (!pet) return puck.isEditing ? <NoPet what="The pet’s name, status and facts" /> : <></>
|
|
255
|
+
// The pet's name is the page's heading: <h1> on the site (the first heading of the page).
|
|
256
|
+
const Name = headingLevel === 2 ? 'h2' : 'h1'
|
|
257
|
+
const rows = showFacts === false ? [] : facts(pet)
|
|
258
|
+
const main = photo === 'left' || photo === 'right' ? pet.photos[0] : undefined
|
|
259
|
+
const summary = (
|
|
260
|
+
<>
|
|
261
|
+
<div className="pet-title">
|
|
262
|
+
<Name className={headingClass(headingStyle, 'block-heading')}>{pet.name}</Name>
|
|
263
|
+
{showStatus !== false ? <span className={`badge badge-${classToken(pet.status)}`}>{pet.statusLabel}</span> : null}
|
|
264
|
+
</div>
|
|
265
|
+
{rows.length ? (
|
|
266
|
+
<dl className="facts">
|
|
267
|
+
{rows.map(([label, value]) => (
|
|
268
|
+
<div key={label}>
|
|
269
|
+
<dt>{label}</dt>
|
|
270
|
+
<dd>{value}</dd>
|
|
271
|
+
</div>
|
|
272
|
+
))}
|
|
273
|
+
</dl>
|
|
274
|
+
) : null}
|
|
275
|
+
</>
|
|
276
|
+
)
|
|
277
|
+
if (!main) return <Section>{summary}</Section>
|
|
278
|
+
// The photo comes first in the markup either way (it stacks on top on narrow screens);
|
|
279
|
+
// `data-photo="right"` only moves it visually.
|
|
280
|
+
return (
|
|
281
|
+
<Section>
|
|
282
|
+
<div className="pet-summary-media" data-photo={photo}>
|
|
283
|
+
<div className="pet-photo pet-summary-photo" data-shape={photoShape === 'sharp' || photoShape === 'round' ? photoShape : undefined}>
|
|
284
|
+
<Image src={main.url} alt={main.alt || pet.name} fill priority sizes="(max-width: 800px) 100vw, 45vw" />
|
|
285
|
+
</div>
|
|
286
|
+
<div className="pet-summary-text">{summary}</div>
|
|
287
|
+
</div>
|
|
288
|
+
</Section>
|
|
289
|
+
)
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
PetHealth: {
|
|
294
|
+
label: 'Pet health',
|
|
295
|
+
fields: {
|
|
296
|
+
heading: { type: 'text', label: 'Heading (optional)' },
|
|
297
|
+
showChecks: toggle('Medical history (vaccinated, microchipped, neutered…)'),
|
|
298
|
+
showNotes: toggle('Health notes'),
|
|
299
|
+
...listsLayoutFields,
|
|
300
|
+
} as Fields<PetHealthProps>,
|
|
301
|
+
defaultProps: { heading: 'Health', showChecks: true, showNotes: true, layout: 'columns', rowGap: 'default' },
|
|
302
|
+
// Hidden on the site when the pet has nothing to show here.
|
|
303
|
+
render: ({ headingLevel, heading, showChecks, showNotes, layout, rowGap, puck }) => {
|
|
304
|
+
const pet = petOf(puck)
|
|
305
|
+
if (!pet) return puck.isEditing ? <NoPet what="The pet’s medical history and health notes" /> : <></>
|
|
306
|
+
return (
|
|
307
|
+
<ListsBlock
|
|
308
|
+
heading={heading}
|
|
309
|
+
headingLevel={headingLevel}
|
|
310
|
+
layout={layout}
|
|
311
|
+
rowGap={rowGap}
|
|
312
|
+
isEditing={puck.isEditing}
|
|
313
|
+
empty={`Health details (${pet.name} has none yet)`}
|
|
314
|
+
sections={[
|
|
315
|
+
{ title: 'Medical history', items: showChecks === false ? [] : [...pet.healthChecks, ...(pet.neutered ? ['Neutered / spayed'] : [])] },
|
|
316
|
+
{ title: 'Health notes', notes: showNotes === false ? null : pet.healthNotes },
|
|
317
|
+
]}
|
|
318
|
+
/>
|
|
319
|
+
)
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
PetPersonality: {
|
|
324
|
+
label: 'Pet personality',
|
|
325
|
+
fields: {
|
|
326
|
+
heading: { type: 'text', label: 'Heading (optional)' },
|
|
327
|
+
showTemperament: toggle('Traits (playful, calm…)'),
|
|
328
|
+
showGoodWith: toggle('Good with'),
|
|
329
|
+
showNotes: toggle('Personality notes'),
|
|
330
|
+
...listsLayoutFields,
|
|
331
|
+
} as Fields<PetPersonalityProps>,
|
|
332
|
+
defaultProps: { heading: 'Personality', showTemperament: true, showGoodWith: true, showNotes: true, layout: 'columns', rowGap: 'default' },
|
|
333
|
+
render: ({ headingLevel, heading, showTemperament, showGoodWith, showNotes, layout, rowGap, puck }) => {
|
|
334
|
+
const pet = petOf(puck)
|
|
335
|
+
if (!pet) return puck.isEditing ? <NoPet what="The pet’s personality and who they are good with" /> : <></>
|
|
336
|
+
return (
|
|
337
|
+
<ListsBlock
|
|
338
|
+
heading={heading}
|
|
339
|
+
headingLevel={headingLevel}
|
|
340
|
+
layout={layout}
|
|
341
|
+
rowGap={rowGap}
|
|
342
|
+
isEditing={puck.isEditing}
|
|
343
|
+
empty={`Personality details (${pet.name} has none yet)`}
|
|
344
|
+
sections={[
|
|
345
|
+
{ title: 'Traits', items: showTemperament === false ? [] : pet.temperament },
|
|
346
|
+
{ title: 'Good with', items: showGoodWith === false ? [] : pet.goodWith },
|
|
347
|
+
{ title: 'Personality notes', notes: showNotes === false ? null : pet.personalityNotes },
|
|
348
|
+
]}
|
|
349
|
+
/>
|
|
350
|
+
)
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
|
|
354
|
+
PetDescription: {
|
|
355
|
+
label: 'Pet description',
|
|
356
|
+
fields: {
|
|
357
|
+
showButton: toggle('WhatsApp button (hidden for adopted pets)'),
|
|
358
|
+
buttonLabel: {
|
|
359
|
+
type: 'text',
|
|
360
|
+
label: 'Button text. Blank: “Ask about {pet} on WhatsApp”. Placeholders: {pet}, {species}, {breed}, {age}, {sex}, {location}',
|
|
361
|
+
},
|
|
362
|
+
} as Fields<PetDescriptionProps>,
|
|
363
|
+
defaultProps: { showButton: true, buttonLabel: '' },
|
|
364
|
+
render: ({ showButton, buttonLabel, puck }) => {
|
|
365
|
+
const pet = petOf(puck)
|
|
366
|
+
if (!pet) return puck.isEditing ? <NoPet what="The pet’s description and WhatsApp button" /> : <></>
|
|
367
|
+
const site = siteOf(puck)
|
|
368
|
+
const adopted = pet.status === 'adopted'
|
|
369
|
+
return (
|
|
370
|
+
<Section>
|
|
371
|
+
{/* A rich-text document drawn as React elements (never HTML), so it cannot inject markup. */}
|
|
372
|
+
{pet.description ? <RichText doc={pet.description} className="prose" /> : null}
|
|
373
|
+
{showButton !== false && !adopted ? (
|
|
374
|
+
<div className="pet-page-button">
|
|
375
|
+
<WhatsAppButton phone={site?.whatsappNumber} message={fillMessage(site?.whatsappMessage, pet.name)} label={fillPetPlaceholders(buttonLabel?.trim() || 'Ask about {pet} on WhatsApp', pet) || `Ask about ${pet.name} on WhatsApp`} />
|
|
376
|
+
</div>
|
|
377
|
+
) : null}
|
|
378
|
+
</Section>
|
|
379
|
+
)
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
|
|
383
|
+
PetTimeline: {
|
|
384
|
+
label: 'Pet timeline',
|
|
385
|
+
fields: {
|
|
386
|
+
heading: { type: 'text', label: 'Heading (optional)' },
|
|
387
|
+
align: {
|
|
388
|
+
type: 'radio',
|
|
389
|
+
label: 'Alignment',
|
|
390
|
+
options: [
|
|
391
|
+
{ label: 'Line on the left', value: 'left' },
|
|
392
|
+
{ label: 'Line on the right', value: 'right' },
|
|
393
|
+
{ label: 'Alternate (line in the centre)', value: 'alternate' },
|
|
394
|
+
],
|
|
395
|
+
},
|
|
396
|
+
order: {
|
|
397
|
+
type: 'radio',
|
|
398
|
+
label: 'Order',
|
|
399
|
+
options: [
|
|
400
|
+
{ label: 'Newest first', value: 'newest' },
|
|
401
|
+
{ label: 'Oldest first', value: 'oldest' },
|
|
402
|
+
],
|
|
403
|
+
},
|
|
404
|
+
limit: {
|
|
405
|
+
type: 'select',
|
|
406
|
+
label: 'How many to show (the rest behind “Show all updates”)',
|
|
407
|
+
options: [
|
|
408
|
+
{ label: '3', value: 3 },
|
|
409
|
+
{ label: '5', value: 5 },
|
|
410
|
+
{ label: '10', value: 10 },
|
|
411
|
+
{ label: 'All', value: 0 },
|
|
412
|
+
],
|
|
413
|
+
},
|
|
414
|
+
showPhotos: toggle('Photos'),
|
|
415
|
+
showTime: toggle('Time of day (when an update has one)'),
|
|
416
|
+
} as Fields<PetTimelineProps>,
|
|
417
|
+
defaultProps: { heading: 'Timeline', align: 'left', order: 'newest', limit: 5, showPhotos: true, showTime: true },
|
|
418
|
+
// Render-only: whether this pet has no updates, so the page's main heading is not given to a
|
|
419
|
+
// block that draws nothing (showsHeading in data.ts; never saved, see TRANSIENT_PROPS).
|
|
420
|
+
resolveData: async ({ props }, { metadata }) => ({
|
|
421
|
+
props: { ...props, empty: !(metadata as Partial<PuckSiteMetadata>).pet?.timeline?.length },
|
|
422
|
+
}),
|
|
423
|
+
// The pet's dated updates (posted on the pet's edit page). Left out on the site when there are none.
|
|
424
|
+
render: ({ headingLevel, heading, align, order, limit, showPhotos, showTime, puck }) => {
|
|
425
|
+
const pet = petOf(puck)
|
|
426
|
+
if (!pet) return puck.isEditing ? <NoPet what="The pet’s timeline of updates" /> : <></>
|
|
427
|
+
const entries: TimelineEntry[] = [...(pet.timeline ?? [])].sort(compareTimelineNewestFirst)
|
|
428
|
+
if (!entries.length) {
|
|
429
|
+
return puck.isEditing ? (
|
|
430
|
+
<Section>
|
|
431
|
+
<p className="muted">The pet’s timeline appears here. {pet.name} has no updates yet: add them on the pet’s page in the admin (Pets › {pet.name} › Timeline).</p>
|
|
432
|
+
</Section>
|
|
433
|
+
) : (
|
|
434
|
+
<></>
|
|
435
|
+
)
|
|
436
|
+
}
|
|
437
|
+
if (order === 'oldest') entries.reverse()
|
|
438
|
+
// Saved options are untrusted: only the offered values count, anything else is the default.
|
|
439
|
+
const alignment: TimelineAlignment = (TIMELINE_ALIGNMENTS as readonly unknown[]).includes(align) ? (align as TimelineAlignment) : 'left'
|
|
440
|
+
const count = limit === 3 || limit === 5 || limit === 10 || limit === 0 ? limit : 5
|
|
441
|
+
const title = heading?.trim()
|
|
442
|
+
const Title = headingLevel === 1 ? 'h1' : 'h2'
|
|
443
|
+
return (
|
|
444
|
+
<Section>
|
|
445
|
+
{title ? <Title className="block-heading">{title}</Title> : null}
|
|
446
|
+
<PetTimeline
|
|
447
|
+
entries={entries}
|
|
448
|
+
align={alignment}
|
|
449
|
+
limit={count}
|
|
450
|
+
showPhotos={showPhotos !== false}
|
|
451
|
+
showTime={showTime !== false}
|
|
452
|
+
itemTag={title ? (headingLevel === 1 ? 'h2' : 'h3') : 'h2'}
|
|
453
|
+
/>
|
|
454
|
+
</Section>
|
|
455
|
+
)
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
|
|
459
|
+
MorePets: {
|
|
460
|
+
label: 'More pets like this',
|
|
461
|
+
fields: {
|
|
462
|
+
heading: { type: 'text', label: 'Heading' },
|
|
463
|
+
count: {
|
|
464
|
+
type: 'radio',
|
|
465
|
+
label: 'How many',
|
|
466
|
+
options: [
|
|
467
|
+
{ label: '3', value: 3 },
|
|
468
|
+
{ label: '4', value: 4 },
|
|
469
|
+
{ label: '6', value: 6 },
|
|
470
|
+
],
|
|
471
|
+
},
|
|
472
|
+
} as Fields<MorePetsProps>,
|
|
473
|
+
defaultProps: { heading: 'More pets like this', count: 3 },
|
|
474
|
+
// Available, listed pets: the same species first, then the same state (rankSimilarPets).
|
|
475
|
+
resolveData: async ({ props }, { metadata }) => {
|
|
476
|
+
const meta = metadata as Partial<PuckSiteMetadata>
|
|
477
|
+
if (!meta.pet || !meta.fetchSimilarPets) return { props: { ...props, similar: [] } }
|
|
478
|
+
const similar = await meta.fetchSimilarPets({ id: meta.pet.id, species: meta.pet.species, state: meta.pet.state }, props.count ?? 3)
|
|
479
|
+
return { props: { ...props, similar } }
|
|
480
|
+
},
|
|
481
|
+
render: ({ headingLevel, heading, similar, puck }) => {
|
|
482
|
+
if (!similar?.length) return puck.isEditing ? <NoPet what="Other available pets like this one" /> : <></>
|
|
483
|
+
const Title = headingLevel === 1 ? 'h1' : 'h2'
|
|
484
|
+
return (
|
|
485
|
+
<Section>
|
|
486
|
+
{heading ? <Title className="block-heading">{heading}</Title> : null}
|
|
487
|
+
<div className="pet-grid">
|
|
488
|
+
{similar.map((pet) => (
|
|
489
|
+
<PetCard key={pet.id} pet={pet} headingLevel={headingLevel === 1 ? 'h2' : 'h3'} />
|
|
490
|
+
))}
|
|
491
|
+
</div>
|
|
492
|
+
</Section>
|
|
493
|
+
)
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
|
|
497
|
+
TextSection: shared.TextSection,
|
|
498
|
+
AdoptionSteps: shared.AdoptionSteps,
|
|
499
|
+
Faq: shared.Faq,
|
|
500
|
+
CostTable: shared.CostTable,
|
|
501
|
+
CallToAction: shared.CallToAction,
|
|
502
|
+
Divider: shared.Divider,
|
|
503
|
+
Spacer: shared.Spacer,
|
|
504
|
+
},
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* The pet blocks get the Padding option too (the shared ones already have it), and so do the plugin
|
|
509
|
+
* blocks offered here: only those that set `petPage` (the Form block), under "Plugins".
|
|
510
|
+
*/
|
|
511
|
+
export const petPageConfig: Config<PetPageComponents> = withPadding(withPluginBlocks(petBlocks, pluginBlocks.filter((block) => block.petPage === true)))
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { FieldLabel } from '@puckeditor/core'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import useSWR from 'swr'
|
|
6
|
+
|
|
7
|
+
import { unwrapResult } from '@/lib/admin/unwrap-client'
|
|
8
|
+
|
|
9
|
+
import { listPetChoicesAction } from './actions'
|
|
10
|
+
|
|
11
|
+
// The Pet spotlight's "Pet" field: a plain <select> of the owner's pets (the editor has no Tailwind,
|
|
12
|
+
// so a native control keeps it simple and accessible). Stores the pet's id, or null.
|
|
13
|
+
export function PetPicker({ id, value, onChange, readOnly = false }: { id?: string; value: number | null; onChange: (value: number | null) => void; readOnly?: boolean }) {
|
|
14
|
+
const { data, error } = useSWR('puck-pet-choices', async () => unwrapResult(await listPetChoicesAction()))
|
|
15
|
+
// A saved pet that is not in the list (deleted, or older than the newest 500) keeps its own
|
|
16
|
+
// option, so the block does not look unset.
|
|
17
|
+
const missing = value != null && data !== undefined && !data.some((pet) => pet.id === value)
|
|
18
|
+
return (
|
|
19
|
+
// Puck draws no label for a custom field: FieldLabel adds a real <label> around the select.
|
|
20
|
+
<FieldLabel label="Pet" el="label" className="pet-picker">
|
|
21
|
+
<select
|
|
22
|
+
id={id}
|
|
23
|
+
value={value ?? ''}
|
|
24
|
+
// Puck passes readOnly to custom fields when editing is off (view-only roles).
|
|
25
|
+
disabled={readOnly}
|
|
26
|
+
onChange={(event) => onChange(event.target.value ? Number(event.target.value) : null)}
|
|
27
|
+
aria-busy={!data && !error}
|
|
28
|
+
>
|
|
29
|
+
<option value="">{data ? 'Choose a pet' : error ? 'Could not load the pets' : 'Loading pets…'}</option>
|
|
30
|
+
{missing ? <option value={value}>Not found (deleted?)</option> : null}
|
|
31
|
+
{data?.map((pet) => (
|
|
32
|
+
<option key={pet.id} value={pet.id}>
|
|
33
|
+
{pet.name}
|
|
34
|
+
{pet.note ? ` (${pet.note})` : ''}
|
|
35
|
+
</option>
|
|
36
|
+
))}
|
|
37
|
+
</select>
|
|
38
|
+
</FieldLabel>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// What a plugin's page builder block shows: its loader (`Plugin.blockLoaders[name]`), run for the
|
|
2
|
+
// public site and for the editor's preview. Server-only. A plugin block never breaks a page: an
|
|
3
|
+
// unknown block, a block with no loader, a plugin whose tables are not set up yet, a loader that
|
|
4
|
+
// throws and a result that is not plain JSON all give null, and the block then decides what to show.
|
|
5
|
+
//
|
|
6
|
+
// Cached (Cache Components): the pet and page routes may read nothing uncached, and a plugin cannot be
|
|
7
|
+
// relied on to cache itself, so the call into the loader is the cached function. Tag `plugin-blocks`,
|
|
8
|
+
// expired by `host().revalidateSite()`; a minute's lifetime as every public read. A null (a failure,
|
|
9
|
+
// tables not set up yet) is kept for that minute too, as the old 60 s page refresh kept it.
|
|
10
|
+
import type { PluginBlockLoader } from '@pet-adopt/plugin-sdk'
|
|
11
|
+
|
|
12
|
+
import { fallbackLife, publicLife, tag, TAGS } from '@/lib/cache'
|
|
13
|
+
import { logError } from '@/server/result'
|
|
14
|
+
// Register what plugins reach through the SDK (a no-op if the server start already did).
|
|
15
|
+
import '@/plugins/host'
|
|
16
|
+
import '@/plugins/storage'
|
|
17
|
+
import { getPluginBlock } from '@/plugins/registry'
|
|
18
|
+
import { pluginBlockOptions } from '@/puck/plugin-blocks'
|
|
19
|
+
import { isPluginNotReadyError } from '@/plugins/storage'
|
|
20
|
+
|
|
21
|
+
/** A block's result is a feed or a short list. Anything near this size is a mistake. */
|
|
22
|
+
const MAX_RESULT_BYTES = 1_000_000
|
|
23
|
+
/** The options of one block, as the editor sends them: a handful of short values. */
|
|
24
|
+
const MAX_PROPS_BYTES = 20_000
|
|
25
|
+
|
|
26
|
+
const quiet = () => process.env.NEXT_PHASE === 'phase-production-build'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A block's options as they may be handed to a loader: one flat object of plain values (text,
|
|
30
|
+
* numbers, true, false, null), or null when `props` is anything else or too large. The loader still
|
|
31
|
+
* treats them as untrusted: this only bounds what it can be sent.
|
|
32
|
+
*/
|
|
33
|
+
export function plainBlockProps(props: unknown): Record<string, unknown> | null {
|
|
34
|
+
if (typeof props !== 'object' || props === null || Array.isArray(props)) return null
|
|
35
|
+
const out: Record<string, unknown> = {}
|
|
36
|
+
for (const [key, value] of Object.entries(props)) {
|
|
37
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value))) out[key] = value
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return JSON.stringify(out).length <= MAX_PROPS_BYTES ? out : null
|
|
41
|
+
} catch {
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Runs one loader. Never throws: a failure is logged (without the error object) and gives null. */
|
|
47
|
+
export async function runPluginBlockLoader(name: string, load: PluginBlockLoader, options: Record<string, unknown>): Promise<unknown> {
|
|
48
|
+
try {
|
|
49
|
+
const result = await load(options)
|
|
50
|
+
if (result === undefined || result === null) return null
|
|
51
|
+
// Plain JSON only: it crosses to the browser in the editor, and the site should draw the same.
|
|
52
|
+
const json = JSON.stringify(result)
|
|
53
|
+
if (json === undefined) return null
|
|
54
|
+
if (json.length > MAX_RESULT_BYTES) {
|
|
55
|
+
if (!quiet()) logError(new Error(`the result is too large (${json.length} bytes)`), `Plugin block "${name}"`)
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
return JSON.parse(json) as unknown
|
|
59
|
+
} catch (error) {
|
|
60
|
+
// A plugin whose tables are not migrated yet is reported at server start and on its screens.
|
|
61
|
+
if (!isPluginNotReadyError(error) && !quiet()) logError(error, `Plugin block "${name}"`)
|
|
62
|
+
return null
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The options as one cache argument: keys sorted, so the same options are always the same entry. */
|
|
67
|
+
function stableJson(options: Record<string, unknown>): string {
|
|
68
|
+
return JSON.stringify(Object.fromEntries(Object.entries(options).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function fetchPluginBlockData(name: unknown, props: unknown): Promise<unknown> {
|
|
72
|
+
if (typeof name !== 'string') return null
|
|
73
|
+
const options = plainBlockProps(props)
|
|
74
|
+
if (!options) return null
|
|
75
|
+
// Looked up before the cache, so a name with no loader never makes an entry.
|
|
76
|
+
const found = getPluginBlock(name)
|
|
77
|
+
if (!found?.load) return null
|
|
78
|
+
// The loader gets the block's own options, checked as the block's drawing gets them.
|
|
79
|
+
return loadPluginBlock(name, stableJson(pluginBlockOptions(found.block, options)))
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function loadPluginBlock(name: string, optionsJson: string): Promise<unknown> {
|
|
83
|
+
'use cache'
|
|
84
|
+
tag(TAGS.pluginBlocks)
|
|
85
|
+
const found = getPluginBlock(name)
|
|
86
|
+
const result = found?.load ? await runPluginBlockLoader(name, found.load, JSON.parse(optionsJson) as Record<string, unknown>) : null
|
|
87
|
+
// During the build a null is most likely "no database yet": rebuild on the first request instead.
|
|
88
|
+
if (result === null && quiet()) fallbackLife()
|
|
89
|
+
else publicLife()
|
|
90
|
+
return result
|
|
91
|
+
}
|