Skip to content

Commit 72aa518

Browse files
committed
feat(client,searchengine,matches):integrated searchengine, matches to client
1 parent eb762ec commit 72aa518

File tree

30 files changed

+312
-179
lines changed

30 files changed

+312
-179
lines changed

SearchEngine/src/index.js

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const dbConnect = require('./lib/mongo');
55
const cors = require('cors');
66
const UserSchema = require('./schema/userModel');
77
const cookieparser = require('cookie-parser');
8+
const jwt = require('jsonwebtoken');
9+
const UserModel = require('./schema/userModel');
10+
const SearchBulk = require('./controller/searchBulk');
811
require('dotenv').config();
912
app.use(cors(
1013
{
@@ -17,11 +20,101 @@ app.use(cookieparser());
1720
const port = process.env.PORT || 3000;
1821

1922
app.get('/', (req, res) => {
20-
res.send('Hello World!');
23+
res.json({
24+
message: 'SearchEngine service reached',
25+
method: 'GET',
26+
});
2127
});
2228
const searchBulk = require('./controller/searchBulk');
2329
app.post('/', async (req, res) => {
24-
searchBulk(req, res);
30+
// SearchBulk(req, res);
31+
const token = req.body.token.value; // cookie
32+
const decodedToken = jwt.decode(token, process.env.JWT_SECRET); // decodedToken = {serial,email}
33+
try {
34+
const userdata = await UserModel.find({serial: decodedToken.serial.toString()});
35+
const lookingFor = userdata[0].lookingFor;
36+
const locations = userdata[0].location;
37+
const preferences = userdata[0].preferences;
38+
const locationArray = locations.split(',');
39+
const preferencesArray = preferences.split(',');
40+
console.log(req.body.Query);
41+
if (req.body.Query.location === true && req.body.Query.preference === false) {
42+
const SearchLocation = await UserModel.find(
43+
{
44+
gender: lookingFor,
45+
location: {$regex: locationArray[0], $options: 'i'},
46+
});
47+
res.json({
48+
message: 'SearchEngine service reached',
49+
data: SearchLocation,
50+
});
51+
}
52+
if (req.body.Query.location === false && req.body.Query.preference === true) {
53+
const SearchLocation = await UserModel.find(
54+
{
55+
gender: lookingFor,
56+
preferences: {$regex: preferencesArray[0], $options: 'i'},
57+
},
58+
);
59+
res.json({
60+
message: 'SearchEngine service reached',
61+
data: SearchLocation,
62+
});
63+
}
64+
if (req.body.Query.location === true && req.body.Query.preference === true) {
65+
const SearchLocation = await UserModel.find(
66+
{
67+
gender: lookingFor,
68+
location: {$regex: locationArray[0], $options: 'i'},
69+
preferences: {$regex: preferencesArray[0], $options: 'i'},
70+
},
71+
);
72+
res.json({
73+
message: 'SearchEngine service reached',
74+
data: SearchLocation,
75+
});
76+
}
77+
if (req.body.Query.location === false && req.body.Query.preference === false) {
78+
const SearchLocation = await UserModel.find(
79+
{
80+
gender: lookingFor,
81+
},
82+
);
83+
res.json({
84+
message: 'SearchEngine service reached',
85+
data: SearchLocation,
86+
});
87+
}
88+
} catch (err) {
89+
res.json({
90+
message: 'SearchBulk',
91+
data: [],
92+
});
93+
}
94+
});
95+
96+
app.post('/random', async (req, res) => {
97+
try {
98+
const token = req.body.token.value
99+
const decoded = jwt.decode(token, process.env.JWT_SECRET);
100+
const userdata = await UserModel.find({serial: decoded.serial.toString()});
101+
const lookingFor = userdata[0].lookingFor;
102+
const SearchLocation = await UserModel.find(
103+
{
104+
gender: lookingFor,
105+
},
106+
);
107+
res.json({
108+
message: 'SearchEngine service reached',
109+
data: SearchLocation,
110+
});
111+
} catch (err) {
112+
console.log(err);
113+
res.json({
114+
message: 'SearchBulk',
115+
data: [],
116+
});
117+
}
25118
});
26119

27120
app.listen(port, () => {

auth/__pycache__/app.cpython-310.pyc

0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

blogs/__pycache__/app.cpython-310.pyc

0 Bytes
Binary file not shown.

cdn/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/images
2+
images

client/src/app/choices/SearchAndSort.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ export default function SearchAndSort(): JSX.Element {
122122
<Link href={`profiles?id=${item.serial}`} key={index}>
123123
<CustomCards data={
124124
{
125-
title: item.name,
126-
img: item.profileImage,
127-
age: item.age
125+
name: item.name,
126+
profileImage: item.profileImage,
127+
age: item.age,
128+
location: item.location
128129
}
129130
}/>
130131
</Link>

client/src/app/choices/page.tsx

Lines changed: 5 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import CustomCard from '@/components/Cards/CustomCards';
22
import SearchAndSort from './SearchAndSort';
33
import type {Metadata} from 'next';
4+
import RandomChoices from './randomChoices';
45
export const metadata: Metadata = {
56
title: {
67
template: 'Choices',
@@ -9,90 +10,7 @@ export const metadata: Metadata = {
910
description: 'Choices for your wedding partner and wedding planning',
1011
}
1112
export default function index(): JSX.Element {
12-
const categories = [
13-
{
14-
title: "Photography",
15-
img: "https://nextui.org/images/hero-card-complete.jpeg",
16-
price: "$5.50",
17-
},
18-
{
19-
title: "Videography",
20-
img: "https://nextui.org/images/album-cover.png",
21-
price: "$3.00",
22-
},
23-
{
24-
title: "Makeup",
25-
img: "https://nextui.org/images/fruit-8.jpeg",
26-
price: "$10.00",
27-
},
28-
{
29-
title: "Catering",
30-
img: "https://nextui.org/images/fruit-5.jpeg",
31-
price: "$5.30",
32-
},
33-
{
34-
title: "Decoration",
35-
img: "https://nextui.org/images/fruit-3.jpeg",
36-
price: "$15.70",
37-
},
38-
{
39-
title: "Music",
40-
img: "https://nextui.org/images/fruit-1.jpeg",
41-
price: "$8.00",
42-
},
43-
{
44-
title: "Venue",
45-
img: "https://nextui.org/images/card-example-3.jpeg",
46-
price: "$7.50",
47-
},
48-
{
49-
title: "Dress",
50-
img: "https://nextui.org/images/card-example-2.jpeg",
51-
price: "$12.20",
52-
},
53-
]
54-
const list = [
55-
{
56-
title: "Orange",
57-
img: "https://nextui.org/images/hero-card-complete.jpeg",
58-
price: "$5.50",
59-
},
60-
{
61-
title: "Tangerine",
62-
img: "https://nextui.org/images/album-cover.png",
63-
price: "$3.00",
64-
},
65-
{
66-
title: "Raspberry",
67-
img: "https://nextui.org/images/fruit-8.jpeg",
68-
price: "$10.00",
69-
},
70-
{
71-
title: "Lemon",
72-
img: "https://nextui.org/images/fruit-5.jpeg",
73-
price: "$5.30",
74-
},
75-
{
76-
title: "Avocado",
77-
img: "https://nextui.org/images/fruit-3.jpeg",
78-
price: "$15.70",
79-
},
80-
{
81-
title: "Lemon 2",
82-
img: "https://nextui.org/images/fruit-1.jpeg",
83-
price: "$8.00",
84-
},
85-
{
86-
title: "Banana",
87-
img: "https://nextui.org/images/card-example-3.jpeg",
88-
price: "$7.50",
89-
},
90-
{
91-
title: "Watermelon",
92-
img: "https://nextui.org/images/card-example-2.jpeg",
93-
price: "$12.20",
94-
},
95-
];
13+
9614
return(
9715
<div className='container mx-auto px-auto my-10'>
9816
<div className='flex flex-col my-2'>
@@ -107,33 +25,15 @@ export default function index(): JSX.Element {
10725
<div className='flex flex-col'>
10826
From your location
10927
{/* render only three elements from the list */}
110-
{
111-
list.slice(0,3).map((item, index) => (
112-
<div key={index}>
113-
<CustomCard data={item} />
114-
</div>
115-
))
116-
}
28+
<RandomChoices/>
11729
</div>
11830
<div className='flex flex-col'>
11931
Matches your Preferences
120-
{
121-
list.slice(5,8).map((item, index) => (
122-
<div key={index}>
123-
<CustomCard data={item} />
124-
</div>
125-
))
126-
}
32+
<RandomChoices/>
12733
</div>
12834
<div className='flex flex-col'>
12935
Recommended
130-
{
131-
list.slice(2,5).map((item, index) => (
132-
<div key={index}>
133-
<CustomCard data={item} />
134-
</div>
135-
))
136-
}
36+
<RandomChoices/>
13737
</div>
13838
</div>
13939
</div>

0 commit comments

Comments
 (0)