File tree Expand file tree Collapse file tree 5 files changed +53
-31
lines changed Expand file tree Collapse file tree 5 files changed +53
-31
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,9 @@ export default function Page({ params }: { params: { food: string } }) {
28
28
> ,
29
29
i ,
30
30
) => [
31
- category as string ,
32
- ( < Component key = { i } food = { food } /> ) as JSX . Element ,
33
- ] ,
31
+ category as string ,
32
+ ( < Component key = { i } food = { food } /> ) as JSX . Element ,
33
+ ] ,
34
34
) ;
35
35
36
36
useEffect ( ( ) => {
@@ -53,7 +53,10 @@ export default function Page({ params }: { params: { food: string } }) {
53
53
54
54
return (
55
55
< main className = "flex flex-col items-center" >
56
- < ul className = "flex font-medium text-2xl text-[#003C6C] items-center justify-center py-5" >
56
+ < h1 className = "font-normal py-4 text-2xl text-[#003C6C]" >
57
+ { food . name }
58
+ </ h1 >
59
+ < ul className = "flex font-medium text-2xl text-[#003C6C] items-center justify-center pb-5" >
57
60
{ tabs . map ( ( [ category , _ ] : Array < string | JSX . Element > , i ) => (
58
61
< li key = { i } className = "" >
59
62
< button
Original file line number Diff line number Diff line change @@ -86,10 +86,8 @@ export default function Comments({ food }: { food: Food }) {
86
86
87
87
return (
88
88
< div >
89
- < h1 className = "text-2xl text-[#003C6C] flex items-center justify-center py-3 mr-2 mb-1" >
90
- { food && food . name }
91
- </ h1 >
92
- < div >
89
+
90
+ < div className = "pt-5" >
93
91
{ comments . map ( ( comment , i ) => (
94
92
< div
95
93
key = { comment . id }
@@ -158,11 +156,10 @@ export default function Comments({ food }: { food: Food }) {
158
156
comment : textField ,
159
157
} )
160
158
}
161
- className = { `ml-2 text-white ${
162
- textField . length === 0
163
- ? "bg-gray-300 cursor-default"
164
- : "bg-blue-500 hover:bg-blue-700"
165
- } rounded-md px-4 py-2`}
159
+ className = { `ml-2 text-white ${ textField . length === 0
160
+ ? "bg-gray-300 cursor-default"
161
+ : "bg-blue-500 hover:bg-blue-700"
162
+ } rounded-md px-4 py-2`}
166
163
disabled = { textField . length === 0 }
167
164
>
168
165
Post
Original file line number Diff line number Diff line change 1
1
import { Food } from "@/interfaces/Food" ;
2
+ import { Doppio_One } from "next/font/google" ;
3
+
2
4
3
5
export default function Ratings ( { food } : { food : Food } ) {
6
+ console . log ( food ) ;
4
7
return (
5
- < div >
6
- < h1 > { food && food . name } </ h1 >
7
- < h2 > Ratings</ h2 >
8
- < div >
9
- < p > Rating 1</ p >
10
- < p > Rating 2</ p >
11
- < p > Rating 3</ p >
8
+ < div className = "w-screen " > { /* Yes I know this is horribly written and inefficent -Noah*/ }
9
+ < h1 className = "flex justify-center font-normal py-2 text-xl text-[#003C6C]" >
10
+ < div className = "flex w-1/3 pl-5" >
11
+ User
12
+ </ div >
13
+ < div className = "flex w-3/2 " >
14
+ Rating
15
+ </ div >
16
+ </ h1 >
17
+
18
+ < div className = "flex flex-col justify-center " >
19
+ { /* convert ratings obj to array and map */
20
+ Object . entries ( food . ratings ) . map ( ( [ user_id , rating ] ) => (
21
+ < p key = { user_id } className = "flex flex-row justify-center pb-2 my-1 text-med" >
22
+ < div className = "px-5 flex w-1/3 border-white border bg-[#F9F9F9] font-medium text-[#003C6C]" > { user_id } </ div >
23
+ < div className = "px-5 flex w-3/2 border-white border bg-[#F9F9F9] font-medium text-gray-700" > { rating . rating } </ div >
24
+ </ p >
25
+
26
+ ) ) }
12
27
</ div >
13
28
</ div >
14
29
) ;
Original file line number Diff line number Diff line change @@ -42,13 +42,14 @@ export default function LocationFood({
42
42
) ) }
43
43
</ ul >
44
44
45
- < div >
46
- < h4 className = "flex justify-center" > { average ? average : "?" } </ h4 >
45
+ < div className = "bg-gray-200 " >
46
+
47
+ < h4 className = "flex justify-center px-2" > Score: { average ? average : "?" } </ h4 >
47
48
</ div >
48
49
< div >
49
- < h4 className = "flex justify-center" >
50
- < form >
51
- < select
50
+ < h4 className = "flex justify-center pl-2 " >
51
+ < form className = "text-center" >
52
+ < select className = " text-center py-0.5 px-2 w-20"
52
53
name = "rating"
53
54
id = "rating"
54
55
onChange = { ( e ) =>
@@ -58,16 +59,17 @@ export default function LocationFood({
58
59
food_rating : parseInt ( e . target . value ) ,
59
60
} ) . then ( ( data ) => {
60
61
const newAverage = data . average ;
62
+ food_average = newAverage ;
61
63
setAverage ( newAverage ) ;
62
64
} )
63
65
}
64
66
>
65
- < option value = { user_rating ? user_rating : 5 } >
66
- { user_rating ? user_rating : "Rate " }
67
+ < option className = "font-sans" value = { user_rating ? user_rating : 5 } >
68
+ { user_rating ? user_rating : "Rating " }
67
69
</ option >
68
70
{ ratings . map ( ( rating , index ) => (
69
71
< option
70
- className = "flex justify-center"
72
+ className = "flex justify-center font-sans "
71
73
key = { index }
72
74
value = { rating }
73
75
>
Original file line number Diff line number Diff line change
1
+
2
+
1
3
export interface Comment {
2
4
id : number ;
3
5
user_id : string ;
@@ -6,9 +8,12 @@ export interface Comment {
6
8
}
7
9
8
10
export interface Rating {
9
- user_id : string ;
10
11
rating : number ;
11
- date : string ;
12
+
13
+ }
14
+
15
+ export interface Ratings {
16
+ [ user_id : string ] : Rating ;
12
17
}
13
18
14
19
export interface Image {
@@ -21,6 +26,6 @@ export interface Food {
21
26
name : string ;
22
27
restrictions : Array < string > | never [ ] ;
23
28
comments : Array < Comment > | never [ ] ;
24
- ratings : Array < Rating > | never [ ] ;
29
+ ratings : Ratings | never [ ] ;
25
30
images : Array < Image > | never [ ] ;
26
31
}
You can’t perform that action at this time.
0 commit comments