diff --git a/app/api/[roomcode]/route.ts b/app/api/[roomcode]/route.ts index bda4a03..2ad8887 100644 --- a/app/api/[roomcode]/route.ts +++ b/app/api/[roomcode]/route.ts @@ -77,12 +77,10 @@ export async function GET(_request: Request, context: RoomCodeRouteContext) { ] // console.log(result); - await db - .collection('result') - .insertOne({ - roomcode: context.params.roomcode, - result: result, - }) + await db.collection('result').insertOne({ + roomcode: context.params.roomcode, + result: result, + }) console.log('Saved Successfully!') } else { result = await results[0].result diff --git a/app/api/new-room/route.ts b/app/api/new-room/route.ts index ad81973..18423d5 100644 --- a/app/api/new-room/route.ts +++ b/app/api/new-room/route.ts @@ -7,13 +7,11 @@ export async function POST(request: Request) { const client = await clientPromise const db = client.db('get_interval') - await db - .collection('rooms') - .insertOne({ - username: username, - roomcode: roomcode, - timeRanges: timeRanges, - }) + await db.collection('rooms').insertOne({ + username: username, + roomcode: roomcode, + timeRanges: timeRanges, + }) return new Response(JSON.stringify(roomcode), { status: 200 }) } catch (error) { diff --git a/app/globals.css b/app/globals.css index 81670ec..f9627ca 100644 --- a/app/globals.css +++ b/app/globals.css @@ -7,14 +7,43 @@ input[type='time']::-webkit-calendar-picker-indicator { display: none; } -@layer base { - ::-webkit-scrollbar { - @apply w-3 bg-[#16161a]; - } - ::-webkit-scrollbar-thumb { - @apply w-3 rounded-lg bg-[#fff] hover:bg-[#fff] /*color trackbar*/; - } - html { - -webkit-tap-highlight-color: transparent; - } +/* width */ +::-webkit-scrollbar { + width: 10px; +} + +/* Track */ +::-webkit-scrollbar-track { + background: #16161a; +} + +/* Handle */ +::-webkit-scrollbar-thumb { + background: #888; + border-radius: 5px; +} + +/* Handle on hover */ +::-webkit-scrollbar-thumb:hover { + background: #fff; +} + +.timeline::-webkit-scrollbar { + width: 10px; +} + +/* Track */ +.timeline::-webkit-scrollbar-track { + background: #16161a; +} + +/* Handle */ +.timeline::-webkit-scrollbar-thumb { + background: #888; + border-radius: 5px; +} + +/* Handle on hover */ +.timeline::-webkit-scrollbar-thumb:hover { + background: #fff; } diff --git a/components/GetForm.tsx b/components/GetForm.tsx index b4e59ed..e3e6809 100644 --- a/components/GetForm.tsx +++ b/components/GetForm.tsx @@ -20,7 +20,7 @@ const GetForm = ({ roomCode }: RoomCode) => { if (formData.name === '') setShowError(true) else { setShowError(false) - API.postData(formData); + API.postData(formData) router.push(`/${roomCode}/result`) } } @@ -35,7 +35,7 @@ const GetForm = ({ roomCode }: RoomCode) => { Room Code: {roomCode}

-
+
diff --git a/components/Results.tsx b/components/Results.tsx index 8cc1bf3..386aef1 100644 --- a/components/Results.tsx +++ b/components/Results.tsx @@ -47,12 +47,12 @@ const Results = ({ roomCode }: RoomCode) => {

{result.map((interval: number[], index: number) => ( -

+

{NumToTime(interval[0])} - {NumToTime(interval[1])}

))} -
+
diff --git a/components/Timeline.tsx b/components/Timeline.tsx index d52b53e..e8fd9f5 100644 --- a/components/Timeline.tsx +++ b/components/Timeline.tsx @@ -1,10 +1,7 @@ import { rajdhani } from '@/lib/fonts' +import { TimeRange } from '@/lib/types' import { conditionMet, timeline } from '@/lib/utils' -type TimeRange = { - timeRanges: number[][] -} - const Timeline = ({ timeRanges }: TimeRange) => { const blockLine = (result: boolean, time: number) => { if (result) diff --git a/lib/api.ts b/lib/api.ts index c9ab2d7..a9c74d5 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -1,4 +1,4 @@ -import { FormData } from "./types" +import { FormData } from './types' export const API = { postData: async (formData: FormData) => { @@ -8,8 +8,8 @@ export const API = { body: JSON.stringify({ username: formData.name, roomcode: formData.roomCode, - timeRanges: formData.intervals - }) + timeRanges: formData.intervals, + }), }) return res.json() @@ -20,8 +20,8 @@ export const API = { getInterval: async (roomCode: string) => { try { - const res = await fetch(`/api/${roomCode}`, { - method: 'GET' + const res = await fetch(`/api/${roomCode}`, { + method: 'GET', }) return res.json() @@ -33,7 +33,7 @@ export const API = { getUsers: async (roomCode: string) => { try { const res = await fetch(`/api/${roomCode}/review`, { - method: 'GET' + method: 'GET', }) return res.json() @@ -45,7 +45,7 @@ export const API = { deleteRoom: async (roomCode: string) => { try { const res = await fetch(`/api/${roomCode}/delete`, { - method: 'DELETE' + method: 'DELETE', }) return res.json() @@ -53,4 +53,4 @@ export const API = { console.log(err) } }, -} \ No newline at end of file +} diff --git a/lib/types.ts b/lib/types.ts index e116f77..efbcc43 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,8 +1,8 @@ -import { Dispatch, SetStateAction } from "react" +import { Dispatch, SetStateAction } from 'react' export interface SetUser { - username: string, - roomcode: string, + username: string + roomcode: string timeRanges: number[][] } @@ -36,4 +36,8 @@ export interface MemberData { export interface SetFormData { setFormData: Dispatch> -} \ No newline at end of file +} + +export type TimeRange = { + timeRanges: number[][] +} diff --git a/lib/utils.ts b/lib/utils.ts index 0a89f1a..984eb1e 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -93,9 +93,9 @@ for (let x = 0; x < 24 * 60; x++) { } export const conditionMet = (time: number, timeRanges: number[][]) => { - for(let x = 0; x < timeRanges.length; x++) { - let range = timeRanges[x] - if(time >= range[0] && time <= range[1]) return true; - } - return false - } \ No newline at end of file + for (let x = 0; x < timeRanges.length; x++) { + let range = timeRanges[x] + if (time >= range[0] && time <= range[1]) return true + } + return false +}