Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event location #124

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/web/src/app/api/admin/events/create/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function POST(req: Request) {
description: parsedBody.data.description,
startTime: parsedBody.data.startTime,
endTime: parsedBody.data.endTime,
location: parsedBody.data.location,
type: parsedBody.data.type,
host:
parsedBody.data.host && parsedBody.data.host.length > 0
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/components/events/admin/EventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export default function EventFull({ event }: { event: Event }) {
<h2 className="mb-20 text-lg font-bold">
Hosted by {event.host}
</h2>
<h3 className="mb-2 font-bold">
Location:{" "}
<span className="font-normal">{event.location}</span>
</h3>

<h3 className="mb-2 font-bold">Description:</h3>
<p>
<Balancer>{event.description}</Balancer>
Expand Down
26 changes: 24 additions & 2 deletions apps/web/src/components/events/admin/NewEventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default function NewEventForm({ defaultDate }: NewEventFormProps) {
type: "" as any,
host: "",
startTime: defaultDate,
points: 0,
location: "TBD",
endTime: new Date(defaultDate.getTime() + ONE_HOUR_IN_MILLISECONDS),
},
});
Expand Down Expand Up @@ -92,6 +94,7 @@ export default function NewEventForm({ defaultDate }: NewEventFormProps) {
</FormItem>
)}
/>

<FormField
control={form.control}
name="description"
Expand All @@ -105,6 +108,25 @@ export default function NewEventForm({ defaultDate }: NewEventFormProps) {
</FormItem>
)}
/>
<FormField
control={form.control}
name="location"
render={({ field }) => (
<FormItem>
<FormLabel>Location</FormLabel>
<FormControl>
<Input
{...field}
value={field.value ?? "TBD"}
/>
</FormControl>
{/* <FormDescription>
Keep title short and concise
</FormDescription> */}
<FormMessage />
</FormItem>
)}
/>
<div className="grid grid-cols-2 gap-x-2">
<FormField
control={form.control}
Expand Down Expand Up @@ -166,15 +188,15 @@ export default function NewEventForm({ defaultDate }: NewEventFormProps) {
<FormLabel>Event Start</FormLabel>
<DateTimePicker
value={
!!field.value
field.value
? parseAbsolute(
field.value.toISOString(),
userLocalTimeZone,
)
: null
}
onChange={(date) => {
const newDate = !!date
const newDate = date
? date.toDate(userLocalTimeZone)
: null;
field.onChange(newDate);
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/components/events/shared/EventColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export const columns: ColumnDef<eventTableValidatorType>[] = [
</span>
),
},
{
accessorKey: "location",
header: "Location",
cell: ({ row }) => <span>{row.original.location}</span>,
},
{
accessorKey: "startTime",
header: "Start",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface EventType extends InferSelectModel<typeof events> {}

export type eventTableValidatorType = Pick<
z.infer<typeof eventDataTableValidator>,
"title" | "startTime" | "endTime" | "id" | "type"
"title" | "location" | "startTime" | "endTime" | "id" | "type"
>;

export interface NewEventFormProps {
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/validators/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import c from "config";
export const newEventFormSchema = createInsertSchema(events, {
title: z.string().min(1),
description: z.string().min(1),
location: z.string().min(1),
startTime: z.date(),
endTime: z.date(),
host: z.string().optional(),
Expand Down
6 changes: 3 additions & 3 deletions packages/db/functions/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export function createNewEvent(event: eventInsertType) {

export function getAllEvents(options?: getAllEventsOptions) {
const orderByClause = options?.descending
? [desc(events.startTime)]
: [asc(events.startTime)]
? [desc(events.startTime)]
: [asc(events.startTime)];

return db.query.events.findMany({
orderBy: orderByClause,
});
Expand Down
6 changes: 2 additions & 4 deletions packages/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,8 @@ export const events = pgTable("events", {
title: varchar("name", { length: 255 }).notNull(),
startTime: timestamp("start_time").notNull(),
endTime: timestamp("end_time").notNull(),
// checkinStartTime: timestamp("checkin_start_time").notNull(),
// checkinEndTime: timestamp("checkin_end_time").notNull(),
// location: varchar("location", { length: 255 }).notNull(),
// points: integer("points").notNull().default(0),
location: varchar("location", { length: 255 }).default("TBD"),
points: integer("points").notNull().default(0),
description: text("description").notNull(),
type: varchar("type", { length: 50 }).notNull(),
host: varchar("host", { length: 255 }),
Expand Down
Loading