Skip to content

Commit 99c884c

Browse files
added cuisine counter
1 parent dcd366f commit 99c884c

File tree

8 files changed

+366
-33
lines changed

8 files changed

+366
-33
lines changed

client/zomdata/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import Dashboard from './components/Dashboard';
55
import Homesearch from './components/Homesearch';
66
import Zomnav from './components/Zomnav';
77
import Presaved from './components/Presaved';
8-
import Showtable from './components/Showtable';
98
import Home from './components/Home';
9+
import Test from './components/Test';
1010

1111
function App() {
1212
return (
@@ -17,7 +17,7 @@ function App() {
1717
<Route path='/search' element={<><Homesearch /></>} />
1818
<Route path='/dashboard/:key' element={<Dashboard />} />
1919
<Route path='/saved' element={<Presaved />} />
20-
<Route path='/test' element={<Showtable />} />
20+
<Route path='/test' element={<Test />} />
2121
</Route>
2222
</Routes>
2323
</Router>

client/zomdata/src/Context.tsx

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,118 @@ const Context: FC<ParentCompProps> = ({ children }) => {
2323
ratebox: "0.0",
2424
cuisine: [],
2525
splitarr: "none"
26-
})
26+
});
27+
28+
2729

2830

2931
return (
30-
<Head.Provider value={{ toggleFilterbox, setToggleFilterbox, filterobj, setfilterobj }}>{children}</Head.Provider>
32+
<Head.Provider value={{ cuisines, toggleFilterbox, setToggleFilterbox, filterobj, setfilterobj }}>{children}</Head.Provider>
3133
)
3234
}
3335

36+
const cuisines = [
37+
"Afghan",
38+
"African",
39+
"American",
40+
"Andhra",
41+
"Arabian",
42+
"Asian",
43+
"Delight Goodies",
44+
"Awadhi",
45+
"BBQ",
46+
"Bakery",
47+
"Bangladeshi",
48+
"Belgian",
49+
"Bengali",
50+
"Bihari",
51+
"Biryani",
52+
"Bubble Tea",
53+
"Burger",
54+
"Burmese",
55+
"Cantonese",
56+
"Charcoal Chicken",
57+
"Chettinad",
58+
"Chinese",
59+
"Coffee",
60+
"Continental",
61+
"Desserts",
62+
"Egyptian",
63+
"European",
64+
"Fast Food",
65+
"Finger Food",
66+
"French",
67+
"Frozen Yogurt",
68+
"Goan",
69+
"Gujarati",
70+
"Healthy Food",
71+
"Hot dogs",
72+
"Hyderabadi",
73+
"Ice Cream",
74+
"Indonesian",
75+
"Iranian",
76+
"Irish",
77+
"Italian",
78+
"Japanese",
79+
"Juices",
80+
"Kashmiri",
81+
"Kathiyawadi",
82+
"Kebab",
83+
"Kerala",
84+
"Konkan",
85+
"Korean",
86+
"Lebanese",
87+
"Lucknowi",
88+
"Maharashtrian",
89+
"Malaysian",
90+
"Mandi",
91+
"Mangalorean",
92+
"Mediterranean",
93+
"Mexican",
94+
"Middle Eastern",
95+
"Mishti",
96+
"Mithai",
97+
"Modern Indian",
98+
"Momos",
99+
"Mughlai",
100+
"Naga",
101+
"Nepalese",
102+
"North Eastern",
103+
"North Indian",
104+
"Oriental",
105+
"Paan",
106+
"Pakistani",
107+
"Pancake",
108+
"Panini",
109+
"Retail Products",
110+
"Parsi",
111+
"Pasta",
112+
"Pizza",
113+
"Rajasthani",
114+
"Roast Chicken",
115+
"Rolls",
116+
"Salad",
117+
"Sandwich",
118+
"Seafood",
119+
"Shake",
120+
"Shawarma",
121+
"Sichuan",
122+
"Singaporean",
123+
"South American",
124+
"South Indian",
125+
"Spanish",
126+
"Sri Lankan",
127+
"Steak",
128+
"Sushi",
129+
"Tamil",
130+
"Tea",
131+
"Tex-Mex",
132+
"Thai",
133+
"Tibetan",
134+
"Turkish",
135+
"Vietnamese",
136+
"Waffle",
137+
"Wraps"
138+
];
139+
34140
export default Context
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React, { FC } from 'react'
2+
import { Bar } from 'react-chartjs-2'
3+
import { Chart, registerables } from 'chart.js'
4+
Chart.register(...registerables);
5+
6+
7+
interface data {
8+
labels: string[],
9+
datasets: [{
10+
label: string,
11+
data: number[]
12+
}]
13+
}
14+
15+
type mydata = {
16+
catData: data
17+
}
18+
19+
20+
const Cusinechar: FC<mydata> = ({ catData }: mydata) => {
21+
return (
22+
<Bar data={catData} />
23+
)
24+
}
25+
26+
export default Cusinechar

client/zomdata/src/components/Dashboard.tsx

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { FC, useContext, useEffect, useState } from 'react'
22
import { useParams } from 'react-router-dom'
33
import { Head } from '../Context'
44
import Barchart from './Barchart'
5+
import Cusinechar from './Cusinechar'
56
import Filter from './Filter'
67
import Filterbox from './Filterbox'
78
import Footer from './Footer'
@@ -21,7 +22,8 @@ interface chartData {
2122

2223
interface filterobjtype {
2324
filterobj: filterobjtype2
24-
setfilterobj: (x: any) => any
25+
setfilterobj: (x: any) => any,
26+
cuisines: [string]
2527
}
2628

2729
interface filterobjtype2 {
@@ -35,7 +37,7 @@ interface filterobjtype2 {
3537

3638
const Dashboard: FC = () => {
3739

38-
const { filterobj } = useContext(Head) as filterobjtype;
40+
const { filterobj, cuisines } = useContext(Head) as filterobjtype;
3941

4042
const [mydata, setmydata] = useState<any>([]);
4143
const [analytics, setanalytics] = useState<any>({
@@ -64,7 +66,22 @@ const Dashboard: FC = () => {
6466
})
6567

6668

67-
// console.log(param);
69+
const [catData, setcatData] = useState<chartData>({
70+
labels: ['Chinese', 'Pizza', 'Burger'],
71+
datasets: [
72+
{
73+
label: "Cuisine provided by no. of Food sellers",
74+
data: [1, 2, 3],
75+
backgroundColor: [
76+
'rgb(255, 99, 132)',
77+
'rgb(54, 162, 235)',
78+
'rgb(255, 205, 86)'
79+
],
80+
hoverOffset: 4
81+
}
82+
]
83+
})
84+
6885

6986
useEffect(() => {
7087

@@ -204,8 +221,43 @@ const Dashboard: FC = () => {
204221

205222
setmydata(reso);
206223

207-
console.log(reso);
208-
});
224+
// console.log(reso);
225+
return reso;
226+
})
227+
.then((reso: any) => {
228+
229+
let mapp = new Map();
230+
231+
let temp = reso.map((el: any) => el.categories.map((la: any) => la.trim()));
232+
// console.log(temp);
233+
234+
for (var n of cuisines) {
235+
let value = 0;
236+
for (let i = 0; i < reso.length; i++) {
237+
if (temp[i].includes(n)) {
238+
mapp.set(n, ++value);
239+
}
240+
}
241+
}
242+
243+
mapp = new Map([...mapp.entries()].sort((a, b) => b[1] - a[1]));
244+
console.log(mapp);
245+
console.log(reso)
246+
setcatData({
247+
labels: [...mapp.keys()],
248+
datasets: [
249+
{
250+
label: "Cuisine sellers",
251+
data: [...mapp.values()],
252+
backgroundColor: [
253+
'#0d47a1'
254+
],
255+
hoverOffset: 4
256+
}
257+
]
258+
})
259+
260+
})
209261
return alldone;
210262
}
211263

@@ -230,6 +282,9 @@ const Dashboard: FC = () => {
230282
<section className=' my-40 md:px-20 px-6'>
231283
<Barchart chartData={userData} />
232284
</section>
285+
<section className=' my-40 md:px-20 px-6'>
286+
<Cusinechar catData={catData} />
287+
</section>
233288
<section className=' my-40'>
234289
<Showtable mydata={mydata} />
235290
</section>

client/zomdata/src/components/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const Home = () => {
4646
<h2 className=' text-6xl font-bold mb-9'>2 Steps only</h2>
4747
<ul className=' font-light leading-7'>
4848
<li className=' mb-3'>
49-
Just a single step , paste the zomato's website url of the desired location then click on search button.
49+
First, paste the zomato's website url of the desired location then click on search button.
5050
</li>
5151
<li>
5252
Now, wait for some time to get data, then save it with a unique name

client/zomdata/src/components/Savename.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useRef } from 'react'
2+
import { useNavigate } from 'react-router-dom';
23

34
interface savename {
45
setnamebool: (x: boolean) => any,
@@ -8,11 +9,14 @@ interface savename {
89

910
const Savename = ({ setnamebool, wholedatafood }: savename) => {
1011

12+
const navigate = useNavigate();
13+
1114
const inputRef = useRef<HTMLInputElement>(null);
1215

1316
function handlesubmit() {
1417
localStorage.setItem(`${(inputRef.current?.value as string).trim()}`, JSON.stringify(wholedatafood));
1518
setnamebool(false);
19+
navigate(`/dashboard/${(inputRef.current?.value as string).trim()}`);
1620
// setsavename();
1721
}
1822

client/zomdata/src/components/Showtable.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,34 @@ import React from 'react'
33
const Showtable = ({ mydata }: any) => {
44
return (
55

6-
<div className=' lg:px-20'>
6+
<div className=' lg:px-20 overflow-x-scroll sm:overflow-auto'>
77
<table className=' border-[1px] w-full text-left'>
8-
<tr className=' border-b-[1px] even:bg-blue-100'>
9-
<th className=' px-4 py-4 bg-blue-500 text-white font-bold'>Name</th>
10-
<th className=' px-4 py-4 bg-blue-500 text-white font-bold'>Rate</th>
11-
<th className=' px-4 py-4 bg-blue-500 text-white font-bold'>Cuisine</th>
12-
<th className=' px-4 py-4 bg-blue-500 text-white font-bold'>Orders</th>
13-
</tr>
14-
{
15-
mydata.map((el: any) => {
16-
return (
8+
<tbody>
9+
<tr className=' border-b-[1px] even:bg-blue-100'>
10+
<th className=' px-4 py-4 bg-blue-500 text-white font-bold'>Name</th>
11+
<th className=' px-4 py-4 bg-blue-500 text-white font-bold'>Rate</th>
12+
<th className=' px-4 py-4 bg-blue-500 text-white font-bold'>Cuisine</th>
13+
<th className=' px-4 py-4 bg-blue-500 text-white font-bold'>Orders</th>
14+
</tr>
15+
{
16+
mydata.map((el: any, index: number) => {
17+
return (
1718

18-
<tr className=' hover:shadow hover:shadow-gray-400 border-b-[1px] even:bg-blue-100'>
19+
<tr key={index} className=' hover:shadow hover:shadow-gray-400 border-b-[1px] even:bg-blue-100 w-full'>
1920

20-
<td className=' px-4 py-4 text-blue-500 font-bold'>
21-
<a target="_blank" rel="noopener noreferrer" href={el.link}>
22-
{el.ventureName}
23-
</a>
24-
</td>
25-
<td className=' px-4 py-4'>{el.rating}</td>
26-
<td className=' px-4 pt-4 flex flex-wrap text-white'>{el.categories.map((la: any, index: number) => (el.categories[el.categories.length - 1] !== la) ? <span className=' px-2 py-1 rounded-md bg-blue-500 mr-2 mb-4' key={index}>{la}, </span> : <span className=' px-2 py-1 rounded-md bg-blue-500 mr-2 mb-4' key={index}>{la}</span>)}</td>
27-
<td className=' px-4 py-4'>{el.numberOfOrders}</td>
28-
</tr>
29-
)
30-
})
31-
}
21+
<td className=' px-4 py-4 text-blue-500 font-bold'>
22+
<a target="_blank" rel="noopener noreferrer" href={el.link}>
23+
{el.ventureName}
24+
</a>
25+
</td>
26+
<td className=' px-4 py-4'>{el.rating}</td>
27+
<td className=' px-4 pt-4 flex flex-wrap text-white'>{el.categories.map((la: any, index: number) => (el.categories[el.categories.length - 1] !== la) ? <span className=' px-2 py-1 rounded-md bg-blue-500 mr-2 mb-4' key={index}>{la}, </span> : <span className=' px-2 py-1 rounded-md bg-blue-500 mr-2 mb-4' key={index}>{la}</span>)}</td>
28+
<td className=' px-4 py-4'>{el.numberOfOrders}</td>
29+
</tr>
30+
)
31+
})
32+
}
33+
</tbody>
3234

3335
</table>
3436
</div>

0 commit comments

Comments
 (0)