create-m5kdev 0.25.3 → 0.26.1
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/dist/src/create.cjs +18 -1
- package/dist/src/create.cjs.map +1 -1
- package/dist/src/fs.cjs +65 -5
- package/dist/src/fs.cjs.map +1 -1
- package/dist/src/fs.d.cts +13 -2
- package/dist/src/index.cjs +0 -0
- package/dist/src/paths.cjs +2 -2
- package/dist/src/prompts.cjs +22 -0
- package/dist/src/prompts.cjs.map +1 -1
- package/dist/src/runCli.cjs +13 -2
- package/dist/src/runCli.cjs.map +1 -1
- package/dist/src/types.d.cts +9 -1
- package/package.json +8 -6
- package/templates/minimal-app/.cursor/rules/frontend-data-guide.mdc +46 -3
- package/templates/minimal-app/.cursor/rules/module-db-guide.mdc +15 -1
- package/templates/minimal-app/.cursor/rules/module-dto-guide.mdc +60 -0
- package/templates/minimal-app/.cursor/rules/module-repository-guide.mdc +98 -193
- package/templates/minimal-app/.cursor/rules/module-schema-guide.mdc +53 -173
- package/templates/minimal-app/.cursor/rules/module-service-guide.mdc +133 -240
- package/templates/minimal-app/.cursor/rules/module-trpc-guide.mdc +71 -113
- package/templates/minimal-app/README.md.tpl +3 -3
- package/templates/minimal-app/apps/.gitignore.tpl +13 -0
- package/templates/minimal-app/apps/e2e/package.json.tpl +23 -0
- package/templates/minimal-app/apps/e2e/playwright.config.ts.tpl +39 -0
- package/templates/minimal-app/apps/e2e/playwright.expo.config.ts.tpl +38 -0
- package/templates/minimal-app/apps/e2e/servers.ts.tpl +100 -0
- package/templates/minimal-app/apps/e2e/tests/email.spec.ts.tpl +47 -0
- package/templates/minimal-app/apps/e2e/tests/expo-helpers.ts.tpl +73 -0
- package/templates/minimal-app/apps/e2e/tests/expo-standard.spec.ts.tpl +517 -0
- package/templates/minimal-app/apps/e2e/tests/expo-waitlist.spec.ts.tpl +94 -0
- package/templates/minimal-app/apps/e2e/tests/helpers.ts.tpl +289 -0
- package/templates/minimal-app/apps/e2e/tests/standard.spec.ts.tpl +516 -0
- package/templates/minimal-app/apps/e2e/tests/waitlist.spec.ts.tpl +107 -0
- package/templates/minimal-app/apps/e2e/tsconfig.json.tpl +10 -0
- package/templates/minimal-app/apps/email/package.json.tpl +34 -34
- package/templates/minimal-app/apps/email/src/emails/accountDeletionEmail.tsx.tpl +35 -34
- package/templates/minimal-app/apps/email/src/emails/organizationInviteEmail.tsx.tpl +34 -33
- package/templates/minimal-app/apps/email/src/emails/passwordResetEmail.tsx.tpl +35 -34
- package/templates/minimal-app/apps/email/src/emails/verificationEmail.tsx.tpl +37 -36
- package/templates/minimal-app/apps/email/src/emails/waitlistEmails.tsx.tpl +87 -0
- package/templates/minimal-app/apps/email/src/index.ts.tpl +72 -32
- package/templates/minimal-app/apps/email/src/resources.ts.tpl +65 -36
- package/templates/minimal-app/apps/email/tsconfig.json.tpl +16 -11
- package/templates/minimal-app/apps/expo/.gitignore.tpl +44 -0
- package/templates/minimal-app/apps/expo/.prettierignore +13 -0
- package/templates/minimal-app/apps/expo/.prettierrc.json.tpl +9 -0
- package/templates/minimal-app/apps/expo/CHANGELOG.md.tpl +156 -0
- package/templates/minimal-app/apps/expo/README.md.tpl +44 -0
- package/templates/minimal-app/apps/expo/app.json.tpl +36 -0
- package/templates/minimal-app/apps/expo/assets/images/adaptive-icon.png +0 -0
- package/templates/minimal-app/apps/expo/assets/images/favicon.png +0 -0
- package/templates/minimal-app/apps/expo/assets/images/icon.png +0 -0
- package/templates/minimal-app/apps/expo/assets/images/splash-icon.png +0 -0
- package/templates/minimal-app/apps/expo/eslint.config.js.tpl +8 -0
- package/templates/minimal-app/apps/expo/expo-env.d.ts.tpl +3 -0
- package/templates/minimal-app/apps/expo/metro.config.js.tpl +16 -0
- package/templates/minimal-app/apps/expo/package.json.tpl +59 -0
- package/templates/minimal-app/apps/expo/src/app/_layout.tsx.tpl +31 -0
- package/templates/minimal-app/apps/expo/src/app/claim-account.tsx.tpl +151 -0
- package/templates/minimal-app/apps/expo/src/app/forgot-password.tsx.tpl +53 -0
- package/templates/minimal-app/apps/expo/src/app/index.tsx.tpl +8 -0
- package/templates/minimal-app/apps/expo/src/app/login.tsx.tpl +71 -0
- package/templates/minimal-app/apps/expo/src/app/logout.tsx.tpl +19 -0
- package/templates/minimal-app/apps/expo/src/app/organization/accept-invitation.tsx.tpl +85 -0
- package/templates/minimal-app/apps/expo/src/app/posts.tsx.tpl +40 -0
- package/templates/minimal-app/apps/expo/src/app/reset-password.tsx.tpl +75 -0
- package/templates/minimal-app/apps/expo/src/app/signup.tsx.tpl +193 -0
- package/templates/minimal-app/apps/expo/src/components/AuthScaffold.tsx.tpl +34 -0
- package/templates/minimal-app/apps/expo/src/components/FormTextField.tsx.tpl +37 -0
- package/templates/minimal-app/apps/expo/src/components/LoadingScreen.tsx.tpl +10 -0
- package/templates/minimal-app/apps/expo/src/components/StatusText.tsx.tpl +22 -0
- package/templates/minimal-app/apps/expo/src/config.ts.tpl +9 -0
- package/templates/minimal-app/apps/expo/src/global.css.tpl +11 -0
- package/templates/minimal-app/apps/expo/src/lib/trpc.ts.tpl +20 -0
- package/templates/minimal-app/apps/expo/tsconfig.json.tpl +11 -0
- package/templates/minimal-app/apps/expo/uniwind-env.d.ts.tpl +1 -0
- package/templates/minimal-app/apps/expo/uniwind-types.d.ts.tpl +10 -0
- package/templates/minimal-app/apps/server/AGENTS.md.tpl +39 -39
- package/templates/minimal-app/apps/server/drizzle/0000_wealthy_absorbing_man.sql +268 -0
- package/templates/minimal-app/apps/server/drizzle/db.ts.tpl +26 -0
- package/templates/minimal-app/apps/server/drizzle/meta/0000_snapshot.json.tpl +1890 -0
- package/templates/minimal-app/apps/server/drizzle/meta/_journal.json.tpl +13 -0
- package/templates/minimal-app/apps/server/drizzle/reset.ts.tpl +33 -0
- package/templates/minimal-app/apps/server/drizzle/seed.e2e.ts.tpl +244 -0
- package/templates/minimal-app/apps/server/drizzle/seed.ts.tpl +181 -180
- package/templates/minimal-app/apps/server/drizzle/sync.ts.tpl +14 -21
- package/templates/minimal-app/apps/server/drizzle.config.ts.tpl +33 -35
- package/templates/minimal-app/apps/server/package.json.tpl +56 -52
- package/templates/minimal-app/apps/server/src/app.ts.tpl +142 -126
- package/templates/minimal-app/apps/server/src/index.ts.tpl +58 -58
- package/templates/minimal-app/apps/server/src/lib/auth.ts.tpl +12 -12
- package/templates/minimal-app/apps/server/src/modules/posts/posts.db.ts.tpl +25 -25
- package/templates/minimal-app/apps/server/src/modules/posts/posts.dto.ts.tpl +23 -0
- package/templates/minimal-app/apps/server/src/modules/posts/posts.grants.ts.tpl +30 -40
- package/templates/minimal-app/apps/server/src/modules/posts/posts.module.ts.tpl +54 -54
- package/templates/minimal-app/apps/server/src/modules/posts/posts.repository.ts.tpl +67 -112
- package/templates/minimal-app/apps/server/src/modules/posts/posts.service.ts.tpl +104 -170
- package/templates/minimal-app/apps/server/src/modules/posts/posts.trpc.ts.tpl +37 -48
- package/templates/minimal-app/apps/server/src/modules/posts/posts.utils.ts.tpl +19 -0
- package/templates/minimal-app/apps/server/src/modules/test-harness/test-harness.module.ts.tpl +279 -0
- package/templates/minimal-app/apps/server/src/schema.ts.tpl +20 -0
- package/templates/minimal-app/apps/server/src/types.ts.tpl +1 -1
- package/templates/minimal-app/apps/server/tsconfig.json.tpl +20 -14
- package/templates/minimal-app/apps/server/tsup.config.ts.tpl +9 -9
- package/templates/minimal-app/apps/shared/package.json.tpl +24 -24
- package/templates/minimal-app/apps/shared/src/modules/app/app.constants.ts.tpl +28 -2
- package/templates/minimal-app/apps/shared/src/modules/notification/notification.schema.ts.tpl +3 -3
- package/templates/minimal-app/apps/shared/src/modules/posts/posts.constants.ts.tpl +5 -5
- package/templates/minimal-app/apps/shared/src/modules/posts/posts.schema.ts.tpl +25 -76
- package/templates/minimal-app/apps/shared/tsconfig.json.tpl +16 -12
- package/templates/minimal-app/apps/webapp/index.html.tpl +22 -22
- package/templates/minimal-app/apps/webapp/package.json.tpl +53 -52
- package/templates/minimal-app/apps/webapp/public/{push-sw.js → push-sw.js.tpl} +34 -34
- package/templates/minimal-app/apps/webapp/src/App.tsx.tpl +44 -13
- package/templates/minimal-app/apps/webapp/src/Layout.tsx.tpl +18 -12
- package/templates/minimal-app/apps/webapp/src/Router.tsx.tpl +33 -40
- package/templates/minimal-app/apps/webapp/src/index.css.tpl +15 -75
- package/templates/minimal-app/apps/webapp/src/main.tsx.tpl +26 -26
- package/templates/minimal-app/apps/webapp/src/modules/posts/PostsRoute.tsx.tpl +278 -307
- package/templates/minimal-app/apps/webapp/src/modules/posts/components/PostCard.tsx.tpl +96 -138
- package/templates/minimal-app/apps/webapp/src/modules/posts/components/PostEditorModal.tsx.tpl +118 -124
- package/templates/minimal-app/apps/webapp/src/modules/posts/hooks/usePostActions.ts.tpl +108 -116
- package/templates/minimal-app/apps/webapp/src/modules/posts/hooks/usePostsList.ts.tpl +15 -9
- package/templates/minimal-app/apps/webapp/src/modules/posts/hooks/usePostsRoute.ts.tpl +13 -13
- package/templates/minimal-app/apps/webapp/src/modules/posts/posts.utils.ts.tpl +16 -16
- package/templates/minimal-app/apps/webapp/src/utils/i18n.ts.tpl +13 -13
- package/templates/minimal-app/apps/webapp/src/utils/trpc.ts.tpl +10 -6
- package/templates/minimal-app/apps/webapp/src/vite-env.d.ts.tpl +1 -1
- package/templates/minimal-app/apps/webapp/translations/{app.json.tpl → en/app.json.tpl} +7 -7
- package/templates/minimal-app/apps/webapp/translations/en/{blog-app.json.tpl → {{APP_SLUG}}.json.tpl} +135 -135
- package/templates/minimal-app/apps/webapp/tsconfig.json.tpl +17 -17
- package/templates/minimal-app/apps/webapp/vite.config.ts.tpl +31 -31
- package/templates/minimal-app/template.manifest.json +21 -0
- package/templates/minimal-app/apps/server/drizzle/generate-schema.ts.tpl +0 -31
- package/templates/minimal-app/apps/server/src/db.ts.tpl +0 -7
- package/templates/minimal-app/apps/server/src/generated/schema.ts.tpl +0 -13
- package/templates/minimal-app/apps/server/src/utils/trpc.ts.tpl +0 -8
- package/templates/minimal-app/apps/shared/src/modules/app/locale.constants.ts.tpl +0 -7
- package/templates/minimal-app/apps/shared/src/modules/app/roles.constants.ts.tpl +0 -17
- package/templates/minimal-app/apps/webapp/src/Providers.tsx.tpl +0 -36
- package/templates/minimal-app/apps/webapp/src/modules/notification/PushNotificationsPanel.tsx.tpl +0 -89
- package/templates/minimal-app/apps/webapp/src/navigation/navigation.config.tsx.tpl +0 -85
- /package/templates/minimal-app/apps/webapp/public/{logo.svg → logo.svg.tpl} +0 -0
|
@@ -1,307 +1,278 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
</
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</
|
|
156
|
-
<
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
<
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
<
|
|
221
|
-
{selectedPost
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
</
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
onSave={posts.savePost}
|
|
280
|
-
/>
|
|
281
|
-
</div>
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function StatCard({
|
|
286
|
-
label,
|
|
287
|
-
value,
|
|
288
|
-
accent,
|
|
289
|
-
}: {
|
|
290
|
-
label: string;
|
|
291
|
-
value: number;
|
|
292
|
-
accent: "amber" | "emerald" | "stone";
|
|
293
|
-
}) {
|
|
294
|
-
const accentClass =
|
|
295
|
-
accent === "amber"
|
|
296
|
-
? "border-amber-200 bg-amber-50/90 text-amber-900"
|
|
297
|
-
: accent === "emerald"
|
|
298
|
-
? "border-emerald-200 bg-emerald-50/90 text-emerald-900"
|
|
299
|
-
: "border-stone-200 bg-stone-100/90 text-stone-900";
|
|
300
|
-
|
|
301
|
-
return (
|
|
302
|
-
<div className={`rounded-[24px] border px-4 py-4 ${accentClass}`}>
|
|
303
|
-
<p className="text-[0.68rem] font-semibold uppercase tracking-[0.28em]">{label}</p>
|
|
304
|
-
<p className="mt-3 font-editorial text-4xl leading-none">{value}</p>
|
|
305
|
-
</div>
|
|
306
|
-
);
|
|
307
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Card,
|
|
4
|
+
Chip,
|
|
5
|
+
EmptyState,
|
|
6
|
+
Label,
|
|
7
|
+
ListBox,
|
|
8
|
+
Pagination,
|
|
9
|
+
SearchField,
|
|
10
|
+
Select,
|
|
11
|
+
Skeleton,
|
|
12
|
+
} from "@heroui/react";
|
|
13
|
+
import { FilePenLineIcon, FileTextIcon, PlusIcon } from "lucide-react";
|
|
14
|
+
import { useId, useState } from "react";
|
|
15
|
+
import { useTranslation } from "react-i18next";
|
|
16
|
+
import { PostCard } from "./components/PostCard";
|
|
17
|
+
import { PostEditorModal } from "./components/PostEditorModal";
|
|
18
|
+
import type { PostRow, PostStatusFilter } from "./hooks/usePostsList";
|
|
19
|
+
import { usePostsRoute } from "./hooks/usePostsRoute";
|
|
20
|
+
import { formatDate, getReadingTime } from "./posts.utils";
|
|
21
|
+
|
|
22
|
+
/** Editor modal state: null = closed, {} = create, { post } = edit. */
|
|
23
|
+
type EditorState = { post?: PostRow } | null;
|
|
24
|
+
|
|
25
|
+
const STATUS_OPTIONS = ["all", "draft", "published"] as const satisfies readonly PostStatusFilter[];
|
|
26
|
+
|
|
27
|
+
export function PostsRoute() {
|
|
28
|
+
const { t } = useTranslation("{{APP_SLUG}}");
|
|
29
|
+
const posts = usePostsRoute();
|
|
30
|
+
|
|
31
|
+
const statusFieldId = useId();
|
|
32
|
+
|
|
33
|
+
const [selectedPostId, setSelectedPostId] = useState<string | undefined>(undefined);
|
|
34
|
+
const [editor, setEditor] = useState<EditorState>(null);
|
|
35
|
+
|
|
36
|
+
const selectedPost = posts.rows.find((row) => row.id === selectedPostId) ?? posts.rows[0];
|
|
37
|
+
const isFirstPage = posts.page <= 1;
|
|
38
|
+
const isLastPage = posts.page >= posts.pageCount;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="p-4 grid gap-6" data-testid="posts-route">
|
|
42
|
+
<Card>
|
|
43
|
+
<Card.Header className="flex flex-col gap-1">
|
|
44
|
+
<p className="text-xs font-medium uppercase tracking-wide text-muted">
|
|
45
|
+
{t("posts.hero.eyebrow")}
|
|
46
|
+
</p>
|
|
47
|
+
<Card.Title>{t("posts.hero.title")}</Card.Title>
|
|
48
|
+
<Card.Description>{t("posts.hero.body")}</Card.Description>
|
|
49
|
+
</Card.Header>
|
|
50
|
+
<Card.Content className="grid gap-4">
|
|
51
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
52
|
+
<Button variant="primary" onPress={() => setEditor({})}>
|
|
53
|
+
<span className="inline-flex items-center gap-2">
|
|
54
|
+
<PlusIcon className="h-4 w-4" />
|
|
55
|
+
{t("posts.hero.new")}
|
|
56
|
+
</span>
|
|
57
|
+
</Button>
|
|
58
|
+
<Chip variant="soft" color="default">
|
|
59
|
+
{posts.isFetching ? t("posts.hero.syncing") : t("posts.hero.synced")}
|
|
60
|
+
</Chip>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<div className="grid grid-cols-3 gap-3">
|
|
64
|
+
<Card variant="secondary">
|
|
65
|
+
<Card.Header>
|
|
66
|
+
<Card.Description>{t("posts.stats.total")}</Card.Description>
|
|
67
|
+
<Card.Title>{posts.stats.total}</Card.Title>
|
|
68
|
+
</Card.Header>
|
|
69
|
+
</Card>
|
|
70
|
+
<Card variant="secondary">
|
|
71
|
+
<Card.Header>
|
|
72
|
+
<Card.Description>{t("posts.stats.published")}</Card.Description>
|
|
73
|
+
<Card.Title>{posts.stats.published}</Card.Title>
|
|
74
|
+
</Card.Header>
|
|
75
|
+
</Card>
|
|
76
|
+
<Card variant="secondary">
|
|
77
|
+
<Card.Header>
|
|
78
|
+
<Card.Description>{t("posts.stats.drafts")}</Card.Description>
|
|
79
|
+
<Card.Title>{posts.stats.drafts}</Card.Title>
|
|
80
|
+
</Card.Header>
|
|
81
|
+
</Card>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<div className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_220px]">
|
|
85
|
+
<SearchField
|
|
86
|
+
aria-label={t("posts.filters.searchLabel")}
|
|
87
|
+
name="search"
|
|
88
|
+
variant="secondary"
|
|
89
|
+
value={posts.search}
|
|
90
|
+
onChange={posts.setSearch}
|
|
91
|
+
>
|
|
92
|
+
<Label>{t("posts.filters.searchLabel")}</Label>
|
|
93
|
+
<SearchField.Group>
|
|
94
|
+
<SearchField.SearchIcon />
|
|
95
|
+
<SearchField.Input placeholder={t("posts.filters.searchPlaceholder")} />
|
|
96
|
+
<SearchField.ClearButton />
|
|
97
|
+
</SearchField.Group>
|
|
98
|
+
</SearchField>
|
|
99
|
+
|
|
100
|
+
<div className="grid gap-2">
|
|
101
|
+
<Label className="text-sm font-medium" htmlFor={statusFieldId}>
|
|
102
|
+
{t("posts.filters.statusLabel")}
|
|
103
|
+
</Label>
|
|
104
|
+
<Select
|
|
105
|
+
aria-label={t("posts.filters.statusLabel")}
|
|
106
|
+
className="w-full"
|
|
107
|
+
variant="secondary"
|
|
108
|
+
selectedKey={posts.status}
|
|
109
|
+
onSelectionChange={(key) => {
|
|
110
|
+
if (key === null) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
posts.setStatus(String(key) as PostStatusFilter);
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
<Select.Trigger id={statusFieldId} className="w-full">
|
|
117
|
+
<Select.Value />
|
|
118
|
+
<Select.Indicator />
|
|
119
|
+
</Select.Trigger>
|
|
120
|
+
<Select.Popover>
|
|
121
|
+
<ListBox>
|
|
122
|
+
{STATUS_OPTIONS.map((status) => (
|
|
123
|
+
<ListBox.Item
|
|
124
|
+
key={status}
|
|
125
|
+
id={`${statusFieldId}-${status}`}
|
|
126
|
+
textValue={t(`posts.filters.${status === "all" ? "all" : status}`)}
|
|
127
|
+
>
|
|
128
|
+
{t(`posts.filters.${status === "all" ? "all" : status}`)}
|
|
129
|
+
<ListBox.ItemIndicator />
|
|
130
|
+
</ListBox.Item>
|
|
131
|
+
))}
|
|
132
|
+
</ListBox>
|
|
133
|
+
</Select.Popover>
|
|
134
|
+
</Select>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</Card.Content>
|
|
138
|
+
</Card>
|
|
139
|
+
|
|
140
|
+
<div className="grid gap-6 xl:grid-cols-[minmax(0,1.2fr)_minmax(360px,0.85fr)]">
|
|
141
|
+
<section className="grid gap-4">
|
|
142
|
+
{posts.isLoading ? (
|
|
143
|
+
<>
|
|
144
|
+
<Skeleton className="h-44" animationType="pulse" />
|
|
145
|
+
<Skeleton className="h-44" animationType="pulse" />
|
|
146
|
+
<Skeleton className="h-44" animationType="pulse" />
|
|
147
|
+
</>
|
|
148
|
+
) : posts.rows.length === 0 ? (
|
|
149
|
+
<EmptyState className="flex flex-col items-center gap-4 py-10 text-center">
|
|
150
|
+
<FileTextIcon className="size-6 text-muted" />
|
|
151
|
+
<Chip color="default" variant="soft">
|
|
152
|
+
{t("posts.empty.eyebrow")}
|
|
153
|
+
</Chip>
|
|
154
|
+
<div className="grid gap-2">
|
|
155
|
+
<p className="text-lg font-semibold">{t("posts.empty.title")}</p>
|
|
156
|
+
<p className="max-w-xl text-sm text-muted">{t("posts.empty.body")}</p>
|
|
157
|
+
</div>
|
|
158
|
+
<Button variant="primary" onPress={() => setEditor({})}>
|
|
159
|
+
{t("posts.empty.action")}
|
|
160
|
+
</Button>
|
|
161
|
+
</EmptyState>
|
|
162
|
+
) : (
|
|
163
|
+
posts.rows.map((row) => (
|
|
164
|
+
<PostCard
|
|
165
|
+
key={row.id}
|
|
166
|
+
row={row}
|
|
167
|
+
isSelected={selectedPost?.id === row.id}
|
|
168
|
+
isPublishing={posts.publishingId === row.id}
|
|
169
|
+
isDeleting={posts.deletingId === row.id}
|
|
170
|
+
onSelect={() => setSelectedPostId(row.id)}
|
|
171
|
+
onEdit={() => setEditor({ post: row })}
|
|
172
|
+
onPublish={() => posts.publishPost(row.id)}
|
|
173
|
+
onDelete={() => posts.deletePost(row.id)}
|
|
174
|
+
/>
|
|
175
|
+
))
|
|
176
|
+
)}
|
|
177
|
+
|
|
178
|
+
{posts.rows.length > 0 ? (
|
|
179
|
+
<Pagination size="sm">
|
|
180
|
+
<Pagination.Summary>
|
|
181
|
+
{t("posts.pagination.summary", {
|
|
182
|
+
page: posts.page,
|
|
183
|
+
pageCount: posts.pageCount,
|
|
184
|
+
})}
|
|
185
|
+
</Pagination.Summary>
|
|
186
|
+
<Pagination.Content>
|
|
187
|
+
<Pagination.Item>
|
|
188
|
+
<Pagination.Previous
|
|
189
|
+
isDisabled={isFirstPage}
|
|
190
|
+
onPress={() => posts.goToPage(posts.page - 1)}
|
|
191
|
+
>
|
|
192
|
+
<Pagination.PreviousIcon />
|
|
193
|
+
{t("posts.pagination.previous")}
|
|
194
|
+
</Pagination.Previous>
|
|
195
|
+
</Pagination.Item>
|
|
196
|
+
<Pagination.Item>
|
|
197
|
+
<Pagination.Next
|
|
198
|
+
isDisabled={isLastPage}
|
|
199
|
+
onPress={() => posts.goToPage(posts.page + 1)}
|
|
200
|
+
>
|
|
201
|
+
{t("posts.pagination.next")}
|
|
202
|
+
<Pagination.NextIcon />
|
|
203
|
+
</Pagination.Next>
|
|
204
|
+
</Pagination.Item>
|
|
205
|
+
</Pagination.Content>
|
|
206
|
+
</Pagination>
|
|
207
|
+
) : null}
|
|
208
|
+
</section>
|
|
209
|
+
|
|
210
|
+
<aside className="sticky top-6 h-fit">
|
|
211
|
+
<Card>
|
|
212
|
+
<Card.Header className="flex items-start justify-between gap-4">
|
|
213
|
+
<div className="grid gap-1">
|
|
214
|
+
<p className="text-xs font-medium uppercase tracking-wide text-muted">
|
|
215
|
+
{t("posts.preview.eyebrow")}
|
|
216
|
+
</p>
|
|
217
|
+
<Card.Title>{selectedPost?.title ?? t("posts.preview.emptyTitle")}</Card.Title>
|
|
218
|
+
</div>
|
|
219
|
+
{selectedPost ? (
|
|
220
|
+
<Chip
|
|
221
|
+
color={selectedPost.status === "published" ? "success" : "default"}
|
|
222
|
+
variant="soft"
|
|
223
|
+
>
|
|
224
|
+
{selectedPost.status === "published"
|
|
225
|
+
? t("posts.filters.published")
|
|
226
|
+
: t("posts.filters.draft")}
|
|
227
|
+
</Chip>
|
|
228
|
+
) : null}
|
|
229
|
+
</Card.Header>
|
|
230
|
+
<Card.Content className="flex flex-col gap-4">
|
|
231
|
+
{selectedPost ? (
|
|
232
|
+
<>
|
|
233
|
+
{selectedPost.excerpt ? (
|
|
234
|
+
<Card variant="secondary">
|
|
235
|
+
<Card.Content>
|
|
236
|
+
<p className="text-sm text-muted">{selectedPost.excerpt}</p>
|
|
237
|
+
</Card.Content>
|
|
238
|
+
</Card>
|
|
239
|
+
) : null}
|
|
240
|
+
<div className="flex flex-wrap gap-2">
|
|
241
|
+
<Chip variant="soft" color="default">
|
|
242
|
+
{getReadingTime(selectedPost.content)}
|
|
243
|
+
</Chip>
|
|
244
|
+
<Chip variant="soft">
|
|
245
|
+
{t("posts.preview.updated")}:{" "}
|
|
246
|
+
{formatDate(selectedPost.updatedAt ?? selectedPost.createdAt)}
|
|
247
|
+
</Chip>
|
|
248
|
+
</div>
|
|
249
|
+
<p className="text-sm leading-7 text-muted">{selectedPost.content}</p>
|
|
250
|
+
</>
|
|
251
|
+
) : (
|
|
252
|
+
<Card.Description>{t("posts.preview.emptyBody")}</Card.Description>
|
|
253
|
+
)}
|
|
254
|
+
</Card.Content>
|
|
255
|
+
{selectedPost ? (
|
|
256
|
+
<Card.Footer>
|
|
257
|
+
<Button variant="ghost" onPress={() => setEditor({ post: selectedPost })}>
|
|
258
|
+
<span className="inline-flex items-center gap-2">
|
|
259
|
+
<FilePenLineIcon className="h-4 w-4" />
|
|
260
|
+
{t("posts.preview.openEditor")}
|
|
261
|
+
</span>
|
|
262
|
+
</Button>
|
|
263
|
+
</Card.Footer>
|
|
264
|
+
) : null}
|
|
265
|
+
</Card>
|
|
266
|
+
</aside>
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<PostEditorModal
|
|
270
|
+
isOpen={editor !== null}
|
|
271
|
+
post={editor?.post}
|
|
272
|
+
isSaving={posts.isSaving}
|
|
273
|
+
onClose={() => setEditor(null)}
|
|
274
|
+
onSave={posts.savePost}
|
|
275
|
+
/>
|
|
276
|
+
</div>
|
|
277
|
+
);
|
|
278
|
+
}
|