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.
Files changed (486) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +120 -0
  3. package/index.js +920 -0
  4. package/package.json +43 -1
  5. package/template/.env.example +136 -0
  6. package/template/.pet-adopt/template.json +581 -0
  7. package/template/LICENSE +21 -0
  8. package/template/README.md +109 -0
  9. package/template/_gitignore +28 -0
  10. package/template/_pnpm-lock.yaml +9251 -0
  11. package/template/assets/sample-pet.png +0 -0
  12. package/template/components.json +25 -0
  13. package/template/docker-compose.yml +110 -0
  14. package/template/drizzle/pg/0000_initial.sql +176 -0
  15. package/template/drizzle/pg/0001_greedy_the_renegades.sql +1 -0
  16. package/template/drizzle/pg/0002_fuzzy_the_renegades.sql +1 -0
  17. package/template/drizzle/pg/0003_thin_multiple_man.sql +1 -0
  18. package/template/drizzle/pg/0004_boring_norman_osborn.sql +15 -0
  19. package/template/drizzle/pg/0005_bitter_proemial_gods.sql +3 -0
  20. package/template/drizzle/pg/0006_friendly_black_knight.sql +2 -0
  21. package/template/drizzle/pg/0007_wise_ozymandias.sql +11 -0
  22. package/template/drizzle/pg/0008_messy_human_fly.sql +2 -0
  23. package/template/drizzle/pg/0009_amused_lady_bullseye.sql +1 -0
  24. package/template/drizzle/pg/0010_cute_mauler.sql +7 -0
  25. package/template/drizzle/pg/0011_clear_purple_man.sql +3 -0
  26. package/template/drizzle/pg/0012_tiresome_gunslinger.sql +2 -0
  27. package/template/drizzle/pg/0013_awesome_wong.sql +18 -0
  28. package/template/drizzle/pg/0014_fantastic_sumo.sql +12 -0
  29. package/template/drizzle/pg/0015_pink_carnage.sql +12 -0
  30. package/template/drizzle/pg/0016_sloppy_king_bedlam.sql +2 -0
  31. package/template/drizzle/pg/0017_steep_warhawk.sql +15 -0
  32. package/template/drizzle/pg/0018_mixed_otto_octavius.sql +4 -0
  33. package/template/drizzle/pg/0019_talented_rocket_raccoon.sql +1 -0
  34. package/template/drizzle/pg/0020_worthless_zodiak.sql +19 -0
  35. package/template/drizzle/pg/0021_adorable_squadron_supreme.sql +1 -0
  36. package/template/drizzle/pg/0022_soft_pixie.sql +5 -0
  37. package/template/drizzle/pg/0023_fluffy_quasar.sql +1 -0
  38. package/template/drizzle/pg/0024_uneven_ken_ellis.sql +2 -0
  39. package/template/drizzle/pg/0025_rich_white_queen.sql +3 -0
  40. package/template/drizzle/pg/0026_spooky_komodo.sql +16 -0
  41. package/template/drizzle/pg/0027_big_thunderbolts.sql +2 -0
  42. package/template/drizzle/pg/meta/0000_snapshot.json +1265 -0
  43. package/template/drizzle/pg/meta/0001_snapshot.json +1272 -0
  44. package/template/drizzle/pg/meta/0002_snapshot.json +1278 -0
  45. package/template/drizzle/pg/meta/0003_snapshot.json +1284 -0
  46. package/template/drizzle/pg/meta/0004_snapshot.json +1401 -0
  47. package/template/drizzle/pg/meta/0005_snapshot.json +1401 -0
  48. package/template/drizzle/pg/meta/0006_snapshot.json +1414 -0
  49. package/template/drizzle/pg/meta/0007_snapshot.json +1485 -0
  50. package/template/drizzle/pg/meta/0008_snapshot.json +1504 -0
  51. package/template/drizzle/pg/meta/0009_snapshot.json +1510 -0
  52. package/template/drizzle/pg/meta/0010_snapshot.json +1556 -0
  53. package/template/drizzle/pg/meta/0011_snapshot.json +1574 -0
  54. package/template/drizzle/pg/meta/0012_snapshot.json +1586 -0
  55. package/template/drizzle/pg/meta/0013_snapshot.json +1730 -0
  56. package/template/drizzle/pg/meta/0014_snapshot.json +1805 -0
  57. package/template/drizzle/pg/meta/0015_snapshot.json +1883 -0
  58. package/template/drizzle/pg/meta/0016_snapshot.json +1897 -0
  59. package/template/drizzle/pg/meta/0017_snapshot.json +2013 -0
  60. package/template/drizzle/pg/meta/0018_snapshot.json +1988 -0
  61. package/template/drizzle/pg/meta/0019_snapshot.json +1994 -0
  62. package/template/drizzle/pg/meta/0020_snapshot.json +2108 -0
  63. package/template/drizzle/pg/meta/0021_snapshot.json +2114 -0
  64. package/template/drizzle/pg/meta/0022_snapshot.json +2126 -0
  65. package/template/drizzle/pg/meta/0023_snapshot.json +2132 -0
  66. package/template/drizzle/pg/meta/0024_snapshot.json +2151 -0
  67. package/template/drizzle/pg/meta/0025_snapshot.json +2169 -0
  68. package/template/drizzle/pg/meta/0026_snapshot.json +2294 -0
  69. package/template/drizzle/pg/meta/0027_snapshot.json +2330 -0
  70. package/template/drizzle/pg/meta/_journal.json +202 -0
  71. package/template/drizzle/sqlite/0000_initial.sql +176 -0
  72. package/template/drizzle/sqlite/0001_easy_sebastian_shaw.sql +1 -0
  73. package/template/drizzle/sqlite/0002_past_king_cobra.sql +1 -0
  74. package/template/drizzle/sqlite/0003_organic_masked_marvel.sql +1 -0
  75. package/template/drizzle/sqlite/0004_panoramic_inhumans.sql +15 -0
  76. package/template/drizzle/sqlite/0005_small_sunset_bain.sql +19 -0
  77. package/template/drizzle/sqlite/0006_narrow_medusa.sql +2 -0
  78. package/template/drizzle/sqlite/0007_gray_grandmaster.sql +10 -0
  79. package/template/drizzle/sqlite/0008_chief_toxin.sql +1 -0
  80. package/template/drizzle/sqlite/0009_vengeful_tag.sql +1 -0
  81. package/template/drizzle/sqlite/0010_kind_klaw.sql +7 -0
  82. package/template/drizzle/sqlite/0011_overrated_meltdown.sql +3 -0
  83. package/template/drizzle/sqlite/0012_robust_next_avengers.sql +2 -0
  84. package/template/drizzle/sqlite/0013_melodic_kitty_pryde.sql +18 -0
  85. package/template/drizzle/sqlite/0014_stormy_cyclops.sql +12 -0
  86. package/template/drizzle/sqlite/0015_parallel_mongu.sql +11 -0
  87. package/template/drizzle/sqlite/0016_grey_quicksilver.sql +2 -0
  88. package/template/drizzle/sqlite/0017_daily_psylocke.sql +15 -0
  89. package/template/drizzle/sqlite/0018_whole_redwing.sql +4 -0
  90. package/template/drizzle/sqlite/0019_spotty_mandroid.sql +1 -0
  91. package/template/drizzle/sqlite/0020_wild_wendell_rand.sql +19 -0
  92. package/template/drizzle/sqlite/0021_calm_lockheed.sql +1 -0
  93. package/template/drizzle/sqlite/0022_lonely_emma_frost.sql +5 -0
  94. package/template/drizzle/sqlite/0023_elite_tony_stark.sql +1 -0
  95. package/template/drizzle/sqlite/0024_little_lily_hollister.sql +1 -0
  96. package/template/drizzle/sqlite/0025_tough_shotgun.sql +3 -0
  97. package/template/drizzle/sqlite/0026_faithful_mephistopheles.sql +16 -0
  98. package/template/drizzle/sqlite/0027_rapid_arclight.sql +2 -0
  99. package/template/drizzle/sqlite/meta/0000_snapshot.json +1237 -0
  100. package/template/drizzle/sqlite/meta/0001_snapshot.json +1245 -0
  101. package/template/drizzle/sqlite/meta/0002_snapshot.json +1252 -0
  102. package/template/drizzle/sqlite/meta/0003_snapshot.json +1259 -0
  103. package/template/drizzle/sqlite/meta/0004_snapshot.json +1369 -0
  104. package/template/drizzle/sqlite/meta/0005_snapshot.json +1369 -0
  105. package/template/drizzle/sqlite/meta/0006_snapshot.json +1384 -0
  106. package/template/drizzle/sqlite/meta/0007_snapshot.json +1459 -0
  107. package/template/drizzle/sqlite/meta/0008_snapshot.json +1479 -0
  108. package/template/drizzle/sqlite/meta/0009_snapshot.json +1486 -0
  109. package/template/drizzle/sqlite/meta/0010_snapshot.json +1533 -0
  110. package/template/drizzle/sqlite/meta/0011_snapshot.json +1554 -0
  111. package/template/drizzle/sqlite/meta/0012_snapshot.json +1568 -0
  112. package/template/drizzle/sqlite/meta/0013_snapshot.json +1687 -0
  113. package/template/drizzle/sqlite/meta/0014_snapshot.json +1769 -0
  114. package/template/drizzle/sqlite/meta/0015_snapshot.json +1852 -0
  115. package/template/drizzle/sqlite/meta/0016_snapshot.json +1867 -0
  116. package/template/drizzle/sqlite/meta/0017_snapshot.json +1973 -0
  117. package/template/drizzle/sqlite/meta/0018_snapshot.json +1944 -0
  118. package/template/drizzle/sqlite/meta/0019_snapshot.json +1951 -0
  119. package/template/drizzle/sqlite/meta/0020_snapshot.json +2077 -0
  120. package/template/drizzle/sqlite/meta/0021_snapshot.json +2084 -0
  121. package/template/drizzle/sqlite/meta/0022_snapshot.json +2098 -0
  122. package/template/drizzle/sqlite/meta/0023_snapshot.json +2105 -0
  123. package/template/drizzle/sqlite/meta/0024_snapshot.json +2125 -0
  124. package/template/drizzle/sqlite/meta/0025_snapshot.json +2146 -0
  125. package/template/drizzle/sqlite/meta/0026_snapshot.json +2265 -0
  126. package/template/drizzle/sqlite/meta/0027_snapshot.json +2280 -0
  127. package/template/drizzle/sqlite/meta/_journal.json +202 -0
  128. package/template/drizzle.pg.config.ts +8 -0
  129. package/template/drizzle.sqlite.config.ts +8 -0
  130. package/template/eslint.config.mjs +22 -0
  131. package/template/next.config.ts +153 -0
  132. package/template/package.json +102 -0
  133. package/template/pet-adopt.blocks.ts +9 -0
  134. package/template/pet-adopt.config.ts +17 -0
  135. package/template/pnpm-workspace.yaml +19 -0
  136. package/template/postcss.config.mjs +5 -0
  137. package/template/scripts/check-routes.ts +405 -0
  138. package/template/scripts/check-schemas.ts +58 -0
  139. package/template/scripts/migrate-all.ts +25 -0
  140. package/template/scripts/migrate-on-build.ts +71 -0
  141. package/template/scripts/migrate.ts +20 -0
  142. package/template/scripts/plugin-generate.ts +92 -0
  143. package/template/scripts/reset-password.ts +45 -0
  144. package/template/scripts/reset-two-factor.ts +53 -0
  145. package/template/scripts/seed.ts +79 -0
  146. package/template/scripts/setup-env.ts +91 -0
  147. package/template/scripts/storage-check.ts +53 -0
  148. package/template/src/app/(admin)/admin/account/AccountForms.tsx +194 -0
  149. package/template/src/app/(admin)/admin/account/page.tsx +59 -0
  150. package/template/src/app/(admin)/admin/activity/page.tsx +76 -0
  151. package/template/src/app/(admin)/admin/authentication/archived/page.tsx +24 -0
  152. package/template/src/app/(admin)/admin/authentication/layout.tsx +20 -0
  153. package/template/src/app/(admin)/admin/authentication/page.tsx +36 -0
  154. package/template/src/app/(admin)/admin/authentication/providers/page.tsx +33 -0
  155. package/template/src/app/(admin)/admin/email/layout.tsx +21 -0
  156. package/template/src/app/(admin)/admin/email/page.tsx +43 -0
  157. package/template/src/app/(admin)/admin/email/templates/page.tsx +38 -0
  158. package/template/src/app/(admin)/admin/error.tsx +36 -0
  159. package/template/src/app/(admin)/admin/layout.tsx +26 -0
  160. package/template/src/app/(admin)/admin/loading.tsx +9 -0
  161. package/template/src/app/(admin)/admin/media/[id]/page.tsx +97 -0
  162. package/template/src/app/(admin)/admin/media/page.tsx +34 -0
  163. package/template/src/app/(admin)/admin/media/search-params.ts +16 -0
  164. package/template/src/app/(admin)/admin/page.tsx +79 -0
  165. package/template/src/app/(admin)/admin/pages/PageForm.tsx +604 -0
  166. package/template/src/app/(admin)/admin/pages/[id]/page.tsx +51 -0
  167. package/template/src/app/(admin)/admin/pages/new/page.tsx +19 -0
  168. package/template/src/app/(admin)/admin/pages/page.tsx +49 -0
  169. package/template/src/app/(admin)/admin/pets/PetForm.tsx +437 -0
  170. package/template/src/app/(admin)/admin/pets/[id]/page.tsx +41 -0
  171. package/template/src/app/(admin)/admin/pets/new/page.tsx +26 -0
  172. package/template/src/app/(admin)/admin/pets/page.tsx +70 -0
  173. package/template/src/app/(admin)/admin/pets/search-params.ts +16 -0
  174. package/template/src/app/(admin)/admin/plugins/[plugin]/[[...path]]/page.tsx +73 -0
  175. package/template/src/app/(admin)/admin/plugins/page.tsx +66 -0
  176. package/template/src/app/(admin)/admin/settings/SettingsForm.tsx +644 -0
  177. package/template/src/app/(admin)/admin/settings/email/page.tsx +9 -0
  178. package/template/src/app/(admin)/admin/settings/page.tsx +40 -0
  179. package/template/src/app/(admin)/admin/settings/templates/page.tsx +9 -0
  180. package/template/src/app/(admin)/admin/theme/[id]/page.tsx +28 -0
  181. package/template/src/app/(admin)/admin/theme/page.tsx +30 -0
  182. package/template/src/app/(admin)/admin/users/page.tsx +33 -0
  183. package/template/src/app/(admin)/layout.tsx +75 -0
  184. package/template/src/app/(admin)/providers.tsx +42 -0
  185. package/template/src/app/(auth)/admin/confirm-email/page.tsx +40 -0
  186. package/template/src/app/(auth)/admin/invite/page.tsx +38 -0
  187. package/template/src/app/(auth)/admin/login/DemoSignIn.tsx +69 -0
  188. package/template/src/app/(auth)/admin/login/page.tsx +83 -0
  189. package/template/src/app/(auth)/admin/reset-password/page.tsx +73 -0
  190. package/template/src/app/(auth)/error.tsx +9 -0
  191. package/template/src/app/(auth)/layout.tsx +71 -0
  192. package/template/src/app/(editor)/EditorToast.tsx +43 -0
  193. package/template/src/app/(editor)/edit/[id]/PageEditor.tsx +586 -0
  194. package/template/src/app/(editor)/edit/[id]/actions.ts +139 -0
  195. package/template/src/app/(editor)/edit/[id]/page.tsx +76 -0
  196. package/template/src/app/(editor)/edit/[id]/preview/page.tsx +81 -0
  197. package/template/src/app/(editor)/edit/email/[id]/EmailEditor.tsx +236 -0
  198. package/template/src/app/(editor)/edit/email/[id]/page.tsx +64 -0
  199. package/template/src/app/(editor)/edit/theme-preview/page.tsx +94 -0
  200. package/template/src/app/(editor)/editor.css +223 -0
  201. package/template/src/app/(editor)/error.tsx +32 -0
  202. package/template/src/app/(editor)/layout.tsx +67 -0
  203. package/template/src/app/(frontend)/[slug]/page.tsx +53 -0
  204. package/template/src/app/(frontend)/fonts.ts +8 -0
  205. package/template/src/app/(frontend)/layout.tsx +107 -0
  206. package/template/src/app/(frontend)/not-found.tsx +16 -0
  207. package/template/src/app/(frontend)/page.tsx +42 -0
  208. package/template/src/app/(frontend)/pets/[slug]/page.tsx +92 -0
  209. package/template/src/app/(frontend)/pets/page.tsx +42 -0
  210. package/template/src/app/(frontend)/styles.css +537 -0
  211. package/template/src/app/(setup)/error.tsx +9 -0
  212. package/template/src/app/(setup)/layout.tsx +41 -0
  213. package/template/src/app/(setup)/setup/page.tsx +105 -0
  214. package/template/src/app/(setup)/setup/storage-check.ts +43 -0
  215. package/template/src/app/api/auth/[...all]/route.ts +144 -0
  216. package/template/src/app/health/route.ts +9 -0
  217. package/template/src/app/media/[...path]/route.ts +45 -0
  218. package/template/src/app/media/email/[name]/route.ts +60 -0
  219. package/template/src/app/robots.ts +19 -0
  220. package/template/src/app/sitemap.ts +24 -0
  221. package/template/src/components/admin/AdminNav.tsx +153 -0
  222. package/template/src/components/admin/AdminShell.tsx +107 -0
  223. package/template/src/components/admin/DemoNotice.tsx +31 -0
  224. package/template/src/components/admin/EmailConfirmBanner.tsx +44 -0
  225. package/template/src/components/admin/EmptyState.tsx +10 -0
  226. package/template/src/components/admin/ErrorSummary.tsx +72 -0
  227. package/template/src/components/admin/MediaDetails.tsx +218 -0
  228. package/template/src/components/admin/MediaGrid.tsx +307 -0
  229. package/template/src/components/admin/MediaLibrary.tsx +103 -0
  230. package/template/src/components/admin/MediaPager.tsx +66 -0
  231. package/template/src/components/admin/PageHeader.tsx +22 -0
  232. package/template/src/components/admin/PhoneInput.tsx +128 -0
  233. package/template/src/components/admin/PluginWidgetBoundary.tsx +38 -0
  234. package/template/src/components/admin/PluginWidgets.tsx +51 -0
  235. package/template/src/components/admin/RemountOnNavigate.tsx +37 -0
  236. package/template/src/components/admin/StatusBadge.tsx +16 -0
  237. package/template/src/components/admin/UploadPhotosDialog.tsx +387 -0
  238. package/template/src/components/admin/UserAvatar.tsx +18 -0
  239. package/template/src/components/admin/UserMenu.tsx +118 -0
  240. package/template/src/components/admin/ViewSiteLink.tsx +24 -0
  241. package/template/src/components/admin/account/ConnectedProviders.tsx +91 -0
  242. package/template/src/components/admin/account/DeleteAccountCard.tsx +136 -0
  243. package/template/src/components/admin/account/EmailCard.tsx +137 -0
  244. package/template/src/components/admin/account/ProfilePicture.tsx +159 -0
  245. package/template/src/components/admin/activity/ActivityFilters.tsx +146 -0
  246. package/template/src/components/admin/activity/ActivityLog.tsx +159 -0
  247. package/template/src/components/admin/activity/RecentActivity.tsx +52 -0
  248. package/template/src/components/admin/demo-mode.tsx +17 -0
  249. package/template/src/components/admin/nav-items.ts +47 -0
  250. package/template/src/components/admin/pages/PageDetails.tsx +198 -0
  251. package/template/src/components/admin/pages/PageVersions.tsx +296 -0
  252. package/template/src/components/admin/pages/PagesTable.tsx +467 -0
  253. package/template/src/components/admin/pets/FilterBar.tsx +154 -0
  254. package/template/src/components/admin/pets/PetCard.tsx +170 -0
  255. package/template/src/components/admin/pets/PetList.tsx +112 -0
  256. package/template/src/components/admin/pets/PetListSkeleton.tsx +84 -0
  257. package/template/src/components/admin/pets/PetPagination.tsx +91 -0
  258. package/template/src/components/admin/pets/form/AgeFields.tsx +132 -0
  259. package/template/src/components/admin/pets/form/LocationFields.tsx +231 -0
  260. package/template/src/components/admin/pets/form/MediaPickerDialog.tsx +359 -0
  261. package/template/src/components/admin/pets/form/PhotosField.tsx +176 -0
  262. package/template/src/components/admin/pets/form/RichTextField.tsx +438 -0
  263. package/template/src/components/admin/pets/form/SeoImageField.tsx +87 -0
  264. package/template/src/components/admin/pets/form/SeoPreview.tsx +142 -0
  265. package/template/src/components/admin/pets/form/fields.tsx +434 -0
  266. package/template/src/components/admin/pets/form/rich-text-extensions.ts +45 -0
  267. package/template/src/components/admin/pets/timeline/PetTimeline.tsx +297 -0
  268. package/template/src/components/admin/pets/timeline/TimelineEntryForm.tsx +289 -0
  269. package/template/src/components/admin/pets/timeline/TimelinePhotosField.tsx +173 -0
  270. package/template/src/components/admin/plugins/PluginNotReady.tsx +28 -0
  271. package/template/src/components/admin/plugins/PluginOverview.tsx +121 -0
  272. package/template/src/components/admin/plugins/SendTestEmail.tsx +70 -0
  273. package/template/src/components/admin/settings/AuthProviders.tsx +373 -0
  274. package/template/src/components/admin/settings/AuthenticationNav.tsx +42 -0
  275. package/template/src/components/admin/settings/EmailNav.tsx +40 -0
  276. package/template/src/components/admin/settings/EmailSettingsForm.tsx +325 -0
  277. package/template/src/components/admin/settings/EmailTemplates.tsx +551 -0
  278. package/template/src/components/admin/settings/RegionFields.tsx +203 -0
  279. package/template/src/components/admin/site-time.tsx +26 -0
  280. package/template/src/components/admin/theme/ThemeEditor.tsx +467 -0
  281. package/template/src/components/admin/theme/ThemeLibrary.tsx +339 -0
  282. package/template/src/components/admin/theme/ThemeSwatches.tsx +30 -0
  283. package/template/src/components/admin/theme/theme-utils.ts +32 -0
  284. package/template/src/components/admin/two-factor/BackupCodeList.tsx +54 -0
  285. package/template/src/components/admin/two-factor/TwoFactorCard.tsx +237 -0
  286. package/template/src/components/admin/two-factor/TwoFactorRequired.tsx +52 -0
  287. package/template/src/components/admin/two-factor/TwoFactorSetup.tsx +180 -0
  288. package/template/src/components/admin/use-unsaved-changes.tsx +101 -0
  289. package/template/src/components/admin/users/ArchivedAccounts.tsx +159 -0
  290. package/template/src/components/admin/users/InviteDialogs.tsx +131 -0
  291. package/template/src/components/admin/users/TwoFactorRoles.tsx +80 -0
  292. package/template/src/components/admin/users/UserDialogs.tsx +681 -0
  293. package/template/src/components/admin/users/UsersTable.tsx +374 -0
  294. package/template/src/components/admin/view-only.tsx +43 -0
  295. package/template/src/components/auth/AcceptInviteForm.tsx +123 -0
  296. package/template/src/components/auth/AuthNav.tsx +80 -0
  297. package/template/src/components/auth/ConfirmEmailForm.tsx +73 -0
  298. package/template/src/components/auth/LoginForm.tsx +250 -0
  299. package/template/src/components/auth/PageError.tsx +37 -0
  300. package/template/src/components/auth/ProviderSignIn.tsx +53 -0
  301. package/template/src/components/auth/ResetPasswordForm.tsx +267 -0
  302. package/template/src/components/demo/DemoBanner.tsx +38 -0
  303. package/template/src/components/demo/SiteDemoBanner.tsx +22 -0
  304. package/template/src/components/demo/wording.ts +21 -0
  305. package/template/src/components/setup/SetupAccountForm.tsx +93 -0
  306. package/template/src/components/setup/SetupDone.tsx +95 -0
  307. package/template/src/components/setup/SetupNav.tsx +49 -0
  308. package/template/src/components/setup/SetupSampleContent.tsx +67 -0
  309. package/template/src/components/setup/SetupSiteForm.tsx +104 -0
  310. package/template/src/components/setup/SetupThemePicker.tsx +73 -0
  311. package/template/src/components/setup/SkipSetup.tsx +35 -0
  312. package/template/src/components/site/BuilderContent.tsx +46 -0
  313. package/template/src/components/site/CopyButton.tsx +28 -0
  314. package/template/src/components/site/ImageCarousel.tsx +52 -0
  315. package/template/src/components/site/PetCard.tsx +32 -0
  316. package/template/src/components/site/PetCatalog.tsx +106 -0
  317. package/template/src/components/site/PetGallery.tsx +75 -0
  318. package/template/src/components/site/PetTimeline.tsx +82 -0
  319. package/template/src/components/site/RemountOnNavigate.tsx +13 -0
  320. package/template/src/components/site/RichText.tsx +56 -0
  321. package/template/src/components/site/SmartLink.tsx +37 -0
  322. package/template/src/components/site/SocialIcons.tsx +26 -0
  323. package/template/src/components/site/ThemePreviewBridge.tsx +29 -0
  324. package/template/src/components/site/ThemeStyle.tsx +22 -0
  325. package/template/src/components/site/ThemeToggle.tsx +36 -0
  326. package/template/src/components/site/WhatsAppButton.tsx +27 -0
  327. package/template/src/components/site/timeline-format.ts +20 -0
  328. package/template/src/db/client.ts +702 -0
  329. package/template/src/db/compare-tables.ts +41 -0
  330. package/template/src/db/migrate.ts +28 -0
  331. package/template/src/db/plugin-migrations.ts +167 -0
  332. package/template/src/db/schema/pg.ts +484 -0
  333. package/template/src/db/schema/sqlite.ts +492 -0
  334. package/template/src/instrumentation.ts +110 -0
  335. package/template/src/lib/activity.ts +29 -0
  336. package/template/src/lib/admin/call-action.ts +19 -0
  337. package/template/src/lib/admin/initials.ts +9 -0
  338. package/template/src/lib/admin/media-cache.ts +16 -0
  339. package/template/src/lib/admin/media-page.ts +3 -0
  340. package/template/src/lib/admin/pet-form.ts +242 -0
  341. package/template/src/lib/admin/pets-cache.ts +22 -0
  342. package/template/src/lib/admin/unwrap-client.ts +11 -0
  343. package/template/src/lib/admin/unwrap.ts +38 -0
  344. package/template/src/lib/admin/use-media-list.ts +41 -0
  345. package/template/src/lib/admin/use-pet-list.ts +58 -0
  346. package/template/src/lib/age.ts +117 -0
  347. package/template/src/lib/auth-provider-errors.ts +38 -0
  348. package/template/src/lib/cache.ts +69 -0
  349. package/template/src/lib/color-mode.ts +48 -0
  350. package/template/src/lib/demo.ts +78 -0
  351. package/template/src/lib/email-address.ts +9 -0
  352. package/template/src/lib/email-template.ts +691 -0
  353. package/template/src/lib/links.ts +78 -0
  354. package/template/src/lib/mail-error.ts +38 -0
  355. package/template/src/lib/media-name.ts +31 -0
  356. package/template/src/lib/options.ts +134 -0
  357. package/template/src/lib/pagination.ts +28 -0
  358. package/template/src/lib/pet-placeholders.ts +34 -0
  359. package/template/src/lib/pet-seo.ts +40 -0
  360. package/template/src/lib/pet-timeline.ts +62 -0
  361. package/template/src/lib/phone.ts +129 -0
  362. package/template/src/lib/places.ts +84 -0
  363. package/template/src/lib/queries.ts +549 -0
  364. package/template/src/lib/revalidate.ts +32 -0
  365. package/template/src/lib/rich-text.ts +215 -0
  366. package/template/src/lib/seo.ts +121 -0
  367. package/template/src/lib/slugify.ts +11 -0
  368. package/template/src/lib/theme.ts +546 -0
  369. package/template/src/lib/utils.ts +2 -0
  370. package/template/src/lib/whatsapp.ts +29 -0
  371. package/template/src/lib/zod-schema/auth.ts +56 -0
  372. package/template/src/lib/zod-schema/page.ts +57 -0
  373. package/template/src/lib/zod-schema/pet-timeline.ts +118 -0
  374. package/template/src/lib/zod-schema/pet.ts +172 -0
  375. package/template/src/lib/zod-schema/settings.ts +162 -0
  376. package/template/src/plugins/host.ts +117 -0
  377. package/template/src/plugins/icon.ts +89 -0
  378. package/template/src/plugins/registry.ts +369 -0
  379. package/template/src/plugins/storage-rules.ts +87 -0
  380. package/template/src/plugins/storage.ts +184 -0
  381. package/template/src/puck/actions.ts +46 -0
  382. package/template/src/puck/config.tsx +1693 -0
  383. package/template/src/puck/data.ts +196 -0
  384. package/template/src/puck/demo-mode.tsx +20 -0
  385. package/template/src/puck/email-config.tsx +267 -0
  386. package/template/src/puck/icons.tsx +76 -0
  387. package/template/src/puck/media-picker.tsx +273 -0
  388. package/template/src/puck/padding.tsx +71 -0
  389. package/template/src/puck/pet-page-config.tsx +511 -0
  390. package/template/src/puck/pet-picker.tsx +40 -0
  391. package/template/src/puck/plugin-block-data.ts +91 -0
  392. package/template/src/puck/plugin-blocks.tsx +235 -0
  393. package/template/src/puck/plugin-choice-field.tsx +87 -0
  394. package/template/src/puck/sanitize.ts +107 -0
  395. package/template/src/puck/server.ts +36 -0
  396. package/template/src/puck/types.ts +41 -0
  397. package/template/src/server/actions/activity.ts +48 -0
  398. package/template/src/server/actions/auth-providers.ts +171 -0
  399. package/template/src/server/actions/auth.ts +217 -0
  400. package/template/src/server/actions/demo.ts +30 -0
  401. package/template/src/server/actions/email-change.ts +80 -0
  402. package/template/src/server/actions/email-templates.ts +144 -0
  403. package/template/src/server/actions/email.ts +70 -0
  404. package/template/src/server/actions/media.ts +127 -0
  405. package/template/src/server/actions/pages.ts +159 -0
  406. package/template/src/server/actions/password-reset.ts +80 -0
  407. package/template/src/server/actions/pet-timeline.ts +75 -0
  408. package/template/src/server/actions/pets.ts +74 -0
  409. package/template/src/server/actions/places.ts +36 -0
  410. package/template/src/server/actions/settings.ts +29 -0
  411. package/template/src/server/actions/setup.ts +72 -0
  412. package/template/src/server/actions/themes.ts +80 -0
  413. package/template/src/server/actions/two-factor.ts +306 -0
  414. package/template/src/server/actions/users.ts +200 -0
  415. package/template/src/server/activity.ts +409 -0
  416. package/template/src/server/auth-errors.ts +17 -0
  417. package/template/src/server/auth-providers.ts +359 -0
  418. package/template/src/server/auth.ts +266 -0
  419. package/template/src/server/avatars.ts +263 -0
  420. package/template/src/server/demo-site.ts +169 -0
  421. package/template/src/server/email-change.ts +278 -0
  422. package/template/src/server/email-templates.ts +350 -0
  423. package/template/src/server/email.ts +442 -0
  424. package/template/src/server/invites.ts +143 -0
  425. package/template/src/server/media-url.ts +20 -0
  426. package/template/src/server/media.ts +236 -0
  427. package/template/src/server/pages.ts +812 -0
  428. package/template/src/server/password-reset.ts +158 -0
  429. package/template/src/server/pending-links.ts +46 -0
  430. package/template/src/server/pet-timeline.ts +181 -0
  431. package/template/src/server/pets.ts +555 -0
  432. package/template/src/server/places.ts +113 -0
  433. package/template/src/server/privacy.ts +21 -0
  434. package/template/src/server/provider-endpoints.ts +94 -0
  435. package/template/src/server/provider-guard.ts +157 -0
  436. package/template/src/server/result.ts +280 -0
  437. package/template/src/server/sample-content.ts +368 -0
  438. package/template/src/server/search-text.ts +43 -0
  439. package/template/src/server/secret-box.ts +38 -0
  440. package/template/src/server/session.ts +154 -0
  441. package/template/src/server/settings.ts +361 -0
  442. package/template/src/server/setup.ts +110 -0
  443. package/template/src/server/sitemap.ts +88 -0
  444. package/template/src/server/storage.ts +267 -0
  445. package/template/src/server/strip-metadata.ts +357 -0
  446. package/template/src/server/themes.ts +195 -0
  447. package/template/src/server/throttle.ts +258 -0
  448. package/template/src/server/two-factor-codes.ts +32 -0
  449. package/template/src/server/two-factor.ts +158 -0
  450. package/template/src/server/types.ts +198 -0
  451. package/template/src/server/uploads.ts +137 -0
  452. package/template/src/server/users.ts +500 -0
  453. package/template/tsconfig.json +44 -0
  454. package/template/ui/components.json +25 -0
  455. package/template/ui/package.json +12 -0
  456. package/template/ui/src/components/alert-dialog.tsx +187 -0
  457. package/template/ui/src/components/avatar.tsx +108 -0
  458. package/template/ui/src/components/badge.tsx +51 -0
  459. package/template/ui/src/components/button.tsx +57 -0
  460. package/template/ui/src/components/card.tsx +102 -0
  461. package/template/ui/src/components/carousel.tsx +245 -0
  462. package/template/ui/src/components/checkbox.tsx +27 -0
  463. package/template/ui/src/components/combobox.tsx +297 -0
  464. package/template/ui/src/components/dialog.tsx +159 -0
  465. package/template/ui/src/components/dropdown-menu.tsx +265 -0
  466. package/template/ui/src/components/field.tsx +238 -0
  467. package/template/ui/src/components/input-group.tsx +158 -0
  468. package/template/ui/src/components/input.tsx +19 -0
  469. package/template/ui/src/components/label.tsx +19 -0
  470. package/template/ui/src/components/pagination.tsx +127 -0
  471. package/template/ui/src/components/popover.tsx +89 -0
  472. package/template/ui/src/components/radio-group.tsx +37 -0
  473. package/template/ui/src/components/select.tsx +200 -0
  474. package/template/ui/src/components/separator.tsx +24 -0
  475. package/template/ui/src/components/sheet.tsx +138 -0
  476. package/template/ui/src/components/sidebar.tsx +723 -0
  477. package/template/ui/src/components/skeleton.tsx +13 -0
  478. package/template/ui/src/components/switch.tsx +31 -0
  479. package/template/ui/src/components/table.tsx +115 -0
  480. package/template/ui/src/components/tabs.tsx +81 -0
  481. package/template/ui/src/components/textarea.tsx +17 -0
  482. package/template/ui/src/components/toggle.tsx +44 -0
  483. package/template/ui/src/components/tooltip.tsx +65 -0
  484. package/template/ui/src/hooks/use-mobile.ts +21 -0
  485. package/template/ui/src/lib/utils.ts +2 -0
  486. 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
+ }