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,76 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
import Link from 'next/link'
|
|
3
|
+
|
|
4
|
+
import { buttonVariants } from '@pet-adopt/ui/components/button'
|
|
5
|
+
import { ActivityFilters, type ActivityFilterValues } from '@/components/admin/activity/ActivityFilters'
|
|
6
|
+
import { ActivityList, ExportActivityButton } from '@/components/admin/activity/ActivityLog'
|
|
7
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
8
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
9
|
+
import { activityRetentionDays } from '@/server/activity'
|
|
10
|
+
import { listActivityAction } from '@/server/actions/activity'
|
|
11
|
+
|
|
12
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
13
|
+
export const instant = false
|
|
14
|
+
|
|
15
|
+
export const metadata = { title: 'Activity' }
|
|
16
|
+
|
|
17
|
+
type Search = Record<string, string | string[] | undefined>
|
|
18
|
+
const one = (value: string | string[] | undefined) => (typeof value === 'string' && value ? value : null)
|
|
19
|
+
|
|
20
|
+
// Who did what, and when (src/server/activity.ts). Everyone sees their own entries; admins and
|
|
21
|
+
// audit see everyone's and can download them. Filters live in the URL; the actions check them.
|
|
22
|
+
export default async function ActivityPage({ searchParams }: { searchParams: Promise<Search> }) {
|
|
23
|
+
const me = await requirePermissionPage('activity:own')
|
|
24
|
+
const search = await searchParams
|
|
25
|
+
const filters: ActivityFilterValues = { area: one(search.area), actor: one(search.actor), from: one(search.from), to: one(search.to) }
|
|
26
|
+
const page = Math.max(Math.floor(Number(one(search.page)) || 1), 1)
|
|
27
|
+
const data = unwrap(await listActivityAction({ ...filters, page }))
|
|
28
|
+
const all = data.scope === 'all'
|
|
29
|
+
const days = activityRetentionDays()
|
|
30
|
+
const kept = days % 365 === 0 ? `${days / 365} year${days === 365 ? '' : 's'}` : `${days} days`
|
|
31
|
+
|
|
32
|
+
const pageHref = (target: number) => {
|
|
33
|
+
const params = new URLSearchParams()
|
|
34
|
+
for (const [key, value] of Object.entries(filters)) if (value) params.set(key, value)
|
|
35
|
+
if (target > 1) params.set('page', String(target))
|
|
36
|
+
return params.size ? `/admin/activity?${params}` : '/admin/activity'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<PageHeader
|
|
42
|
+
title="Activity"
|
|
43
|
+
description={
|
|
44
|
+
all
|
|
45
|
+
? `Who changed what, and when, for everyone. Entries are kept for ${kept}.`
|
|
46
|
+
: `What you have changed, your sign-ins, and failed sign-ins to your account. Entries are kept for ${kept}.`
|
|
47
|
+
}
|
|
48
|
+
actions={can(me.role, 'activity:export') ? <ExportActivityButton filters={filters} disabled={data.total === 0} /> : null}
|
|
49
|
+
/>
|
|
50
|
+
<div className="flex flex-col gap-4">
|
|
51
|
+
<ActivityFilters values={filters} actors={data.actors} />
|
|
52
|
+
<p className="text-sm text-muted-foreground" aria-live="polite">
|
|
53
|
+
{data.total} {data.total === 1 ? 'entry' : 'entries'}
|
|
54
|
+
{data.pages > 1 ? `, page ${data.page} of ${data.pages}` : ''}
|
|
55
|
+
</p>
|
|
56
|
+
<ActivityList rows={data.entries} meId={me.id} showClient={all} />
|
|
57
|
+
{data.pages > 1 ? (
|
|
58
|
+
<nav aria-label="Pages" className="flex items-center justify-between gap-2">
|
|
59
|
+
{data.page > 1 ? (
|
|
60
|
+
<Link className={buttonVariants({ variant: 'outline' })} href={pageHref(data.page - 1)}>
|
|
61
|
+
Newer
|
|
62
|
+
</Link>
|
|
63
|
+
) : (
|
|
64
|
+
<span />
|
|
65
|
+
)}
|
|
66
|
+
{data.page < data.pages ? (
|
|
67
|
+
<Link className={buttonVariants({ variant: 'outline' })} href={pageHref(data.page + 1)}>
|
|
68
|
+
Older
|
|
69
|
+
</Link>
|
|
70
|
+
) : null}
|
|
71
|
+
</nav>
|
|
72
|
+
) : null}
|
|
73
|
+
</div>
|
|
74
|
+
</>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { ArchivedAccounts } from '@/components/admin/users/ArchivedAccounts'
|
|
4
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
5
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
6
|
+
import { listUsersAction } from '@/server/actions/users'
|
|
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 = { title: 'Archived accounts' }
|
|
12
|
+
|
|
13
|
+
// Authentication > Archived accounts. Admins restore or delete them; audit views the list.
|
|
14
|
+
export default async function ArchivedAccountsPage() {
|
|
15
|
+
const me = await requirePermissionPage('users:view')
|
|
16
|
+
const users = unwrap(await listUsersAction()).filter((user) => user.archivedAt)
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ViewOnly value={!can(me.role, 'users:edit')}>
|
|
20
|
+
<ViewOnlyNotice role={me.role} what="the archived accounts" />
|
|
21
|
+
<ArchivedAccounts users={users} />
|
|
22
|
+
</ViewOnly>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
2
|
+
import { RemountInSection } from '@/components/admin/RemountOnNavigate'
|
|
3
|
+
import { AuthenticationNav } from '@/components/admin/settings/AuthenticationNav'
|
|
4
|
+
|
|
5
|
+
// The Authentication page: its screens (Two-factor, Archived accounts) in a side menu next to the
|
|
6
|
+
// content, like Email and Site settings. Each screen is its own route and checks its own permission.
|
|
7
|
+
export default function AuthenticationLayout({ children }: { children: React.ReactNode }) {
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<PageHeader title="Authentication" />
|
|
11
|
+
<div className="flex flex-col gap-6 md:flex-row md:items-start">
|
|
12
|
+
<AuthenticationNav />
|
|
13
|
+
<div className="min-w-0 flex-1">
|
|
14
|
+
{/* A fresh screen per address; the menu above stays (see RemountOnNavigate). */}
|
|
15
|
+
<RemountInSection>{children}</RemountInSection>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { DemoNotice } from '@/components/admin/DemoNotice'
|
|
4
|
+
import { TwoFactorRoles } from '@/components/admin/users/TwoFactorRoles'
|
|
5
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
6
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
7
|
+
import { isDemo } from '@/lib/demo'
|
|
8
|
+
import { getTwoFactorRolesAction } from '@/server/actions/two-factor'
|
|
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 = { title: 'Two-factor' }
|
|
14
|
+
|
|
15
|
+
// Authentication > Two-factor: which roles must use two-factor sign-in. Admins change it; audit
|
|
16
|
+
// views it. Each person sets up their own on the Account page; an admin turns it off for someone
|
|
17
|
+
// who lost their phone on the Users screen. In the demo the screen is read-only, with a note (every
|
|
18
|
+
// visitor shares one account, and the action refuses).
|
|
19
|
+
export default async function TwoFactorSettingsPage() {
|
|
20
|
+
const me = await requirePermissionPage('users:view')
|
|
21
|
+
const roles = unwrap(await getTwoFactorRolesAction())
|
|
22
|
+
const demo = isDemo()
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ViewOnly value={demo || !can(me.role, 'users:edit')}>
|
|
26
|
+
{demo ? (
|
|
27
|
+
<DemoNotice className="mb-4 max-w-2xl" what="Requiring two-factor sign-in" why="every visitor shares one account" />
|
|
28
|
+
) : (
|
|
29
|
+
<ViewOnlyNotice role={me.role} what="the sign-in rules" />
|
|
30
|
+
)}
|
|
31
|
+
<div className="max-w-2xl">
|
|
32
|
+
<TwoFactorRoles roles={roles} meRole={me.role} meEnabled={me.twoFactorEnabled} />
|
|
33
|
+
</div>
|
|
34
|
+
</ViewOnly>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { DemoNotice } from '@/components/admin/DemoNotice'
|
|
4
|
+
import { AuthProviders } from '@/components/admin/settings/AuthProviders'
|
|
5
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
6
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
7
|
+
import { isDemo } from '@/lib/demo'
|
|
8
|
+
import { listAuthProvidersAction } from '@/server/actions/auth-providers'
|
|
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 = { title: 'Sign-in providers' }
|
|
14
|
+
|
|
15
|
+
// Authentication > Sign-in providers (OAuth 2 / OpenID Connect). Admins change them; audit views.
|
|
16
|
+
// In the demo the screen is read-only, with a note (the server would connect to addresses visitors
|
|
17
|
+
// type, and the actions refuse).
|
|
18
|
+
export default async function SignInProvidersPage() {
|
|
19
|
+
const me = await requirePermissionPage('users:view')
|
|
20
|
+
const providers = unwrap(await listAuthProvidersAction())
|
|
21
|
+
const demo = isDemo()
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ViewOnly value={demo || !can(me.role, 'users:edit')}>
|
|
25
|
+
{demo ? (
|
|
26
|
+
<DemoNotice className="mb-4 max-w-3xl" what="Adding sign-in providers" why="it connects to no outside services" />
|
|
27
|
+
) : (
|
|
28
|
+
<ViewOnlyNotice role={me.role} what="the sign-in providers" />
|
|
29
|
+
)}
|
|
30
|
+
<AuthProviders providers={providers} />
|
|
31
|
+
</ViewOnly>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EmailNav } from '@/components/admin/settings/EmailNav'
|
|
2
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
3
|
+
import { RemountInSection } from '@/components/admin/RemountOnNavigate'
|
|
4
|
+
|
|
5
|
+
// The Email page: its screens (Sending, Templates) in a side menu next to the content, like Site
|
|
6
|
+
// settings: a fixed column from md up (it stays in view while the page scrolls), stacked above the
|
|
7
|
+
// content on phones. Each screen is its own route and checks its own permission.
|
|
8
|
+
export default function EmailLayout({ children }: { children: React.ReactNode }) {
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<PageHeader title="Email" />
|
|
12
|
+
<div className="flex flex-col gap-6 md:flex-row md:items-start">
|
|
13
|
+
<EmailNav />
|
|
14
|
+
<div className="min-w-0 flex-1">
|
|
15
|
+
{/* A fresh screen per address; the menu above stays (see RemountOnNavigate). */}
|
|
16
|
+
<RemountInSection>{children}</RemountInSection>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { DemoNotice } from '@/components/admin/DemoNotice'
|
|
4
|
+
import { SendTestEmail } from '@/components/admin/plugins/SendTestEmail'
|
|
5
|
+
import { EmailSettingsForm } from '@/components/admin/settings/EmailSettingsForm'
|
|
6
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
7
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
8
|
+
import { isDemo } from '@/lib/demo'
|
|
9
|
+
import { getEmailSettingsAction } from '@/server/actions/email'
|
|
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: 'Email' }
|
|
15
|
+
|
|
16
|
+
// Email > Sending: the built-in SMTP sender (src/server/email.ts). Admins and developers change it
|
|
17
|
+
// (`settings:edit`); audit sees it, never the password. The demo sends no email (getEmailSender is
|
|
18
|
+
// null there): the form is read-only with a note, and there is no test email.
|
|
19
|
+
export default async function EmailSettingsPage() {
|
|
20
|
+
const user = await requirePermissionPage('settings:view')
|
|
21
|
+
const view = unwrap(await getEmailSettingsAction())
|
|
22
|
+
const demo = isDemo()
|
|
23
|
+
const canEdit = can(user.role, 'settings:edit') && !demo
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<ViewOnly value={!canEdit}>
|
|
28
|
+
{demo ? (
|
|
29
|
+
<DemoNotice className="mb-4 max-w-3xl">Sending email is turned off in the demo, so these settings cannot be saved.</DemoNotice>
|
|
30
|
+
) : (
|
|
31
|
+
<ViewOnlyNotice role={user.role} what="the email settings" />
|
|
32
|
+
)}
|
|
33
|
+
<EmailSettingsForm initial={view} />
|
|
34
|
+
</ViewOnly>
|
|
35
|
+
{canEdit ? (
|
|
36
|
+
<section className="mt-8 max-w-3xl rounded-lg border p-4">
|
|
37
|
+
{/* Uses whatever sends the site's email: this SMTP server, or an email plugin. */}
|
|
38
|
+
<SendTestEmail defaultTo={user.email} disabled={!view.ready && !view.plugin?.ready} />
|
|
39
|
+
</section>
|
|
40
|
+
) : null}
|
|
41
|
+
</>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { can, foldText } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import { EmailTemplates } from '@/components/admin/settings/EmailTemplates'
|
|
4
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
5
|
+
import { SYSTEM_PURPOSES } from '@/lib/email-template'
|
|
6
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
7
|
+
import { listEmailTemplatesAction } from '@/server/actions/email-templates'
|
|
8
|
+
import { getEmailTemplateUsage } from '@/plugins/registry'
|
|
9
|
+
import { getSystemEmail } from '@/server/email-templates'
|
|
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: 'Email templates' }
|
|
15
|
+
|
|
16
|
+
// Email > Templates (src/server/email-templates.ts). Admins and developers make and change
|
|
17
|
+
// templates; audit can look at them.
|
|
18
|
+
export default async function EmailTemplatesPage() {
|
|
19
|
+
const user = await requirePermissionPage('settings:view')
|
|
20
|
+
const [library, usage] = await Promise.all([listEmailTemplatesAction().then(unwrap), getEmailTemplateUsage()])
|
|
21
|
+
const templates = library
|
|
22
|
+
// Forms that picked nothing use a plugin's default template: listed under it too.
|
|
23
|
+
.map((template) => ({ ...template, usedBy: [...(usage.get(template.id) ?? []), ...(template.seedKey ? (usage.get(template.seedKey) ?? []) : [])] }))
|
|
24
|
+
.sort((a, b) => foldText(a.name).localeCompare(foldText(b.name)))
|
|
25
|
+
const system = await Promise.all(SYSTEM_PURPOSES.map(async (purpose) => {
|
|
26
|
+
const email = await getSystemEmail(purpose)
|
|
27
|
+
return { purpose, customised: email.customised, updatedAt: email.updatedAt }
|
|
28
|
+
}))
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<ViewOnly value={!can(user.role, 'settings:edit')}>
|
|
33
|
+
<ViewOnlyNotice role={user.role} what="the email templates" />
|
|
34
|
+
<EmailTemplates templates={templates} system={system} />
|
|
35
|
+
</ViewOnly>
|
|
36
|
+
</>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useRouter } from 'next/navigation'
|
|
4
|
+
import { startTransition } from 'react'
|
|
5
|
+
|
|
6
|
+
import { Button } from '@pet-adopt/ui/components/button'
|
|
7
|
+
|
|
8
|
+
// A screen failed to load (the data layer threw, often through `unwrap`). In a production build
|
|
9
|
+
// Next.js replaces the message of an error thrown on the server with a generic sentence and gives a
|
|
10
|
+
// `digest` instead, which is also printed beside the error in the server log. So the screen says
|
|
11
|
+
// what to do and shows the digest as a reference; the message itself only in development.
|
|
12
|
+
export default function AdminError({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
|
|
13
|
+
const router = useRouter()
|
|
14
|
+
const showMessage = process.env.NODE_ENV === 'development' && error.message
|
|
15
|
+
// reset() alone re-renders with the same failed server data: ask the server again first.
|
|
16
|
+
const retry = () =>
|
|
17
|
+
startTransition(() => {
|
|
18
|
+
router.refresh()
|
|
19
|
+
reset()
|
|
20
|
+
})
|
|
21
|
+
return (
|
|
22
|
+
<div role="alert" className="space-y-3">
|
|
23
|
+
<h1 className="text-xl font-semibold">Something went wrong</h1>
|
|
24
|
+
<p className="text-sm text-muted-foreground">
|
|
25
|
+
This screen could not be loaded. Try again; if it keeps happening, the server log has the details.
|
|
26
|
+
</p>
|
|
27
|
+
{showMessage ? <p className="text-sm text-muted-foreground">{error.message}</p> : null}
|
|
28
|
+
{error.digest ? (
|
|
29
|
+
<p className="text-sm text-muted-foreground">
|
|
30
|
+
Reference: <code className="font-mono">{error.digest}</code>
|
|
31
|
+
</p>
|
|
32
|
+
) : null}
|
|
33
|
+
<Button onClick={retry}>Try again</Button>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { redirect } from 'next/navigation'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { AdminShell } from '@/components/admin/AdminShell'
|
|
5
|
+
import { DemoMode } from '@/components/admin/demo-mode'
|
|
6
|
+
import { EmailConfirmBanner } from '@/components/admin/EmailConfirmBanner'
|
|
7
|
+
import { isDemo } from '@/lib/demo'
|
|
8
|
+
import { needsEmailConfirmation } from '@/server/email-change'
|
|
9
|
+
import { getSessionUser } from '@/server/session'
|
|
10
|
+
|
|
11
|
+
// The frame for every screen under /admin. The root (admin) layout already redirects signed-out
|
|
12
|
+
// visitors; this one needs the user for the menu and role-based navigation.
|
|
13
|
+
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
|
|
14
|
+
const user = await getSessionUser()
|
|
15
|
+
if (!user) redirect('/admin/login')
|
|
16
|
+
// Not confirmed their email while the site can send email: a banner, and changes are refused.
|
|
17
|
+
const banner = (await needsEmailConfirmation(user)) ? <EmailConfirmBanner email={user.email} /> : null
|
|
18
|
+
return (
|
|
19
|
+
// The public demo: client components below draw a DemoNotice where a control is turned off.
|
|
20
|
+
<DemoMode value={isDemo()}>
|
|
21
|
+
<AdminShell user={user} banner={banner}>
|
|
22
|
+
{children}
|
|
23
|
+
</AdminShell>
|
|
24
|
+
</DemoMode>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Shown while a screen loads its data: one plain line for every screen. A screen that wants a
|
|
2
|
+
// skeleton shaped like itself adds its own loading.tsx.
|
|
3
|
+
export default function Loading() {
|
|
4
|
+
return (
|
|
5
|
+
<p role="status" className="text-sm text-muted-foreground">
|
|
6
|
+
Loading…
|
|
7
|
+
</p>
|
|
8
|
+
)
|
|
9
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import Link from 'next/link'
|
|
2
|
+
import { FiArrowLeft } from 'react-icons/fi'
|
|
3
|
+
|
|
4
|
+
import { MediaDetails } from '@/components/admin/MediaDetails'
|
|
5
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
6
|
+
import { buttonVariants } from '@pet-adopt/ui/components/button'
|
|
7
|
+
import { ViewOnly, ViewOnlyNotice } from '@/components/admin/view-only'
|
|
8
|
+
import { parseId, requirePermissionPage, unwrapOrNotFound } from '@/lib/admin/unwrap'
|
|
9
|
+
import { can, formatWhen } from '@pet-adopt/plugin-sdk'
|
|
10
|
+
import { extensionOf } from '@/lib/media-name'
|
|
11
|
+
import { getSettings } from '@/lib/queries'
|
|
12
|
+
import { getMediaAction } from '@/server/actions/media'
|
|
13
|
+
|
|
14
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
15
|
+
export const instant = false
|
|
16
|
+
|
|
17
|
+
export const metadata = { title: 'Image' }
|
|
18
|
+
|
|
19
|
+
// One image from the library: the picture, its file details, where it is used, its alt text
|
|
20
|
+
// (editable) and delete. A tile in the library grid links here while "Select images" is off.
|
|
21
|
+
|
|
22
|
+
const sizeLabel = (bytes: number) => (bytes < 1024 * 1024 ? `${Math.max(1, Math.round(bytes / 1024))} KB` : `${(bytes / 1024 / 1024).toFixed(1)} MB`)
|
|
23
|
+
|
|
24
|
+
export default async function MediaImagePage({ params }: { params: Promise<{ id: string }> }) {
|
|
25
|
+
const user = await requirePermissionPage('media:view')
|
|
26
|
+
const { id } = await params
|
|
27
|
+
const { media, usage } = unwrapOrNotFound(await getMediaAction(parseId(id)))
|
|
28
|
+
|
|
29
|
+
const uses = [
|
|
30
|
+
usage.pets ? `${usage.pets} ${usage.pets === 1 ? 'pet' : 'pets'} (photos or share image)` : null,
|
|
31
|
+
usage.pages ? `${usage.pages} ${usage.pages === 1 ? 'page' : 'pages'} (share image)` : null,
|
|
32
|
+
usage.layouts ? `${usage.layouts} page ${usage.layouts === 1 ? 'layout' : 'layouts'}` : null,
|
|
33
|
+
usage.emails ? `${usage.emails} email ${usage.emails === 1 ? 'template' : 'templates'}` : null,
|
|
34
|
+
usage.timeline ? `${usage.timeline} pet timeline ${usage.timeline === 1 ? 'entry' : 'entries'}` : null,
|
|
35
|
+
usage.logo ? 'the site logo' : null,
|
|
36
|
+
usage.favicon ? 'the site icon' : null,
|
|
37
|
+
].filter((use): use is string => use !== null)
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<Link href="/admin/media" className={buttonVariants({ variant: 'ghost', size: 'sm', className: '-ml-2 mb-2' })}>
|
|
42
|
+
<FiArrowLeft aria-hidden />
|
|
43
|
+
Media library
|
|
44
|
+
</Link>
|
|
45
|
+
<PageHeader title={media.name || media.alt || media.filename} description={media.name ? media.alt : undefined} />
|
|
46
|
+
<div className="grid gap-6 lg:grid-cols-[minmax(0,3fr)_minmax(18rem,2fr)]">
|
|
47
|
+
<div className="flex items-start justify-center rounded-lg border bg-muted/40 p-2">
|
|
48
|
+
{/* The original file, at most the screen's height. The text beside it describes it, so
|
|
49
|
+
the alt text here is the image's own. */}
|
|
50
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
51
|
+
<img src={media.url} alt={media.alt} className="max-h-[70vh] w-auto max-w-full rounded object-contain" />
|
|
52
|
+
</div>
|
|
53
|
+
<div className="flex flex-col gap-6">
|
|
54
|
+
<section aria-labelledby="media-file-heading">
|
|
55
|
+
<h2 id="media-file-heading" className="mb-2 font-semibold">
|
|
56
|
+
File
|
|
57
|
+
</h2>
|
|
58
|
+
<dl className="grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm">
|
|
59
|
+
<dt className="text-muted-foreground">Type</dt>
|
|
60
|
+
<dd>{media.mimeType.replace('image/', '').toUpperCase()}</dd>
|
|
61
|
+
<dt className="text-muted-foreground">Size</dt>
|
|
62
|
+
<dd>{sizeLabel(media.size)}</dd>
|
|
63
|
+
{media.width && media.height ? (
|
|
64
|
+
<>
|
|
65
|
+
<dt className="text-muted-foreground">Dimensions</dt>
|
|
66
|
+
<dd>
|
|
67
|
+
{media.width} × {media.height} px
|
|
68
|
+
</dd>
|
|
69
|
+
</>
|
|
70
|
+
) : null}
|
|
71
|
+
<dt className="text-muted-foreground">Uploaded</dt>
|
|
72
|
+
<dd>{formatWhen(media.createdAt, (await getSettings()).timeZone, 'longDate')}</dd>
|
|
73
|
+
</dl>
|
|
74
|
+
</section>
|
|
75
|
+
<section aria-labelledby="media-usage-heading">
|
|
76
|
+
<h2 id="media-usage-heading" className="mb-2 font-semibold">
|
|
77
|
+
Where it is used
|
|
78
|
+
</h2>
|
|
79
|
+
{uses.length ? (
|
|
80
|
+
<ul className="list-disc pl-5 text-sm">
|
|
81
|
+
{uses.map((use) => (
|
|
82
|
+
<li key={use}>{use}</li>
|
|
83
|
+
))}
|
|
84
|
+
</ul>
|
|
85
|
+
) : (
|
|
86
|
+
<p className="text-sm text-muted-foreground">Not used anywhere yet.</p>
|
|
87
|
+
)}
|
|
88
|
+
</section>
|
|
89
|
+
<ViewOnly value={!can(user.role, 'media:edit')}>
|
|
90
|
+
<ViewOnlyNotice role={user.role} what="this image" />
|
|
91
|
+
<MediaDetails id={media.id} name={media.name} alt={media.alt} extension={extensionOf(media.filename)} inUse={uses.length > 0} />
|
|
92
|
+
</ViewOnly>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
import type { SearchParams } from 'nuqs/server'
|
|
3
|
+
|
|
4
|
+
import { MediaLibrary } from '@/components/admin/MediaLibrary'
|
|
5
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
6
|
+
import { ViewOnly } from '@/components/admin/view-only'
|
|
7
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
8
|
+
import { listMediaAction } from '@/server/actions/media'
|
|
9
|
+
|
|
10
|
+
import { loadMediaSearchParams } from './search-params'
|
|
11
|
+
|
|
12
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
13
|
+
export const instant = false
|
|
14
|
+
|
|
15
|
+
export const metadata = { title: 'Media' }
|
|
16
|
+
|
|
17
|
+
// Like the pets list: the view lives in the URL (?search=&page=&perPage=, see ./search-params.ts).
|
|
18
|
+
// This server component only loads the first render, the URL as it was when the page opened and
|
|
19
|
+
// the images for it. After that MediaLibrary changes the URL without asking the server and fetches
|
|
20
|
+
// and caches the images with SWR.
|
|
21
|
+
export default async function MediaPage({ searchParams }: { searchParams: Promise<SearchParams> }) {
|
|
22
|
+
const user = await requirePermissionPage('media:view')
|
|
23
|
+
const filters = await loadMediaSearchParams(searchParams)
|
|
24
|
+
const initialData = unwrap(await listMediaAction({ search: filters.search || undefined, page: filters.page, limit: filters.perPage }))
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<PageHeader title="Media" description="Every image used on the site: pet photos, page images, the logo and the site icon." />
|
|
29
|
+
<ViewOnly value={!can(user.role, 'media:edit')}>
|
|
30
|
+
<MediaLibrary initialFilters={filters} initialData={initialData} />
|
|
31
|
+
</ViewOnly>
|
|
32
|
+
</>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createLoader, parseAsInteger, parseAsNumberLiteral, parseAsString } from 'nuqs/server'
|
|
2
|
+
|
|
3
|
+
import { MEDIA_PAGE_SIZES } from '@/lib/admin/media-page'
|
|
4
|
+
|
|
5
|
+
// The media library's view, as it appears in the URL (?search=&page=&perPage=). Like the pets
|
|
6
|
+
// list (../pets/search-params.ts): `nuqs/server` has no React in it, so the server page loads the
|
|
7
|
+
// first render with `loadMediaSearchParams` and the client reads and writes the same parsers with
|
|
8
|
+
// `useQueryStates(mediaSearchParsers)`. Only the offered page sizes are accepted; anything else
|
|
9
|
+
// in the URL falls back to the default.
|
|
10
|
+
export const mediaSearchParsers = {
|
|
11
|
+
search: parseAsString.withDefault(''),
|
|
12
|
+
page: parseAsInteger.withDefault(1),
|
|
13
|
+
perPage: parseAsNumberLiteral(MEDIA_PAGE_SIZES.options).withDefault(MEDIA_PAGE_SIZES.default),
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const loadMediaSearchParams = createLoader(mediaSearchParsers)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { can } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
import Link from 'next/link'
|
|
3
|
+
|
|
4
|
+
import { RecentActivity } from '@/components/admin/activity/RecentActivity'
|
|
5
|
+
import { PageHeader } from '@/components/admin/PageHeader'
|
|
6
|
+
import { PluginWidgets } from '@/components/admin/PluginWidgets'
|
|
7
|
+
import { buttonVariants } from '@pet-adopt/ui/components/button'
|
|
8
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@pet-adopt/ui/components/card'
|
|
9
|
+
import { requirePermissionPage, unwrap } from '@/lib/admin/unwrap'
|
|
10
|
+
import { PetStatus } from '@/lib/options'
|
|
11
|
+
import { listMediaAction } from '@/server/actions/media'
|
|
12
|
+
import { listPagesAction } from '@/server/actions/pages'
|
|
13
|
+
import { listPetsAction } from '@/server/actions/pets'
|
|
14
|
+
import { isSetupDone } from '@/server/setup'
|
|
15
|
+
import { redirect } from 'next/navigation'
|
|
16
|
+
|
|
17
|
+
// Per request, and may wait for its data: see `instant` in the root layout.
|
|
18
|
+
export const instant = false
|
|
19
|
+
|
|
20
|
+
export const metadata = { title: 'Dashboard' }
|
|
21
|
+
|
|
22
|
+
// Counts come from the list actions (there is no dedicated stats action): `limit: 1` keeps them cheap
|
|
23
|
+
// and `totalDocs` is the number that matches.
|
|
24
|
+
export default async function DashboardPage() {
|
|
25
|
+
const user = await requirePermissionPage('pets:view')
|
|
26
|
+
// The guided first-time setup until an admin finishes or skips it (src/server/setup.ts).
|
|
27
|
+
if (can(user.role, 'settings:edit') && !(await isSetupDone())) redirect('/setup')
|
|
28
|
+
const [available, pending, adopted, pages, media] = await Promise.all([
|
|
29
|
+
listPetsAction({ status: PetStatus.Available, limit: 1 }),
|
|
30
|
+
listPetsAction({ status: PetStatus.Pending, limit: 1 }),
|
|
31
|
+
listPetsAction({ status: PetStatus.Adopted, limit: 1 }),
|
|
32
|
+
listPagesAction(),
|
|
33
|
+
listMediaAction({ limit: 1 }),
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
const stats = [
|
|
37
|
+
{ label: 'Available pets', value: unwrap(available).totalDocs },
|
|
38
|
+
{ label: 'Pending pets', value: unwrap(pending).totalDocs },
|
|
39
|
+
{ label: 'Adopted pets', value: unwrap(adopted).totalDocs },
|
|
40
|
+
{ label: 'Pages', value: unwrap(pages).length },
|
|
41
|
+
{ label: 'Images', value: unwrap(media).totalDocs },
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<PageHeader
|
|
47
|
+
title="Dashboard"
|
|
48
|
+
actions={
|
|
49
|
+
<>
|
|
50
|
+
{can(user.role, 'pets:edit') ? (
|
|
51
|
+
<Link href="/admin/pets/new" className={buttonVariants()}>
|
|
52
|
+
Add pet
|
|
53
|
+
</Link>
|
|
54
|
+
) : null}
|
|
55
|
+
{can(user.role, 'pages:edit') ? (
|
|
56
|
+
<Link href="/admin/pages/new" className={buttonVariants({ variant: 'outline' })}>
|
|
57
|
+
New page
|
|
58
|
+
</Link>
|
|
59
|
+
) : null}
|
|
60
|
+
</>
|
|
61
|
+
}
|
|
62
|
+
/>
|
|
63
|
+
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-5">
|
|
64
|
+
{stats.map(({ label, value }) => (
|
|
65
|
+
<li key={label}>
|
|
66
|
+
<Card>
|
|
67
|
+
<CardHeader>
|
|
68
|
+
<CardTitle className="text-sm font-medium">{label}</CardTitle>
|
|
69
|
+
</CardHeader>
|
|
70
|
+
<CardContent className="text-3xl font-semibold">{value}</CardContent>
|
|
71
|
+
</Card>
|
|
72
|
+
</li>
|
|
73
|
+
))}
|
|
74
|
+
</ul>
|
|
75
|
+
{can(user.role, 'activity:own') ? <RecentActivity /> : null}
|
|
76
|
+
<PluginWidgets />
|
|
77
|
+
</>
|
|
78
|
+
)
|
|
79
|
+
}
|