Skip to content

Commit b44694b

Browse files
committed
fixed eslint bugs and used prettier
1 parent fdc2070 commit b44694b

File tree

9 files changed

+75
-49
lines changed

9 files changed

+75
-49
lines changed

app/api/[roomcode]/route.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,10 @@ export async function GET(_request: Request, context: RoomCodeRouteContext) {
7777
]
7878
// console.log(result);
7979

80-
await db
81-
.collection('result')
82-
.insertOne({
83-
roomcode: context.params.roomcode,
84-
result: result,
85-
})
80+
await db.collection('result').insertOne({
81+
roomcode: context.params.roomcode,
82+
result: result,
83+
})
8684
console.log('Saved Successfully!')
8785
} else {
8886
result = await results[0].result

app/api/new-room/route.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ export async function POST(request: Request) {
77
const client = await clientPromise
88
const db = client.db('get_interval')
99

10-
await db
11-
.collection('rooms')
12-
.insertOne({
13-
username: username,
14-
roomcode: roomcode,
15-
timeRanges: timeRanges,
16-
})
10+
await db.collection('rooms').insertOne({
11+
username: username,
12+
roomcode: roomcode,
13+
timeRanges: timeRanges,
14+
})
1715

1816
return new Response(JSON.stringify(roomcode), { status: 200 })
1917
} catch (error) {

app/globals.css

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,43 @@ input[type='time']::-webkit-calendar-picker-indicator {
77
display: none;
88
}
99

10-
@layer base {
11-
::-webkit-scrollbar {
12-
@apply w-3 bg-[#16161a];
13-
}
14-
::-webkit-scrollbar-thumb {
15-
@apply w-3 rounded-lg bg-[#fff] hover:bg-[#fff] /*color trackbar*/;
16-
}
17-
html {
18-
-webkit-tap-highlight-color: transparent;
19-
}
10+
/* width */
11+
::-webkit-scrollbar {
12+
width: 10px;
13+
}
14+
15+
/* Track */
16+
::-webkit-scrollbar-track {
17+
background: #16161a;
18+
}
19+
20+
/* Handle */
21+
::-webkit-scrollbar-thumb {
22+
background: #888;
23+
border-radius: 5px;
24+
}
25+
26+
/* Handle on hover */
27+
::-webkit-scrollbar-thumb:hover {
28+
background: #fff;
29+
}
30+
31+
.timeline::-webkit-scrollbar {
32+
width: 10px;
33+
}
34+
35+
/* Track */
36+
.timeline::-webkit-scrollbar-track {
37+
background: #16161a;
38+
}
39+
40+
/* Handle */
41+
.timeline::-webkit-scrollbar-thumb {
42+
background: #888;
43+
border-radius: 5px;
44+
}
45+
46+
/* Handle on hover */
47+
.timeline::-webkit-scrollbar-thumb:hover {
48+
background: #fff;
2049
}

components/GetForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const GetForm = ({ roomCode }: RoomCode) => {
2020
if (formData.name === '') setShowError(true)
2121
else {
2222
setShowError(false)
23-
API.postData(formData);
23+
API.postData(formData)
2424
router.push(`/${roomCode}/result`)
2525
}
2626
}
@@ -35,7 +35,7 @@ const GetForm = ({ roomCode }: RoomCode) => {
3535
Room Code: {roomCode}
3636
</p>
3737

38-
<Form {...{setFormData}} />
38+
<Form {...{ setFormData }} />
3939
</div>
4040

4141
<div className="mt-[20px] ml-[20px] max-[985px]:hidden">

components/Results.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ const Results = ({ roomCode }: RoomCode) => {
4747
</p>
4848

4949
{result.map((interval: number[], index: number) => (
50-
<p className="text-3xl text-[#48d399] my-1">
50+
<p className="text-3xl text-[#48d399] my-1" key={index}>
5151
{NumToTime(interval[0])} - {NumToTime(interval[1])}
5252
</p>
5353
))}
5454

55-
<div className="px-4 flex items-center justify-start w-full overflow-auto">
55+
<div className="timeline px-4 flex items-center justify-start w-full overflow-auto">
5656
<Timeline timeRanges={result} />
5757
</div>
5858

components/Timeline.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { rajdhani } from '@/lib/fonts'
2+
import { TimeRange } from '@/lib/types'
23
import { conditionMet, timeline } from '@/lib/utils'
34

4-
type TimeRange = {
5-
timeRanges: number[][]
6-
}
7-
85
const Timeline = ({ timeRanges }: TimeRange) => {
96
const blockLine = (result: boolean, time: number) => {
107
if (result)

lib/api.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FormData } from "./types"
1+
import { FormData } from './types'
22

33
export const API = {
44
postData: async (formData: FormData) => {
@@ -8,8 +8,8 @@ export const API = {
88
body: JSON.stringify({
99
username: formData.name,
1010
roomcode: formData.roomCode,
11-
timeRanges: formData.intervals
12-
})
11+
timeRanges: formData.intervals,
12+
}),
1313
})
1414

1515
return res.json()
@@ -20,8 +20,8 @@ export const API = {
2020

2121
getInterval: async (roomCode: string) => {
2222
try {
23-
const res = await fetch(`/api/${roomCode}`, {
24-
method: 'GET'
23+
const res = await fetch(`/api/${roomCode}`, {
24+
method: 'GET',
2525
})
2626

2727
return res.json()
@@ -33,7 +33,7 @@ export const API = {
3333
getUsers: async (roomCode: string) => {
3434
try {
3535
const res = await fetch(`/api/${roomCode}/review`, {
36-
method: 'GET'
36+
method: 'GET',
3737
})
3838

3939
return res.json()
@@ -45,12 +45,12 @@ export const API = {
4545
deleteRoom: async (roomCode: string) => {
4646
try {
4747
const res = await fetch(`/api/${roomCode}/delete`, {
48-
method: 'DELETE'
48+
method: 'DELETE',
4949
})
5050

5151
return res.json()
5252
} catch (err: any) {
5353
console.log(err)
5454
}
5555
},
56-
}
56+
}

lib/types.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Dispatch, SetStateAction } from "react"
1+
import { Dispatch, SetStateAction } from 'react'
22

33
export interface SetUser {
4-
username: string,
5-
roomcode: string,
4+
username: string
5+
roomcode: string
66
timeRanges: number[][]
77
}
88

@@ -36,4 +36,8 @@ export interface MemberData {
3636

3737
export interface SetFormData {
3838
setFormData: Dispatch<SetStateAction<FormData>>
39-
}
39+
}
40+
41+
export type TimeRange = {
42+
timeRanges: number[][]
43+
}

lib/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ for (let x = 0; x < 24 * 60; x++) {
9393
}
9494

9595
export const conditionMet = (time: number, timeRanges: number[][]) => {
96-
for(let x = 0; x < timeRanges.length; x++) {
97-
let range = timeRanges[x]
98-
if(time >= range[0] && time <= range[1]) return true;
99-
}
100-
return false
101-
}
96+
for (let x = 0; x < timeRanges.length; x++) {
97+
let range = timeRanges[x]
98+
if (time >= range[0] && time <= range[1]) return true
99+
}
100+
return false
101+
}

0 commit comments

Comments
 (0)