Skip to content

Commit

Permalink
fix linting error, update time picker
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorDuino committed Jul 17, 2024
1 parent 73ca586 commit bd8de44
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 229 deletions.
13 changes: 12 additions & 1 deletion frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ await import("./src/env.js");
/** @type {import("next").NextConfig} */
const config = {
typescript: {

// TODO: return to false
ignoreBuildErrors: true,
},
images: {
dangerouslyAllowSVG: true,
remotePatterns: [
{
protocol: 'https',
hostname: '**',
port: '',
pathname: '**',
},
],
},

};

export default config;
7 changes: 4 additions & 3 deletions frontend/src/app/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Link from "next/link"
import Image from 'next/image'


export default function Component() {
return (
Expand All @@ -17,7 +18,7 @@ export default function Component() {
<div className="container mx-auto px-4 md:px-6">
<div className="max-w-5xl mx-auto grid gap-8 md:grid-cols-2">
<div className="flex items-center justify-center">
<img src="/img/about/gcal.png" width={400} height={300} alt="Google Calendar" className="rounded-lg" />
<Image src="/img/about/gcal.png" width={400} height={300} alt="Google Calendar" className="rounded-lg" />
</div>
<div>
<h2 className="text-3xl md:text-4xl font-bold mb-4">Import the busy from Google Calendar</h2>
Expand All @@ -38,7 +39,7 @@ export default function Component() {
</p>
</div>
<div className="flex items-center justify-center">
<img src="/img/about/zoom.png" width={400} height={300} alt="Google Calendar" className="rounded-lg" />
<Image src="/img/about/zoom.png" width={400} height={300} alt="Google Calendar" className="rounded-lg" />
</div>
</div>
</div>
Expand Down
134 changes: 34 additions & 100 deletions frontend/src/app/meeting/page.tsx
Original file line number Diff line number Diff line change
@@ -1,104 +1,38 @@
"use client";

"use client"

import TimePeeker from '@/components/elements/meeting/timepeeker'

import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { z } from "zod"

import { Button } from "@/components/ui/button"
import React, { useState } from "react";
import WeeklySchedule from "@/components/WeeklySchedule/WeeklySchedule";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form"
import { Input } from "@/components/ui/input"
import { toast } from "@/components/ui/use-toast"

const FormSchema = z.object({
name: z.string().min(2, {
message: "Name must be at least 2 characters.",
}),
email: z.string().email({
message: "Invalid email address.",
}),
})

export function InputForm() {
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
name: "",
email: ""
},
})

function onSubmit(data: z.infer<typeof FormSchema>) {
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
</pre>
),
})
}
type WeeklySchedule as WeeklyScheduleType,
schedule as defaultSchedule,
TimePeekerSlotType,
} from "@/components/WeeklySchedule/timepeeker";

const SchedulePage: React.FC = () => {
const [schedule, setSchedule] = useState<WeeklyScheduleType>(defaultSchedule);

const handleSlotClick = (day: string, time: string) => {
setSchedule((prevSchedule) => {
const newSchedule = { ...prevSchedule };
if (newSchedule[day]?.[time]) {
newSchedule[day][time] =
newSchedule[day][time] === TimePeekerSlotType.Available
? TimePeekerSlotType.Busy
: TimePeekerSlotType.Available;
}
newSchedule[day]?.[time] === TimePeekerSlotType.Available
? TimePeekerSlotType.Busy
: TimePeekerSlotType.Available;
return newSchedule;
});
};

return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="w-2/3 space-y-6">
<FormField
control={form.control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Your name</FormLabel>
<FormControl>
<Input placeholder="enter your name" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Your mail</FormLabel>
<FormControl>
<Input placeholder="[email protected]" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit" className="w-full" variant="action">Submit</Button>
</form>
</Form>
)
}


export default function meeting (){

return (
<div className="container py-12 lg:py-16">

<div className="flex flex-row">
<div>
<InputForm/>
<Button variant="outline">Load events from Google</Button>
</div>
<TimePeeker />
<div className="vertline h-full bg-black w-1"></div>
<TimePeeker />
</div>
</div>
)
}
<div className="container mx-auto p-4">
<h1 className="mb-4 text-2xl font-bold">Weekly Schedule</h1>
<WeeklySchedule schedule={schedule} onSlotClick={handleSlotClick} />
</div>
);
};

export default SchedulePage;
11 changes: 9 additions & 2 deletions frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React from "react";

import Link from "next/link";
import Image from "next/image";

import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"
import Link from "next/link";


export default function HeroSectionImageWithReviews() {
return (
Expand Down Expand Up @@ -29,7 +34,9 @@ export default function HeroSectionImageWithReviews() {
</div>
{/* Col */}
<div className="">
<img
<Image
width={800}
height={700}
className="w-full rounded-md"
src="https://placehold.co/800x700"
alt="Image Description"
Expand Down
50 changes: 50 additions & 0 deletions frontend/src/components/WeeklySchedule/WeeklySchedule.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use client";

import React from "react";
import { type TimePeekerProps, TimePeekerSlotType } from "./timepeeker";

export const WeeklySchedule: React.FC<TimePeekerProps> = ({
schedule,
onSlotClick,
}) => {
const days = Object.keys(schedule);
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const times = days.length > 0 ? Object.keys(schedule[days[0]]) : [];

const getSlotClass = (slotType: TimePeekerSlotType) => {
switch (slotType) {
case TimePeekerSlotType.Busy:
return "bg-green-600";
case TimePeekerSlotType.Available:
default:
return "bg-white";
}
};

return (
<div className="grid grid-cols-8 gap-2">
<div></div>
{days.map((day) => (
<div key={day} className="text-center font-semibold">
{day}
</div>
))}
{times.map((time) => (
<React.Fragment key={time}>
<div className="pr-2 text-right">{time}</div>
{days.map((day) => (
<div
key={`${day}-${time}`}
className={`cursor-pointer border ${getSlotClass(schedule[day][time])}`}
onClick={() => onSlotClick(day, time)}
>
&nbsp;
</div>
))}
</React.Fragment>
))}
</div>
);
};

export default WeeklySchedule;
27 changes: 27 additions & 0 deletions frontend/src/components/WeeklySchedule/timepeeker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export enum TimePeekerSlotType {
Busy = 'Busy',
Available = 'Available',
}

type TimeSlots = Record<string, TimePeekerSlotType>;

export type WeeklySchedule = Record<string, TimeSlots>;

function defaultWeeklySchedule(): WeeklySchedule {
const schedule: WeeklySchedule = {};
["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].forEach(day => {
schedule[day] = {};
["9:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00"].forEach(time => {
(schedule[day]!)[time] = TimePeekerSlotType.Available;
});
});
return schedule;
}

export type TimePeekerProps = {
schedule: WeeklySchedule;
onSlotClick: (day: string, time: string) => void;
};

export const schedule = defaultWeeklySchedule();

2 changes: 1 addition & 1 deletion frontend/src/components/elements/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Sheet, SheetTrigger, SheetContent } from "@/components/ui/sheet"
import Link from "next/link"
import { Button } from "@/components/ui/button"
import { NavigationMenu, NavigationMenuList, NavigationMenuLink } from "@/components/ui/navigation-menu"
import { ReactNode } from "react"
import { type ReactNode } from "react"


export default function Header () {
Expand Down
Loading

0 comments on commit bd8de44

Please sign in to comment.