Skip to content

Commit 0010e7a

Browse files
authored
イベントの説明欄を追加 (#50)
* feat: イベント説明欄を追加 * マイグレーションファイルを追加
1 parent 88960ee commit 0010e7a

File tree

8 files changed

+38
-2
lines changed

8 files changed

+38
-2
lines changed

client/src/pages/Project.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export default function ProjectPage() {
8989
mode: "onChange",
9090
defaultValues: {
9191
name: "",
92+
description: "",
9293
startDate: eventId ? "" : dayjs().format("YYYY-MM-DD"),
9394
endDate: eventId ? "" : dayjs().add(6, "day").format("YYYY-MM-DD"),
9495
allowedRanges: [{ startTime: "00:00", endTime: "23:45" }],
@@ -109,6 +110,7 @@ export default function ProjectPage() {
109110
if (!project) return;
110111
reset({
111112
name: project.name,
113+
description: project.description,
112114
startDate: dayjs(project.startDate).format("YYYY-MM-DD"),
113115
endDate: dayjs(project.endDate).format("YYYY-MM-DD"),
114116
allowedRanges: [
@@ -136,6 +138,7 @@ export default function ProjectPage() {
136138

137139
const eventData = {
138140
name: data.name ?? "",
141+
description: data.description ?? "",
139142
startDate: startDateTime,
140143
endDate: endDateTime,
141144
allowedRanges: rangeWithDateTime ?? [],
@@ -235,6 +238,19 @@ export default function ProjectPage() {
235238
/>
236239
{errors.name && <p className="mt-1 text-red-500 text-sm">{errors.name.message}</p>}
237240
</div>
241+
<div>
242+
<label className="text-gray-400 text-sm" htmlFor="input-description">
243+
イベントの説明(任意)
244+
</label>
245+
<textarea
246+
{...register("description")}
247+
id="input-description"
248+
className={`textarea w-full text-base ${errors.description ? "textarea-error border-red-500" : ""}`}
249+
placeholder="イベントの詳細や注意事項などを入力"
250+
rows={3}
251+
/>
252+
{errors.description && <p className="mt-1 text-red-500 text-sm">{errors.description.message}</p>}
253+
</div>
238254
{!project || (project && project.guests.length === 0) ? (
239255
<>
240256
<div className="collapse-arrow collapse mb-4 border border-blue-200 bg-blue-50">

client/src/pages/eventId/Submission.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ export default function SubmissionPage() {
169169
</NavLink>
170170
)}
171171
</div>
172+
{project.description && (
173+
<p className="mb-4 whitespace-pre-wrap text-gray-600 text-sm">{project.description}</p>
174+
)}
172175
<Calendar project={project} myGuestId={myGuestId ?? ""} mySlotsRef={mySlotsRef} editMode={editMode} />
173176
<div className="flex w-full items-center justify-between gap-2 p-2">
174177
{editMode ? (

client/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Guest = {
2828
export type Project = {
2929
id: string;
3030
name: string;
31+
description: string;
3132
startDate: Date;
3233
endDate: Date;
3334
allowedRanges: AllowedRange[];
@@ -41,6 +42,7 @@ export type Project = {
4142
export type ISOStringProject = {
4243
id: string;
4344
name: string;
45+
description: string;
4446
startDate: string;
4547
endDate: string;
4648
allowedRanges: {

common/validators.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const isQuarterHour = (time: string): boolean => {
2323

2424
const baseProjectReqSchema = z.object({
2525
name: z.string().min(1, "イベント名を入力してください"),
26+
description: z.string(),
2627
startDate: z.string().min(1, "開始日を入力してください"),
2728
// TODO: 新規作成時のみ、過去日付を制限する必要
2829
// .refine(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "Project" ADD COLUMN "description" TEXT;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Please do not edit this file manually
2+
# It should be added in your version-control system (e.g., Git)
3+
provider = "postgresql"

server/prisma/schema.prisma

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ datasource db {
1717
model Project {
1818
id String @id @db.VarChar(21)
1919
name String
20+
description String? /// イベントの説明(オプショナル)
2021
/// 注: 日付部分のみ利用。時間は考慮しない。
21-
startDate DateTime
22+
startDate DateTime
2223
/// 注: 日付部分のみ利用。時間は考慮しない。
2324
endDate DateTime
2425
/// 注: 現在は 1 つのみ設定可能

server/src/routes/projects.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const router = new Hono()
2626
data: {
2727
id: nanoid(),
2828
name: data.name,
29+
description: data.description.trim() || null,
2930
startDate: new Date(data.startDate),
3031
endDate: new Date(data.endDate),
3132
allowedRanges: {
@@ -79,6 +80,7 @@ const router = new Hono()
7980
select: {
8081
id: true,
8182
name: true,
83+
description: true,
8284
startDate: true,
8385
endDate: true,
8486
hosts: {
@@ -93,6 +95,7 @@ const router = new Hono()
9395
involvedProjects.map((p) => ({
9496
id: p.id,
9597
name: p.name,
98+
description: p.description ?? "",
9699
startDate: p.startDate,
97100
endDate: p.endDate,
98101
isHost: p.hosts.some((host) => host.browserId === browserId),
@@ -136,6 +139,7 @@ const router = new Hono()
136139

137140
const data = {
138141
...projectRow,
142+
description: projectRow.description ?? "",
139143
hosts: projectRow.hosts.map((h) => {
140144
const { browserId: _, ...rest } = h;
141145
return rest;
@@ -187,9 +191,13 @@ const router = new Hono()
187191
const updatedEvent = await prisma.project.update({
188192
where: { id: projectId },
189193
data: existingGuest
190-
? { name: data.name } // ゲストがいれば名前だけ
194+
? {
195+
name: data.name,
196+
description: data.description?.trim() || null,
197+
} // ゲストがいれば名前と説明だけ
191198
: {
192199
name: data.name,
200+
description: data.description?.trim() || null,
193201
startDate: data.startDate ? new Date(data.startDate) : undefined,
194202
endDate: data.endDate ? new Date(data.endDate) : undefined,
195203
allowedRanges: {

0 commit comments

Comments
 (0)