Skip to content

Commit ba80c6c

Browse files
Merge branch 'main' of https://github.com/jency1/PlantWorld
2 parents 66ce6e3 + aaf16f8 commit ba80c6c

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

Backend/controllers/plantController.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,47 @@ const Plant = require('./../model/plantModel');
33

44
exports.getAllPlants = async (req, res) => {
55
try {
6-
console.log(req.query);
6+
// console.log(req.query);
77

88
// BUILD QUERY
9-
// 1)filtering
9+
// 1A)filtering
1010
const queryObj = { ...req.query };
1111
const excludedFields = ['page', 'sort', 'limit', 'fields'];
1212

1313
excludedFields.forEach((el) => delete queryObj[el]);
1414

15-
// 2)Advanced filtering
15+
// 1B)Advanced filtering
1616
let queryString = JSON.stringify(queryObj);
1717
queryString = queryString.replace(
1818
/\b(gte|gt|lte|lt)\b/g,
1919
(match) => `$${match}`
2020
);
2121

22-
console.log(JSON.parse(queryString));
22+
// console.log(JSON.parse(queryString));
2323
// mongoose {tag:'Indoor' , price:{$gte:200}}
2424
// req.query { tag: 'Indoor', price: { gte: '200' } }
2525

26-
const query = Plant.find(JSON.parse(queryString));
26+
// 2) Sorting
27+
28+
let query = Plant.find(JSON.parse(queryString));
29+
30+
if (req.query.sort) {
31+
//mongoose sort('price ratingsAverage)
32+
33+
const sortBy = req.query.sort.split(',').join(' ');
34+
query = query.sort(sortBy);
35+
} else {
36+
query = query.sort('-createdAt');
37+
}
38+
39+
// 3) Field limiting
40+
41+
if (req.query.fields) {
42+
const fields = req.query.fields.split(',').join(' ');
43+
query = query.select(fields);
44+
} else {
45+
query = query.select('-__v');
46+
}
2747

2848
// EXECUTE QUERY
2949

src/components/HomePage/FollowOnInstagram.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,53 +78,53 @@ function FollowOnInstagram() {
7878
Follow us on Instagram
7979
</div>
8080
<div
81-
className={`${styles["main-container"]} grid h-4/6 w-5/6 grid-cols-12 px-8 mx-8 mt-2 mb-5`}
81+
className={`${styles["main-container"]} grid h-full w-full md:h-4/6 md:w-5/6 grid-cols-12 px-8 mx-8 mt-2 mb-5`}
8282
>
83-
<div className="col-span-12 md:col-span-8 grid grid-cols-12">
84-
<div className="col-span-6 text-center m-1">
83+
<div className="col-span-8 grid grid-cols-12">
84+
<div className="col-span-6 text-center m-[0.1rem] md:m-1">
8585
<img
8686
src="/Shop By Category/image-1.jpg"
8787
alt=""
8888
className="w-full h-full object-cover rounded hover:shadow-lg"
8989
/>
9090
</div>
91-
<div className="col-span-6 text-center m-1 ">
91+
<div className="col-span-6 text-center m-[0.1rem] md:m-1">
9292
<img
9393
src="/Shop By Category/image-2.jpg"
9494
alt=""
9595
className="w-full h-full object-cover rounded hover:shadow-lg"
9696
/>
9797
</div>
98-
<div className="col-span-8 text-center m-1">
98+
<div className="col-span-8 text-center m-[0.1rem] md:m-1">
9999
<img
100100
src="/Shop By Category/image-3.jpg"
101101
alt=""
102102
className="w-full h-full object-cover rounded hover:shadow-lg"
103103
/>
104104
</div>
105-
<div className="col-span-4 text-center m-1 ">
105+
<div className="col-span-4 text-center m-[0.1rem] md:m-1">
106106
<img
107107
src="/Shop By Category/image-4.jpg"
108108
alt=""
109109
className="w-full h-full object-cover rounded hover:shadow-lg"
110110
/>
111111
</div>
112-
<div className="col-span-6 text-center m-1">
112+
<div className="col-span-6 text-center m-[0.1rem] md:m-1">
113113
<img
114114
src="/Shop By Category/image-5.jpg"
115115
alt=""
116116
className="w-full h-full object-cover rounded hover:shadow-lg"
117117
/>
118118
</div>
119-
<div className="col-span-6 text-center m-1">
119+
<div className="col-span-6 text-center m-[0.1rem] md:m-1">
120120
<img
121121
src="/Shop By Category/image-6.jpg"
122122
alt=""
123123
className="w-full h-full object-cover rounded hover:shadow-lg"
124124
/>
125125
</div>
126126
</div>
127-
<div className={`${styles.longImage} m-1 col-span-4 `}>
127+
<div className={`${styles.longImage} m-[0.1rem] col-span-4 md:m-1`}>
128128
<img
129129
src="/Shop By Category/long-image.jpg"
130130
alt=""

src/components/HomePage/FollowOnInstagram.module.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
}
44

55
@media only screen and (max-width: 48em) {
6-
.longImage {
6+
/* .longImage {
77
height: 0;
8-
}
8+
} */
99

1010
.main-container {
11-
padding: 0 4rem 0 4rem;
11+
padding: 0 2rem 0 2rem;
1212
}
1313
}

src/pages/LoginPage.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const LoginForm = ({ handleForgotPassword }) => (
3232
className="w-full px-[6px] py-[3px] lg:px-[12px] lg:py-[8px] mb-3 rounded border border-gray-300 text-[14px] lg:text-[16px]"
3333
/>
3434

35-
<label htmlFor="mobile" className="mb-2 text-[0.8rem] lg:text-[1.1rem]">
35+
{/* <label htmlFor="mobile" className="mb-2 text-[0.8rem] lg:text-[1.1rem]">
3636
Mobile Number:
3737
</label>
3838
<input
@@ -41,7 +41,7 @@ const LoginForm = ({ handleForgotPassword }) => (
4141
placeholder="123-456-7890"
4242
required
4343
className="w-full px-[6px] py-[3px] lg:px-[12px] lg:py-[8px] mb-3 rounded border border-gray-300 text-[14px] lg:text-[16px]"
44-
/>
44+
/> */}
4545

4646
<label htmlFor="password" className="mb-2 text-[0.8rem] lg:text-[1.1rem]">
4747
Password:
@@ -239,7 +239,7 @@ const LoginPage = () => {
239239
return (
240240
<div className="relative flex justify-center items-center min-h-screen bg-[#ecffed] p-2 md:p-4">
241241
<BackToHomeButton />
242-
<div className="flex w-[90%] md:w-[80%] max-w-[1200px] bg-white/80 rounded-[10px] shadow-lg flex-col sm:flex-row mt-10">
242+
<div className="flex w-[90%] md:w-[80%] max-w-[1200px] bg-white/80 rounded-[10px] shadow-lg flex-col sm:flex-row mt-10 mb-2 md:mt-3">
243243
<LeftSection />
244244
<RightSection
245245
isSignup={isSignup}

0 commit comments

Comments
 (0)