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

Show file tree
Hide file tree
Changes from all commits
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
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"chai-http": "^4.4.0",
"cloudinary": "^2.2.0",
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"coverage": "^0.4.1",
"coveralls": "^3.1.1",
Expand Down Expand Up @@ -122,6 +123,7 @@
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/compression": "^1.7.5",
"@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.6",
Expand Down
32 changes: 20 additions & 12 deletions src/databases/migrations/20240704115209-create-termsAndCondition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ export default {
up: async (queryInterface: QueryInterface) => {
await queryInterface.createTable("termsAndConditions", {

id: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true,
defaultValue: DataTypes.UUIDV4
},
content: {
id: {
type: DataTypes.UUID,
allowNull: false,
type: DataTypes.STRING
},
type: {
primaryKey: true,
defaultValue: DataTypes.UUIDV4
},
content: {
allowNull: true,
type: DataTypes.TEXT
},
type: {
type: DataTypes.STRING,
allowNull: true
},
allowNull: false
},
pdfUrl: {
type: DataTypes.STRING,
allowNull: true,
unique: true,
validate: {
isUrl: true
}
},
createdAt: {
allowNull: false,
type: DataTypes.DATE,
Expand Down
16 changes: 13 additions & 3 deletions src/databases/models/termsAndCodition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export interface ITermsAndConditions {
id: string;
content:string;
type: string;
pdfUrl: string;
}
class TermsAndConditions extends Model<ITermsAndConditions> implements ITermsAndConditions {
declare id: string;
declare content: string;
declare type: string;
declare pdfUrl: string;

static associate() {

Expand All @@ -29,12 +31,20 @@ TermsAndConditions.init(
defaultValue: DataTypes.UUIDV4
},
content: {
allowNull: false,
type: DataTypes.STRING,
allowNull: true,
type: DataTypes.TEXT,
},
type: {
type: DataTypes.STRING,
allowNull: true
allowNull: false
},
pdfUrl:{
type: DataTypes.STRING,
allowNull: true,
unique: true,
validate:{
isUrl: true
}
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions src/databases/seeders/20240520202759-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const userFour = {
passwordUpdatedAt: new Date(),
firstName: "F Seller",
lastName: "L Seller",
email: "seller@gmail.com",
email: "aimegetz@gmail.com",
password: hashPassword("Password@123"),
phone: 25089767099,
profilePicture: "https://res.cloudinary.com/djrmfg6k9/image/upload/v1720294521/cce1ffu7uw3j2vg9s2vl.jpg",
Expand All @@ -109,7 +109,7 @@ const userFive = {
passwordUpdatedAt: new Date(),
firstName: "dj5090",
lastName: "dj2090",
email: "dj@gmail.com",
email: "jadowacu@gmail.com",
password: hashPassword("Password@123"),
phone: 25089767899,
profilePicture: "https://res.cloudinary.com/djrmfg6k9/image/upload/v1720294521/cce1ffu7uw3j2vg9s2vl.jpg",
Expand All @@ -130,7 +130,7 @@ const userSix = {
passwordUpdatedAt: new Date(),
firstName: "F Seller3",
lastName: "L Seller3",
email: "seller3@gmail.com",
email: "ndahimana154@gmail.com",
password: hashPassword("Password@123"),
phone: 25089767899,
profilePicture: "https://res.cloudinary.com/djrmfg6k9/image/upload/v1720294521/cce1ffu7uw3j2vg9s2vl.jpg",
Expand All @@ -151,7 +151,7 @@ const userSeven = {
passwordUpdatedAt: new Date(),
firstName: "F Seller4",
lastName: "L Seller4",
email: "seller4@gmail.com",
email: "ijbapte@gmail.com",
password: hashPassword("Password@123"),
phone: 25089767899,
profilePicture: "https://res.cloudinary.com/djrmfg6k9/image/upload/v1720294521/cce1ffu7uw3j2vg9s2vl.jpg",
Expand Down
30 changes: 16 additions & 14 deletions src/databases/seeders/20240601224834-shops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,60 @@ import { shopFiveId, shopFourId, shopOneId, shopSixId, shopThreeId, shopTwoId, u

const shopOne = {
id: shopOneId,
name: "Paccy Shop 250",
name: "GadgetHub 250",
userId: userFourId,
description: "Selling",
description: "Your one-stop shop for the latest gadgets and electronics.",
createdAt: new Date(),
updatedAt: new Date()
}

const shopTwo = {
id: shopTwoId,
name: "Paccy Shop 509",
name: "UrbanStyle Boutique",
userId: userSevenId,
description: "Selling",
description: "Bringing you the trendiest fashion and accessories in town.",
createdAt: new Date(),
updatedAt: new Date()
}

const shopThree = {
id: shopThreeId,
name: "Shoes Shop 509",
name: "SoleMates",
userId: userFourTeenId,
description: "Selling",
description: "Premium footwear for every step of your journey.",
createdAt: new Date(),
updatedAt: new Date()
}

const shopFour = {
id: shopFourId,
name: "electronic Shop 509",
name: "TechNest",
userId: userSixId,
description: "Selling",
description: "Explore a world of cutting-edge electronics and accessories.",
createdAt: new Date(),
updatedAt: new Date()
}

const shopFive = {
id: shopFiveId,
name: "Shop 509",
name: "HomeEssentials",
userId: userFiveId,
description: "Selling",
description: "Everything you need to make your house a home.",
createdAt: new Date(),
updatedAt: new Date()
}

const shopSix = {
id: shopSixId,
name: "electronics Shop 509",
name: "ElectroMart",
userId: userFiveTeenId,
description: "Selling",
description: "Your trusted source for all things electronic.",
createdAt: new Date(),
updatedAt: new Date()
}


export const up = async (queryInterface: QueryInterface) => {
await queryInterface.bulkInsert("shops", [shopOne, shopTwo,shopThree,shopFour, shopFive, shopSix]);
await queryInterface.bulkInsert("shops", [shopOne, shopTwo, shopThree, shopFour, shopFive, shopSix]);
};

export const down = async (queryInterface: QueryInterface) => {
Expand Down
2 changes: 1 addition & 1 deletion src/databases/seeders/20240601224835-products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const productTwo = {
description: "A women's bag is a fashionable and functional accessory designed to carry personal belongings. Available in various styles, sizes, and materials, women's bags cater to diverse needs and preferences. From elegant clutches and chic handbags to spacious totes and practical backpacks, each type serves a unique purpose. High-quality women's bags offer a blend of style, durability, and convenience, making them essential for everyday use, special occasions, and professional settings.",
price: 19.99,
discount: "13%",
category: "Handbags:",
category: "Handbags",
expiryDate: new Date("2050-12-31"),
expired: false,
bonus: "Bonus 1",
Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import express, { Express, Request, Response, NextFunction } from "express";
import cookieParser from "cookie-parser";
import dotenv from "dotenv";
import morgan from "morgan";
import compression from "compression";
Expand All @@ -19,7 +20,7 @@ const app: Express = express();
const PORT = process.env.PORT;
const server = createServer(app);

const allowedOrigins = ["http://localhost:5000" , "https://e-commerce-ninja-fn-staging.netlify.app"];
const allowedOrigins = ["http://localhost:5000" , "https://e-commerce-ninjas.netlify.app"];

export const io = new Server(server, {
cors: {
Expand All @@ -42,7 +43,11 @@ app.use((req: Request, res: Response, next: NextFunction) => {

app.use(morgan(process.env.NODE_EN));
app.use(compression());
app.use(cors());
app.use(cookieParser());
app.use(cors({
origin:allowedOrigins,
credentials:true
}));

app.use("/api-docs", SwaggerUi.serve, SwaggerUi.setup(Document));
app.use("/api", router);
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ export const socketAuthMiddleware = async (socket: Socket, next: NextFunction) =
err.data = { message: "Internal server error" };
return next(err);
}
};
};
29 changes: 17 additions & 12 deletions src/middlewares/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,33 +1049,37 @@ const isSellerRequestExist = async (
const role = req.user.role;
let existingRequest = null;
let user = null;
if(req.params.userId){
user = await userRepositories.findUserById(req.params.userId)
}

switch (role) {
case "admin":
const requestCount = await db.SellerProfile.count();

if (requestCount === 0) {
return res.status(httpStatus.NOT_FOUND).json({
status: httpStatus.NOT_FOUND,
message: "No seller requests found",
});
}
if(req.params.userId){
existingRequest = await userRepositories.findSellerRequestByUserId(req.params.userId);
if (!existingRequest) {
return res.status(httpStatus.NOT_FOUND).json({
status: httpStatus.NOT_FOUND,
message: "No seller requests found for the provided user ID",
});

if (req.params.userId) {
existingRequest = await userRepositories.findSellerRequestByUserId(req.params.userId);
user = await userRepositories.findUserById(req.params.userId);

if (!existingRequest) {
return res.status(httpStatus.NOT_FOUND).json({
status: httpStatus.NOT_FOUND,
message: "No seller requests found for the provided user ID",
});
}

req.user = user;
}
}
break;

case "buyer":
const userId = req.user.id || req.params.userId;
existingRequest = await userRepositories.findSellerRequestByUserId(userId);

if (existingRequest) {
return res.status(httpStatus.BAD_REQUEST).json({
status: httpStatus.BAD_REQUEST,
Expand All @@ -1090,7 +1094,7 @@ const isSellerRequestExist = async (
message: "Invalid role or request",
});
}
req.user = user

next();
} catch (error) {
return res.status(httpStatus.INTERNAL_SERVER_ERROR).json({
Expand All @@ -1100,6 +1104,7 @@ const isSellerRequestExist = async (
}
};


const isRequestAcceptedOrRejected = (req: any, res: Response, next: NextFunction) => {
try {
const { requestStatus } = req.body;
Expand Down
3 changes: 1 addition & 2 deletions src/modules/auth/controller/authControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const registerSeller = async (req: Request, res: Response): Promise<void> => {
const { firstName, lastName, email, password, phone, businessName, businessDescription, Tin, mobileNumber, mobilePayment, bankPayment, bankAccount, bankName,terms } = req.body;
if (req.file) {
const result = await uploadImages(req.file);
console.log(result)

req.body.rdbDocument = result.secure_url;
}

Expand All @@ -59,7 +59,6 @@ const registerSeller = async (req: Request, res: Response): Promise<void> => {
phone,
role: "seller",
}
console.log(userInfo)

const sellerData = {
businessName,
Expand Down
1 change: 0 additions & 1 deletion src/modules/auth/repository/authRepositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Op } from "sequelize";
import db from "../../../databases/models";

const createUser = async (body: any) => {
console.log("body" + JSON.stringify(body))
return await db.Users.create(body);
};

Expand Down
Loading
Loading