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,40 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
4
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
5
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
6
|
+
import { getSettingsAction } from '@/server/actions/settings'
|
|
7
|
+
import { listPages } from '@/server/pages'
|
|
8
|
+
import { isSystemPageSlug } from '@/puck/data'
|
|
9
|
+
import type { SettingsTab } from '@/lib/zod-schema/settings'
|
|
10
|
+
|
|
11
|
+
import { SettingsForm } from './SettingsForm'
|
|
12
|
+
|
|
13
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
14
|
+
export const instant = false
|
|
15
|
+
|
|
16
|
+
export const metadata = { title: 'Site settings' }
|
|
17
|
+
|
|
18
|
+
const TABS: SettingsTab[] = ['brand', 'contact', 'region', 'navigation']
|
|
19
|
+
|
|
20
|
+
export default async function SettingsPage({ searchParams }: { searchParams: Promise<{ tab?: string | string[] }> }) {
|
|
21
|
+
const user = await requirePermissionPage('settings:view')
|
|
22
|
+
const settings = unwrap(await getSettingsAction())
|
|
23
|
+
const { tab } = await searchParams
|
|
24
|
+
const initialTab = TABS.find((name) => name === tab) ?? 'brand'
|
|
25
|
+
// Pages that can hold the privacy policy: the owners' own, not archived (the server checks too).
|
|
26
|
+
const privacyPages = (await listPages())
|
|
27
|
+
.filter((page) => !isSystemPageSlug(page.slug) && page.state !== 'archived')
|
|
28
|
+
.map((page) => ({ id: page.id, title: page.title, live: page.state === 'published' }))
|
|
29
|
+
.sort((a, b) => a.title.localeCompare(b.title))
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<PageHeader title="Site settings" />
|
|
34
|
+
<ViewOnly value={!can(user.role, 'settings:edit')}>
|
|
35
|
+
<ViewOnlyNotice role={user.role} what="the settings" />
|
|
36
|
+
<SettingsForm settings={settings} privacyPages={privacyPages} initialTab={initialTab} />
|
|
37
|
+
</ViewOnly>
|
|
38
|
+
</>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { redirect } from 'next/navigation'
|
|
2
|
+
|
|
3
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
4
|
+
export const instant = false
|
|
5
|
+
|
|
6
|
+
// Email templates moved to the Email page; old links still work.
|
|
7
|
+
export default function OldEmailTemplatesPage() {
|
|
8
|
+
redirect('/admin/email/templates')
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
4
|
+
import { ThemeEditor } from '@/components/admin/theme/ThemeEditor'
|
|
5
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
6
|
+
import { parseId, requirePermissionPage, unwrap, unwrapOrNotFound } from '@/lib/admin/unwrap'
|
|
7
|
+
import { getThemeAction, listThemesAction } from '@/server/actions/themes'
|
|
8
|
+
|
|
9
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
10
|
+
export const instant = false
|
|
11
|
+
|
|
12
|
+
export const metadata = { title: 'Edit theme' }
|
|
13
|
+
|
|
14
|
+
export default async function EditThemePage({ params }: { params: Promise<{ id: string }> }) {
|
|
15
|
+
const user = await requirePermissionPage('theme:view')
|
|
16
|
+
const { id } = await params
|
|
17
|
+
const theme = unwrapOrNotFound(await getThemeAction(parseId(id)))
|
|
18
|
+
const { activeThemeId } = unwrap(await listThemesAction())
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<PageHeader title={theme.name} description="Change anything, and see it in the preview as you go. Nothing changes on the site until you save." />
|
|
22
|
+
<ViewOnly value={!can(user.role, 'theme:edit')}>
|
|
23
|
+
<ViewOnlyNotice role={user.role} what="this theme" />
|
|
24
|
+
<ThemeEditor theme={theme} isActive={activeThemeId === theme.id} />
|
|
25
|
+
</ViewOnly>
|
|
26
|
+
</>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
4
|
+
import { ThemeLibrary } from '@/components/admin/theme/ThemeLibrary'
|
|
5
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
6
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
7
|
+
import { listThemesAction } from '@/server/actions/themes'
|
|
8
|
+
|
|
9
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
10
|
+
export const instant = false
|
|
11
|
+
|
|
12
|
+
export const metadata = { title: 'Theme' }
|
|
13
|
+
|
|
14
|
+
// The look of the whole site: built-in presets and the owner's own themes (admin only).
|
|
15
|
+
export default async function ThemePage() {
|
|
16
|
+
const user = await requirePermissionPage('theme:view')
|
|
17
|
+
const { themes, activeThemeId, preset } = unwrap(await listThemesAction())
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<PageHeader
|
|
21
|
+
title="Theme"
|
|
22
|
+
description="Choose how the whole site looks. Use a built-in preset as it is, or make your own theme from one and change its colours, fonts and shapes."
|
|
23
|
+
/>
|
|
24
|
+
<ViewOnly value={!can(user.role, 'theme:edit')}>
|
|
25
|
+
<ViewOnlyNotice role={user.role} what="the themes" />
|
|
26
|
+
<ThemeLibrary themes={themes} activeThemeId={activeThemeId} preset={preset} />
|
|
27
|
+
</ViewOnly>
|
|
28
|
+
</>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
4
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
5
|
+
import { UsersTable } from '@/components/admin/users/UsersTable'
|
|
6
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
7
|
+
import { DEMO_ACCOUNT, isDemo } from '@/lib/demo'
|
|
8
|
+
import { listUsersAction } from '@/server/actions/users'
|
|
9
|
+
import { MIN_PASSWORD_LENGTH } from '@/server/auth'
|
|
10
|
+
|
|
11
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
12
|
+
export const instant = false
|
|
13
|
+
|
|
14
|
+
export const metadata = { title: 'Users' }
|
|
15
|
+
|
|
16
|
+
// Accounts that can sign in to the admin (admins only). The table and its dialogs are client
|
|
17
|
+
// components; every rule is enforced by the actions in src/server/actions/users.ts. In the demo, the
|
|
18
|
+
// shared demo account (everyone's own) keeps only Edit, for its name; the actions refuse the rest.
|
|
19
|
+
export default async function UsersPage() {
|
|
20
|
+
const me = await requirePermissionPage('users:view')
|
|
21
|
+
const users = unwrap(await listUsersAction())
|
|
22
|
+
const demoAccountId = isDemo() ? (users.find((user) => user.email.toLowerCase() === DEMO_ACCOUNT.email)?.id ?? null) : null
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<PageHeader title="Users" />
|
|
27
|
+
<ViewOnly value={!can(me.role, 'users:edit')}>
|
|
28
|
+
<ViewOnlyNotice role={me.role} what="the users" />
|
|
29
|
+
<UsersTable users={users} meId={me.id} minPasswordLength={MIN_PASSWORD_LENGTH} demoAccountId={demoAccountId} />
|
|
30
|
+
</ViewOnly>
|
|
31
|
+
</>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { redirect } from "next/navigation";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
import { DemoBanner } from "@/components/demo/DemoBanner";
|
|
6
|
+
import { ThemeStyle } from "@/components/site/ThemeStyle";
|
|
7
|
+
import { demoResetMinutes, isDemo } from "@/lib/demo";
|
|
8
|
+
import { getSettings, siteIcons } from "@/lib/queries";
|
|
9
|
+
import { getSessionUser } from "@/server/session";
|
|
10
|
+
import { needsTwoFactorSetup } from "@/server/two-factor";
|
|
11
|
+
import { TwoFactorRequired } from "@/components/admin/two-factor/TwoFactorRequired";
|
|
12
|
+
|
|
13
|
+
// Tailwind and the shadcn tokens, bridged to the site theme (see the notes in globals.css).
|
|
14
|
+
import "@pet-adopt/ui/globals.css";
|
|
15
|
+
// Self-hosted fonts. The theme decides which one is used.
|
|
16
|
+
import "../(frontend)/fonts";
|
|
17
|
+
import Providers from "./providers";
|
|
18
|
+
// Do NOT import ../(frontend)/styles.css here: it is unlayered plain CSS, so it would beat
|
|
19
|
+
// Tailwind's utilities (for example the link colour) and fight with the shadcn components.
|
|
20
|
+
|
|
21
|
+
// Cache Components: every admin screen is drawn per request for the signed-in person and may wait
|
|
22
|
+
// for its data (no static shell, no loading skeleton). Without this the build refuses the routes,
|
|
23
|
+
// because this layout reads the session before anything else. It covers every page below; the
|
|
24
|
+
// pages repeat it only to keep `next dev`'s per-page check quiet.
|
|
25
|
+
export const instant = false;
|
|
26
|
+
|
|
27
|
+
// Tabs read "Pets | <site name> admin", so owners with several sites can tell them apart.
|
|
28
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
29
|
+
const settings = await getSettings();
|
|
30
|
+
const { siteName } = settings;
|
|
31
|
+
return {
|
|
32
|
+
title: { default: `${siteName} admin`, template: `%s | ${siteName} admin` },
|
|
33
|
+
// The admin is for the owners only.
|
|
34
|
+
robots: { index: false, follow: false },
|
|
35
|
+
icons: siteIcons(settings),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default async function AdminRootLayout({
|
|
40
|
+
children,
|
|
41
|
+
}: {
|
|
42
|
+
children: React.ReactNode;
|
|
43
|
+
}) {
|
|
44
|
+
// Everything under (admin) is for signed-in owners. The sign-in page lives in the separate (auth)
|
|
45
|
+
// group, so this cannot loop. Each action still checks the session itself: this guard only
|
|
46
|
+
// keeps signed-out visitors from seeing the screens. (A layout cannot read the current path, so
|
|
47
|
+
// the sign-in form cannot know where the person was headed; it goes to /admin afterwards.)
|
|
48
|
+
const user = await getSessionUser();
|
|
49
|
+
if (!user) redirect("/admin/login");
|
|
50
|
+
|
|
51
|
+
const settings = await getSettings();
|
|
52
|
+
// Their role must use two-factor sign-in and they have not set it up: that setup, and nothing
|
|
53
|
+
// else, on every admin address (a layout cannot read the path, so no redirect loop to avoid).
|
|
54
|
+
// The actions refuse too (requirePermission).
|
|
55
|
+
const setupFirst = await needsTwoFactorSetup(user);
|
|
56
|
+
return (
|
|
57
|
+
// suppressHydrationWarning: a small script may set data-mode on <html> (the owner's saved
|
|
58
|
+
// light/dark choice) before React hydrates, exactly like the public layout.
|
|
59
|
+
<html lang="en" suppressHydrationWarning>
|
|
60
|
+
<head>
|
|
61
|
+
{/* Writes the theme's CSS variables (--bg, --ink, --primary ...) that globals.css maps
|
|
62
|
+
shadcn's colours onto, plus the light/dark pre-paint script. */}
|
|
63
|
+
<ThemeStyle settings={settings} />
|
|
64
|
+
</head>
|
|
65
|
+
{/* The page background, text colour and font come from the shadcn tokens, which follow the theme. */}
|
|
66
|
+
<body className="min-h-screen bg-background font-sans text-foreground antialiased">
|
|
67
|
+
{/* The public demo (PET_ADOPT_DEMO=1) says so at the top of every admin screen. */}
|
|
68
|
+
{isDemo() ? <DemoBanner resetMinutes={demoResetMinutes()} besideSidebar /> : null}
|
|
69
|
+
<Providers userId={user.id} timeZone={settings.timeZone}>
|
|
70
|
+
{setupFirst ? <TwoFactorRequired user={user} siteName={settings.siteName} /> : children}
|
|
71
|
+
</Providers>
|
|
72
|
+
</body>
|
|
73
|
+
</html>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { NuqsAdapter } from "nuqs/adapters/next/app";
|
|
5
|
+
import { SWRConfig } from "swr";
|
|
6
|
+
import { SiteTimeProvider } from "@/components/admin/site-time";
|
|
7
|
+
import { TooltipProvider } from "@pet-adopt/ui/components/tooltip";
|
|
8
|
+
|
|
9
|
+
export default function Providers({
|
|
10
|
+
children,
|
|
11
|
+
userId,
|
|
12
|
+
timeZone,
|
|
13
|
+
}: {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
userId: string;
|
|
16
|
+
/** The site's time zone (Site settings > Region), or null. */
|
|
17
|
+
timeZone: string | null;
|
|
18
|
+
}) {
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<NuqsAdapter>
|
|
22
|
+
{/* key: a different signed-in person gets a fresh, empty cache. The cache is a plain
|
|
23
|
+
in-memory Map (never localStorage): the lists include unlisted pets and, later, users,
|
|
24
|
+
and must not outlive the session. */}
|
|
25
|
+
<SWRConfig
|
|
26
|
+
key={userId}
|
|
27
|
+
value={{
|
|
28
|
+
provider: () => new Map(),
|
|
29
|
+
// Data only changes when an owner changes it here, so skip refetching on every tab focus.
|
|
30
|
+
revalidateOnFocus: false,
|
|
31
|
+
// A failed action (signed out, validation) will not fix itself by retrying.
|
|
32
|
+
shouldRetryOnError: false,
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<SiteTimeProvider timeZone={timeZone}>
|
|
36
|
+
<TooltipProvider>{children}</TooltipProvider>
|
|
37
|
+
</SiteTimeProvider>
|
|
38
|
+
</SWRConfig>
|
|
39
|
+
</NuqsAdapter>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { connection } from "next/server";
|
|
3
|
+
|
|
4
|
+
import { ConfirmEmailForm } from "@/components/auth/ConfirmEmailForm";
|
|
5
|
+
import { ResetUnavailable } from "@/components/auth/ResetPasswordForm";
|
|
6
|
+
import { emailChangeFor } from "@/server/email-change";
|
|
7
|
+
|
|
8
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
9
|
+
export const instant = false;
|
|
10
|
+
|
|
11
|
+
export const metadata: Metadata = {
|
|
12
|
+
// The same page confirms a first address and a change of address: the heading says which.
|
|
13
|
+
title: "Confirm your email",
|
|
14
|
+
// The token is in the address: never send it to another site in a Referer header.
|
|
15
|
+
referrer: "no-referrer",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Opened from the "Confirm your email" and "Confirm new email" messages (src/server/email-change.ts).
|
|
19
|
+
// Signed in or not: the link itself proves the person reads that address. Opening it changes nothing
|
|
20
|
+
// until Confirm.
|
|
21
|
+
export default async function ConfirmEmailPage({ searchParams }: { searchParams: Promise<{ token?: string | string[] }> }) {
|
|
22
|
+
// Wait for a real request before the database and the clock (the token check compares its expiry
|
|
23
|
+
// with now). searchParams alone does not count as one under Cache Components.
|
|
24
|
+
await connection();
|
|
25
|
+
const { token } = await searchParams;
|
|
26
|
+
const change = typeof token === "string" ? await emailChangeFor(token) : null;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="w-full h-full flex flex-col items-center justify-center gap-6 p-4">
|
|
30
|
+
{change && typeof token === "string" ? (
|
|
31
|
+
<ConfirmEmailForm token={token} name={change.name} email={change.email} isChange={change.isChange} />
|
|
32
|
+
) : (
|
|
33
|
+
<ResetUnavailable title="This link no longer works">
|
|
34
|
+
Confirmation links work once, for 24 hours. For a new one, use Send confirmation link at the top of the admin, or,
|
|
35
|
+
for a change of address, ask for the change again on your Account page.
|
|
36
|
+
</ResetUnavailable>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { connection } from "next/server";
|
|
3
|
+
|
|
4
|
+
import { AcceptInviteForm } from "@/components/auth/AcceptInviteForm";
|
|
5
|
+
import { ResetUnavailable } from "@/components/auth/ResetPasswordForm";
|
|
6
|
+
import { getSettings } from "@/lib/queries";
|
|
7
|
+
import { MIN_PASSWORD_LENGTH } from "@/server/auth";
|
|
8
|
+
import { isInviteTokenValid } from "@/server/invites";
|
|
9
|
+
|
|
10
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
11
|
+
export const instant = false;
|
|
12
|
+
|
|
13
|
+
export const metadata: Metadata = {
|
|
14
|
+
title: "Accept invite",
|
|
15
|
+
// The token is in the address: never send it to another site in a Referer header.
|
|
16
|
+
referrer: "no-referrer",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// An admin invited this person (src/server/invites.ts): they choose their first password here.
|
|
20
|
+
export default async function AcceptInvitePage({ searchParams }: { searchParams: Promise<{ token?: string | string[] }> }) {
|
|
21
|
+
// Wait for a real request before the database and the clock (the token check reads both): `next
|
|
22
|
+
// build` stops here, so a build with no database never reaches them.
|
|
23
|
+
await connection();
|
|
24
|
+
const [settings, { token }] = await Promise.all([getSettings(), searchParams]);
|
|
25
|
+
const invite = typeof token === "string" ? await isInviteTokenValid(token) : null;
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="w-full h-full flex flex-col items-center justify-center gap-6 p-4">
|
|
29
|
+
{invite && typeof token === "string" ? (
|
|
30
|
+
<AcceptInviteForm token={token} name={invite.name} siteName={settings.siteName} minLength={MIN_PASSWORD_LENGTH} />
|
|
31
|
+
) : (
|
|
32
|
+
<ResetUnavailable title="This invite no longer works">
|
|
33
|
+
Invite links work once, for 7 days. Ask the admin who invited you to send a new one.
|
|
34
|
+
</ResetUnavailable>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
|
|
6
|
+
import { Button } from "@pet-adopt/ui/components/button";
|
|
7
|
+
import { Card, CardContent, CardFooter, CardHeader } from "@pet-adopt/ui/components/card";
|
|
8
|
+
import { callAction } from "@/lib/admin/call-action";
|
|
9
|
+
import { enterDemoAction } from "@/server/actions/demo";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The sign-in screen of the public demo (src/lib/demo.ts): one button instead of the password form
|
|
13
|
+
* and providers. The page decides it is the demo and passes the wording in; this file never reads
|
|
14
|
+
* the environment.
|
|
15
|
+
*/
|
|
16
|
+
export function DemoSignIn({
|
|
17
|
+
redirectTo,
|
|
18
|
+
resetEvery,
|
|
19
|
+
}: {
|
|
20
|
+
/** Already checked on the server (`safeRedirectPath`): a path on this site. */
|
|
21
|
+
redirectTo: string;
|
|
22
|
+
/** How often the demo starts again, as words: "every hour". */
|
|
23
|
+
resetEvery: string;
|
|
24
|
+
}) {
|
|
25
|
+
const router = useRouter();
|
|
26
|
+
const [pending, startTransition] = React.useTransition();
|
|
27
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
28
|
+
|
|
29
|
+
function open() {
|
|
30
|
+
if (pending) return;
|
|
31
|
+
setError(null);
|
|
32
|
+
startTransition(async () => {
|
|
33
|
+
// callAction: a call that never arrives (network, redeploy) becomes a message, not a stuck button.
|
|
34
|
+
const result = await callAction(enterDemoAction());
|
|
35
|
+
// The action sets the demo cookie. /admin is another root layout, so this is a full page load
|
|
36
|
+
// that sends it (the same reason the password form navigates itself).
|
|
37
|
+
if (result.ok) {
|
|
38
|
+
router.replace(redirectTo);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
setError(result.error);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Card className="w-full max-w-lg">
|
|
47
|
+
<CardHeader>
|
|
48
|
+
<h1 className="text-lg font-semibold">Try the admin</h1>
|
|
49
|
+
<p>This is the Pet Adopt demo. Open the admin to add pets, build pages and change the theme. No account needed.</p>
|
|
50
|
+
</CardHeader>
|
|
51
|
+
<CardContent className="flex flex-col gap-3">
|
|
52
|
+
<p className="text-sm text-muted-foreground">Changes are shared with other visitors and reset {resetEvery}.</p>
|
|
53
|
+
{error ? (
|
|
54
|
+
<p role="alert" className="text-sm text-destructive">
|
|
55
|
+
{error}
|
|
56
|
+
</p>
|
|
57
|
+
) : null}
|
|
58
|
+
</CardContent>
|
|
59
|
+
<CardFooter>
|
|
60
|
+
<div className="flex w-full justify-end">
|
|
61
|
+
{/* aria-disabled, not disabled: focus stays on the button while it works. */}
|
|
62
|
+
<Button type="button" onClick={open} aria-disabled={pending || undefined}>
|
|
63
|
+
{pending ? "Opening…" : "Open the admin"}
|
|
64
|
+
</Button>
|
|
65
|
+
</div>
|
|
66
|
+
</CardFooter>
|
|
67
|
+
</Card>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { LoginForm } from "@/components/auth/LoginForm";
|
|
2
|
+
import { ProviderSignIn } from "@/components/auth/ProviderSignIn";
|
|
3
|
+
import { errorCode, providerSignInError } from "@/lib/auth-provider-errors";
|
|
4
|
+
import { demoResetEvery, isDemo } from "@/lib/demo";
|
|
5
|
+
import { listEnabledProviders } from "@/server/auth-providers";
|
|
6
|
+
import { safeRedirectPath } from "@/lib/links";
|
|
7
|
+
import { getSettings } from "@/lib/queries";
|
|
8
|
+
import { redirect as goTo } from "next/navigation";
|
|
9
|
+
import { connection } from "next/server";
|
|
10
|
+
|
|
11
|
+
import { getSessionUser } from "@/server/session";
|
|
12
|
+
import { DELETION_GRACE_DAYS } from "@/server/users";
|
|
13
|
+
import { hasAccounts } from "@/server/setup";
|
|
14
|
+
import { logError } from "@/server/result";
|
|
15
|
+
|
|
16
|
+
import { DemoSignIn } from "./DemoSignIn";
|
|
17
|
+
|
|
18
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
19
|
+
export const instant = false;
|
|
20
|
+
|
|
21
|
+
export default async function AdminLoginPage({
|
|
22
|
+
searchParams,
|
|
23
|
+
}: {
|
|
24
|
+
searchParams: Promise<{ redirect?: string | string[]; error?: string | string[]; closed?: string | string[] }>;
|
|
25
|
+
}) {
|
|
26
|
+
// Wait for a real request before the database (the session lookup does too; this keeps the page
|
|
27
|
+
// safe if that order ever changes).
|
|
28
|
+
await connection();
|
|
29
|
+
// Someone who is already signed in has nothing to do here.
|
|
30
|
+
if (await getSessionUser()) goTo(safeRedirectPath((await searchParams).redirect));
|
|
31
|
+
// The public demo (src/lib/demo.ts): one button that opens the admin as the shared demo account,
|
|
32
|
+
// instead of the password form and the providers (both are refused there).
|
|
33
|
+
if (isDemo()) {
|
|
34
|
+
const { redirect } = await searchParams;
|
|
35
|
+
return (
|
|
36
|
+
<div className="w-full h-full flex flex-col items-center justify-center gap-4 p-4">
|
|
37
|
+
<DemoSignIn redirectTo={safeRedirectPath(redirect)} resetEvery={demoResetEvery()} />
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
// A new site has no accounts: the first one is made with the setup link (src/server/setup.ts).
|
|
42
|
+
// If that cannot be read, show the form: signing in then reports the problem.
|
|
43
|
+
const accounts = await hasAccounts().catch((failure: unknown) => {
|
|
44
|
+
logError(failure, "sign-in page: could not count accounts");
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
47
|
+
if (!accounts) {
|
|
48
|
+
return (
|
|
49
|
+
<div className="w-full h-full flex flex-col items-center justify-center gap-4 p-4">
|
|
50
|
+
<section className="w-full max-w-lg rounded-lg border p-6">
|
|
51
|
+
<h1 className="text-lg font-semibold">This site is not set up yet</h1>
|
|
52
|
+
<p className="mt-2 text-sm">
|
|
53
|
+
There are no accounts yet. Whoever deployed it creates the first one with the setup link printed in the server’s log (it starts with{" "}
|
|
54
|
+
<code className="break-all">/setup?key=</code>).
|
|
55
|
+
</p>
|
|
56
|
+
</section>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
// Providers are extra: if they cannot be read, the password form still works.
|
|
61
|
+
const [settings, { redirect, error, closed }, providers] = await Promise.all([
|
|
62
|
+
getSettings(),
|
|
63
|
+
searchParams,
|
|
64
|
+
listEnabledProviders().catch((failure: unknown) => {
|
|
65
|
+
logError(failure, "sign-in page: could not read sign-in providers");
|
|
66
|
+
return [];
|
|
67
|
+
}),
|
|
68
|
+
]);
|
|
69
|
+
// A sign-in provider that came back with an error (Better Auth adds ?error=<code>).
|
|
70
|
+
const code = errorCode(error);
|
|
71
|
+
return (
|
|
72
|
+
<div className="w-full h-full flex flex-col items-center justify-center gap-4 p-4">
|
|
73
|
+
{closed === "1" ? (
|
|
74
|
+
// After "Delete my account" (src/server/users.ts, requestOwnDeletion).
|
|
75
|
+
<p role="status" className="w-full max-w-lg rounded-md border p-3 text-sm">
|
|
76
|
+
Your account is closed and will be deleted in {DELETION_GRACE_DAYS} days. To keep it, ask an admin to restore it before then.
|
|
77
|
+
</p>
|
|
78
|
+
) : null}
|
|
79
|
+
<LoginForm settings={settings} redirectTo={safeRedirectPath(redirect)} />
|
|
80
|
+
<ProviderSignIn providers={providers} redirectTo={safeRedirectPath(redirect)} error={code ? providerSignInError(code) : null} />
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { connection } from "next/server";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
NewPasswordForm,
|
|
6
|
+
RequestResetForm,
|
|
7
|
+
ResetUnavailable,
|
|
8
|
+
} from "@/components/auth/ResetPasswordForm";
|
|
9
|
+
import { isDemo } from "@/lib/demo";
|
|
10
|
+
import { getSettings } from "@/lib/queries";
|
|
11
|
+
import { getEmailSender } from "@/server/email";
|
|
12
|
+
import { MIN_PASSWORD_LENGTH } from "@/server/auth";
|
|
13
|
+
import { isResetTokenValid } from "@/server/password-reset";
|
|
14
|
+
|
|
15
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
16
|
+
export const instant = false;
|
|
17
|
+
|
|
18
|
+
export const metadata: Metadata = {
|
|
19
|
+
title: "Reset password",
|
|
20
|
+
// The token is in the address: never send it to another site in a Referer header.
|
|
21
|
+
referrer: "no-referrer",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const ASK_ADMIN = "Ask an admin of this site for a new reset link.";
|
|
25
|
+
|
|
26
|
+
export default async function ResetPasswordPage({
|
|
27
|
+
searchParams,
|
|
28
|
+
}: {
|
|
29
|
+
searchParams: Promise<{ token?: string | string[] }>;
|
|
30
|
+
}) {
|
|
31
|
+
// Wait for a real request before the database and the clock (the token check reads both): `next
|
|
32
|
+
// build` stops here, so a build with no database never reaches them.
|
|
33
|
+
await connection();
|
|
34
|
+
const [settings, { token }] = await Promise.all([getSettings(), searchParams]);
|
|
35
|
+
const canEmail = (await getEmailSender()) !== null;
|
|
36
|
+
|
|
37
|
+
let content: React.ReactNode;
|
|
38
|
+
if (token === undefined && isDemo()) {
|
|
39
|
+
// The public demo: everyone opens the admin with one button and nobody signs in with a password.
|
|
40
|
+
content = (
|
|
41
|
+
<ResetUnavailable title="Reset your password">
|
|
42
|
+
Resetting a password is turned off in the demo: every visitor shares one account, and the Sign in page opens it without a password.
|
|
43
|
+
</ResetUnavailable>
|
|
44
|
+
);
|
|
45
|
+
} else if (token === undefined) {
|
|
46
|
+
content = canEmail ? (
|
|
47
|
+
<RequestResetForm siteName={settings.siteName} />
|
|
48
|
+
) : (
|
|
49
|
+
<ResetUnavailable title="Reset your password">
|
|
50
|
+
This site does not send email. {ASK_ADMIN} They can make one for you on the Users screen.
|
|
51
|
+
</ResetUnavailable>
|
|
52
|
+
);
|
|
53
|
+
} else if (typeof token === "string" && (await isResetTokenValid(token))) {
|
|
54
|
+
// Opened from a working reset link.
|
|
55
|
+
content = <NewPasswordForm token={token} minLength={MIN_PASSWORD_LENGTH} />;
|
|
56
|
+
} else {
|
|
57
|
+
content = (
|
|
58
|
+
<>
|
|
59
|
+
<ResetUnavailable title="This link no longer works">
|
|
60
|
+
Reset links work once, for one hour. {canEmail ? "Ask for a new one below." : ASK_ADMIN}
|
|
61
|
+
</ResetUnavailable>
|
|
62
|
+
{/* The card above holds the page's <h1>. */}
|
|
63
|
+
{canEmail && <RequestResetForm siteName={settings.siteName} heading="h2" />}
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className="w-full h-full flex flex-col items-center justify-center gap-6 p-4">
|
|
70
|
+
{content}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// A sign-in, reset, invite or confirm-email page failed to load (often the database). Without this,
|
|
4
|
+
// Next's unstyled default error page would show.
|
|
5
|
+
import { PageError } from '@/components/auth/PageError'
|
|
6
|
+
|
|
7
|
+
export default function AuthError(props: { error: Error & { digest?: string }; reset: () => void }) {
|
|
8
|
+
return <PageError {...props} />
|
|
9
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import { DemoBanner } from "@/components/demo/DemoBanner";
|
|
5
|
+
import { ThemeStyle } from "@/components/site/ThemeStyle";
|
|
6
|
+
import { demoResetMinutes, isDemo } from "@/lib/demo";
|
|
7
|
+
import { getSettings, siteIcons } from "@/lib/queries";
|
|
8
|
+
|
|
9
|
+
// Same styling setup as the (admin) layout: Tailwind and the shadcn tokens bridged to the site
|
|
10
|
+
// theme, plus the self-hosted fonts. Do NOT import ../(frontend)/styles.css here (see the note in
|
|
11
|
+
// the (admin) layout).
|
|
12
|
+
import "@pet-adopt/ui/globals.css";
|
|
13
|
+
import "../(frontend)/fonts";
|
|
14
|
+
import { RemountOnNavigate } from "@/components/admin/RemountOnNavigate";
|
|
15
|
+
import { AuthNav } from "@/components/auth/AuthNav";
|
|
16
|
+
|
|
17
|
+
// Cache Components: the sign-in screens are drawn per request (they read the session, a token in
|
|
18
|
+
// the address, the database) and may wait for it. Without this the build refuses them. It covers
|
|
19
|
+
// every page below; the pages repeat it only to keep `next dev`'s per-page check quiet.
|
|
20
|
+
export const instant = false;
|
|
21
|
+
|
|
22
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
23
|
+
return {
|
|
24
|
+
title: { default: "Sign in", template: "%s | Admin" },
|
|
25
|
+
robots: { index: false, follow: false },
|
|
26
|
+
icons: siteIcons(await getSettings()),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Layout for the signed-out screens (sign in, and later anything like it). This is a separate root
|
|
31
|
+
// layout from (admin), so it renders its own <html> and <body>; going from here to /admin is a full
|
|
32
|
+
// page load, which is fine for a sign-in.
|
|
33
|
+
export default async function AuthLayout({
|
|
34
|
+
children,
|
|
35
|
+
}: {
|
|
36
|
+
children: React.ReactNode;
|
|
37
|
+
}) {
|
|
38
|
+
// Signed-in people may be here: confirming a new email (/admin/confirm-email) is usually done
|
|
39
|
+
// while signed in. The sign-in page itself sends them to the admin.
|
|
40
|
+
// Only cached reads in this layout: it never reads the request itself (each page does).
|
|
41
|
+
const settings = await getSettings();
|
|
42
|
+
return (
|
|
43
|
+
// suppressHydrationWarning: the saved light/dark mode may be set on <html> before hydration.
|
|
44
|
+
<html lang="en" suppressHydrationWarning>
|
|
45
|
+
<head>
|
|
46
|
+
<ThemeStyle settings={settings} />
|
|
47
|
+
</head>
|
|
48
|
+
<body className="min-h-screen bg-background font-sans text-foreground antialiased w-full flex flex-col items-center justify-center">
|
|
49
|
+
{/* First focusable element: lets keyboard users skip the header (WCAG 2.4.1). Each screen's
|
|
50
|
+
card title is the page's one <h1>. */}
|
|
51
|
+
<a
|
|
52
|
+
href="#main-content"
|
|
53
|
+
className="sr-only focus:not-sr-only focus:absolute focus:left-2 focus:top-2 focus:z-50 focus:rounded-md focus:bg-background focus:px-3 focus:py-2"
|
|
54
|
+
>
|
|
55
|
+
Skip to main content
|
|
56
|
+
</a>
|
|
57
|
+
{/* The public demo (PET_ADOPT_DEMO=1) says so above the header, after the skip link. */}
|
|
58
|
+
{isDemo() ? <DemoBanner resetMinutes={demoResetMinutes()} /> : null}
|
|
59
|
+
<header className="w-full flex items-start justify-between py-2 px-4 border-b border-border text-muted-foreground">
|
|
60
|
+
<p className="text-sm">{settings.siteName} </p>
|
|
61
|
+
<AuthNav demo={isDemo()} />
|
|
62
|
+
</header>
|
|
63
|
+
<main id="main-content" tabIndex={-1} className="flex flex-auto items-center justify-center px-4 py-12 w-full">
|
|
64
|
+
{/* A fresh screen on every navigation, as before Cache Components: "Check your email"
|
|
65
|
+
would otherwise still be there on the next visit to Reset password. */}
|
|
66
|
+
<RemountOnNavigate>{children}</RemountOnNavigate>
|
|
67
|
+
</main>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
|
70
|
+
);
|
|
71
|
+
}
|