Skip to content

Commit a96834a

Browse files
committed
button toggle works great
1 parent 1f31756 commit a96834a

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

Diff for: app/(bookingPage)/[username]/[eventName]/page.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ async function getData(username: string, eventName: string) {
2727
description: true,
2828
title: true,
2929
duration: true,
30+
videoCallSoftware: true,
3031

3132
user: {
3233
select: {
@@ -103,7 +104,7 @@ const BookingPage = async ({
103104
<p className="flex items-center">
104105
<BookMarked className="size-4 mr-2 text-primary" />
105106
<span className="text-sm font-medium text-muted-foreground">
106-
Google Meet
107+
{eventType.videoCallSoftware}
107108
</span>
108109
</p>
109110
</div>

Diff for: app/actions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export async function CreateEventTypeAction(
134134
url: submission.value.url,
135135
description: submission.value.description,
136136
userId: session.user?.id as string,
137+
videoCallSoftware: submission.value.videoCallSoftware,
137138
},
138139
});
139140

Diff for: app/dashboard/new/page.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Link from "next/link";
2222
import React, { useState } from "react";
2323
import { useFormState } from "react-dom";
2424

25-
type Platform = "Zoom Meeting" | "Google Meet" | "Microsoft Teams" | null;
25+
type Platform = "Zoom Meeting" | "Google Meet" | "Microsoft Teams";
2626

2727
const CreateNewEvent = () => {
2828
const [lastResult, action] = useFormState(CreateEventTypeAction, undefined);
@@ -39,10 +39,10 @@ const CreateNewEvent = () => {
3939
shouldValidate: "onBlur",
4040
shouldRevalidate: "onInput",
4141
});
42-
const [activePlatform, setActivePlatform] = useState<Platform>(null);
42+
const [activePlatform, setActivePlatform] = useState<Platform>("Google Meet");
4343

4444
const togglePlatform = (platform: Platform) => {
45-
setActivePlatform((prev) => (prev === platform ? null : platform));
45+
setActivePlatform(platform);
4646
};
4747
return (
4848
<div className="h-full w-full flex-1 flex flex-col items-center justify-center">
@@ -111,6 +111,11 @@ const CreateNewEvent = () => {
111111
</div>
112112

113113
<div className="grid gap-y-2">
114+
<input
115+
type="hidden"
116+
name={fields.videoCallSoftware.name}
117+
value={activePlatform}
118+
/>
114119
<Label>Video Call Provider</Label>
115120
<ButtonGroup className="w-full">
116121
<Button

Diff for: app/lib/zodSchemas.ts

+1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ export const eventTypeSchema = z.object({
5757
duration: z.number().min(1).max(100),
5858
url: z.string().min(3).max(150),
5959
description: z.string().min(3).max(300),
60+
videoCallSoftware: z.string(),
6061
});

Diff for: prisma/schema.prisma

+7-6
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@ enum Day {
9696
}
9797

9898
model EventType {
99-
id String @id @default(uuid())
100-
title String
101-
duration Int
102-
url String
103-
description String
104-
active Boolean @default(true)
99+
id String @id @default(uuid())
100+
title String
101+
duration Int
102+
url String
103+
description String
104+
active Boolean @default(true)
105+
videoCallSoftware String @default("Google Meet")
105106
106107
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
107108
userId String

0 commit comments

Comments
 (0)