Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #120

Merged
merged 59 commits into from
Aug 26, 2024
Merged

Fixes #120

Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
f9108f8
rebase
AimePazzo Jun 1, 2024
56c3ce6
Merge pull request #44 from atlp-rwanda/ft-admin
AimePazzo Jun 1, 2024
281b3b8
rebase
AimePazzo Jun 1, 2024
8a315e8
Merge pull request #45 from atlp-rwanda/ft-admin
AimePazzo Jun 1, 2024
9c65028
Ft login v google 187584916 (#47)
Jadowacu1 Jun 4, 2024
5a3356d
Logout feature (#26) (#46)
MANISHIMWESalton Jun 4, 2024
dad2ece
[Finishes #187584924] Seller Create/Add a product (#48)
AimePazzo Jun 6, 2024
dac5a4c
Logout feature (#26)
solangeihirwe03 May 31, 2024
91a286e
Fixed login fetaure (#59)
ProgrammerDATCH Jun 7, 2024
96e83ed
Ft delete items seller #187584926 (#52)
solangeihirwe03 Jun 7, 2024
8ae4ea1
[starts #187584911] Seller statistics per timeframe (#54)
ProgrammerDATCH Jun 8, 2024
5978342
Ft update password 187584920 (#56)
hbapte Jun 9, 2024
73bae0f
Ft seller available products 187584925 (#49)
SaddockAime Jun 9, 2024
99c7974
Ft seller update items 187584929 (#51)
Fabrice-Dush Jun 10, 2024
d82b834
Ft 2 fa v2 187584919 (#60)
Y-elv Jun 10, 2024
041ed3d
The Seller and User - list products (#58)
ndahimana154 Jun 11, 2024
50ad8dc
Ft buyer view cart 187584934 (#64)
ProgrammerDATCH Jun 13, 2024
1b2c1d9
User Search Products by FIlters (#65)
ndahimana154 Jun 16, 2024
5a60d80
ft-view-specific-item (#63)
Jadowacu1 Jun 17, 2024
e0f43f5
[starts #187584933] Add & Update cart (#70)
ProgrammerDATCH Jun 18, 2024
6982bda
Users should be able to chat on the App to ask some information publi…
AimePazzo Jun 18, 2024
939338e
User Search Products by FIlters (#65) (#71)
Jadowacu1 Jun 18, 2024
0c3479a
ft clear wishList (#75)
Jadowacu1 Jun 19, 2024
b1fa94d
adding cron job to products (#76)
Y-elv Jun 20, 2024
41b358f
Ft buyer clear cart 187584935 (#66)
Fabrice-Dush Jun 20, 2024
5863c70
ft buyer view products from wishList (#79)
Jadowacu1 Jun 21, 2024
a6cdec4
ft: password-expiry-check-#187584942 (#72)
hbapte Jun 22, 2024
86c3302
[Delivers-18758493] ft-buyer-checkout (#77)
MANISHIMWESalton Jun 22, 2024
987c6bf
Fixed calculation of cart (#80)
ProgrammerDATCH Jun 23, 2024
dc27e45
[Deliver-18758493] ft-fix-checkout (#82)
MANISHIMWESalton Jun 24, 2024
563cd8a
[Fixes #187584929] (#84)
Fabrice-Dush Jun 25, 2024
1de31f6
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
AimePazzo Jun 26, 2024
bdb7c02
[Delivers #187584943] ft-notifications (#68)
SaddockAime Jun 26, 2024
f370e49
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
AimePazzo Jun 26, 2024
0496ccb
Ft mark one or all notification as read (#69)
SaddockAime Jun 26, 2024
5a71f0f
merged
AimePazzo Jun 26, 2024
f1bb7f1
Ft add product reviews #187584931 (#73)
solangeihirwe03 Jun 27, 2024
6ab42d3
[Delivers #187584943] ft-notifications (#68) (#85)
Jadowacu1 Jul 1, 2024
853bef4
[Delivers-18758498] ft-buyer-stripe-payment (#78)
MANISHIMWESalton Jul 2, 2024
bb06e4b
fx-product-seeders (#88)
SaddockAime Jul 8, 2024
6ce7a6e
Ft submit seller request 187904713 (#87)
hbapte Jul 9, 2024
74b0c1e
Fix product response (#91)
ProgrammerDATCH Jul 11, 2024
7ca7d44
Fx notification route (#93)
SaddockAime Jul 12, 2024
4e31410
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
AimePazzo Jul 3, 2024
512a554
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Jul 12, 2024
5b3a076
fix password expiry check (#92)
hbapte Jul 12, 2024
fd0ff22
Fix passsword expiration check for google login accounts (#95)
hbapte Jul 16, 2024
938c14d
Fix codebase structure (#90)
ndahimana154 Jul 16, 2024
eb92726
Ft buyer track order status #187584937 (#74)
solangeihirwe03 Jul 16, 2024
925bc91
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Jul 18, 2024
580814e
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Aug 4, 2024
0869546
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Aug 5, 2024
4756042
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Aug 5, 2024
5428ed3
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Aug 5, 2024
1026490
Merge branch 'fixes' of github.com:atlp-rwanda/e-commerce-ninjas-bn i…
Aime-Patrick Aug 5, 2024
67f0888
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Aug 5, 2024
4e58074
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Aug 9, 2024
aa86fd2
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Aug 19, 2024
4817a27
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Aime-Patrick Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
User Search Products by FIlters (#65)
* [delivers #187584936] User filter products

* mend

* mend

* mend

* [delivers #187584936] Update the search logic

* Re-test

* mend

* mend

* mend
ndahimana154 authored Jun 16, 2024
commit 1b2c1d9614bb58d2c89830b49d664d72a5af7ae9
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ Our e-commerce web application server, developed by Team Ninjas, facilitates smo
- Seller update product status Endpoint
- Seller get products Endpoint
- User get product Endpoint
- User search products Endpoint
- Buyer get cart Endpoint

## TABLE OF API ENDPOINTS SPECIFICATION AND DESCRIPTION
@@ -81,7 +82,8 @@ Our e-commerce web application server, developed by Team Ninjas, facilitates smo
| 24 | PUT | /api/shop/seller-update-product-status/:id | 200 OK | private | Seller update product status |
| 25 | GET | /api/shop/seller-get-products | 200 OK | private | Seller get products |
| 26 | GET | /api/shop/user-get-products | 200 OK | public | User get product |
| 27 | GET | /api/cart/buyer-get-cart | 200 OK | private | Buyer get cart |
| 27 | GET | /api/shop/user-search-products | 200 OK | public | User search products |
| 28 | GET | /api/cart/buyer-get-cart | 200 OK | private | Buyer get cart |

## INSTALLATION

23 changes: 22 additions & 1 deletion src/databases/seeders/20240520202759-users.ts
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import {
userSixId,
userSevenId,
userEightId,
userNineId
} from "../../types/uuid";

const userOne = {
@@ -170,17 +171,37 @@ const userEight = {
isVerified: true,
is2FAEnabled: false
}
const userNine = {
id: userNineId,
createdAt: new Date(),
updatedAt: new Date(),
firstName: "IR Buyer2",
lastName: "U Buyer2",
email: "invalidroleuser@gmail.com",
password: hashPassword("Password@123"),
phone: 25089767809,
profilePicture: "",
gender: "male",
birthDate: "2-2-2014",
language: "english",
currency: "USD",
role: "nurse",
status: "enabled",
isVerified: true,
is2FAEnabled: false
}

export const up = (queryInterface: QueryInterface) =>
queryInterface.bulkInsert("users", [
userOne,
userOne,
userTwo,
userThree,
userFour,
userFive,
userSix,
userSeven,
userEight,
userNine
]);

export const down = async (queryInterface: QueryInterface) => {
3 changes: 1 addition & 2 deletions src/middlewares/authorization.ts
Original file line number Diff line number Diff line change
@@ -48,10 +48,9 @@ export const userAuthorization = function (roles: string[]) {
}

if (!roles.includes(user.role)) {
res
return res
.status(httpStatus.UNAUTHORIZED)
.json({ status: httpStatus.UNAUTHORIZED, message: "Not authorized" });
return;
}

req.user = user;
74 changes: 68 additions & 6 deletions src/middlewares/validation.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,11 @@ import Shops from "../databases/models/shops";
import Products from "../databases/models/products";
import { ExtendRequest } from "../types";
import { sendEmail } from "../services/sendEmail";
import { Op } from "sequelize";


const currentDate = new Date();

import cartRepositories from "../modules/cart/repositories/cartRepositories";
import db from "../databases/models";

@@ -386,7 +391,7 @@ const isGoogleEnabled = async (req: any, res: Response, next: NextFunction) => {

const isCartExist = async (req: any, res: Response, next: NextFunction) => {
const cart = await cartRepositories.getCartByUserId(req.user.id);
if(!cart) return res.status(httpStatus.NOT_FOUND).json({ status: httpStatus.NOT_FOUND, message: "Cart not found. Please add items to your cart." })
if (!cart) return res.status(httpStatus.NOT_FOUND).json({ status: httpStatus.NOT_FOUND, message: "Cart not found. Please add items to your cart." })
return next();
}

@@ -404,16 +409,73 @@ const isPaginated = (req: any, res: Response, next: NextFunction) => {
};


const isSearchFiltered = (req: ExtendRequest, res: Response, next: NextFunction) => {
const name = req.query.name || undefined;
const category = req.query.category || undefined;
const description = req.query.description || undefined;
const minPrice = req.query.minprice || undefined;
const maxPrice = req.query.maxprice || undefined;

const searchQuery: any = { where: {} };

if ((minPrice && !maxPrice) || (!minPrice && maxPrice)) {
return res.status(httpStatus.BAD_REQUEST).json({
status: httpStatus.BAD_REQUEST,
message: "Minimum and maximum price are required"
});
}

if (Number(minPrice) > Number(maxPrice)) {
return res.status(httpStatus.BAD_REQUEST).json({
status: httpStatus.BAD_REQUEST,
message: "Minimum Price must be less than Maximum price"
});
}

const orConditions = [];

if (name !== undefined) orConditions.push({ name: { [Op.iLike]: `%${name}%` } });
if (category !== undefined) orConditions.push({ category });
if (description !== undefined) orConditions.push({ description: { [Op.iLike]: `%${description}%` } });
if (minPrice !== undefined && maxPrice !== undefined) {
orConditions.push({
price: {
[Op.gte]: minPrice,
[Op.lte]: maxPrice
}
});
}

if (orConditions.length > 0) {
searchQuery.where[Op.or] = orConditions;
}
searchQuery.where.status = "available";
searchQuery.where.expiryDate = {
[Op.gte]: currentDate
};

req.searchQuery = searchQuery;
return next();
};

export {
validation,
isUserExist,
isAccountVerified,
verifyUserCredentials, isUsersExist,
isProductExist, isShopExist,
transformFilesToBody, credential,
isSessionExist, verifyUser, isGoogleEnabled,
isUserEnabled, isUserVerified, isSellerShopExist,
verifyUserCredentials,
isUsersExist,
isProductExist,
isShopExist,
transformFilesToBody,
credential,
isSessionExist,
verifyUser,
isGoogleEnabled,
isUserEnabled,
isUserVerified,
isSellerShopExist,
verifyOtp,
isPaginated,
isSearchFiltered,
isCartExist
};
Loading