-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ft submit seller request 187904713 (#87)
* initial commit * Delivers-[ft-submit-seller-request-#187904713] * Delivers[ft-admin-get-seller-requests-#187904754]
- Loading branch information
Showing
17 changed files
with
568 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/databases/migrations/20240704115208-create-sellerRequests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* eslint-disable comma-dangle */ | ||
import { QueryInterface, DataTypes } from "sequelize"; | ||
|
||
export = { | ||
up: async (queryInterface: QueryInterface) => { | ||
await queryInterface.createTable("sellerRequests", { | ||
id: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
primaryKey: true, | ||
defaultValue: DataTypes.UUIDV4, | ||
}, | ||
userId: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
references: { | ||
model: "users", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE", | ||
}, | ||
requestStatus: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
defaultValue: "Pending", | ||
}, | ||
createdAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
updatedAt: { | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
}); | ||
}, | ||
|
||
down: async (queryInterface: QueryInterface) => { | ||
await queryInterface.dropTable("sellerRequests"); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* eslint-disable quotes */ | ||
/* eslint-disable comma-dangle */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable require-jsdoc */ | ||
import { Model, DataTypes, Optional } from "sequelize"; | ||
import sequelizeConnection from "../config/db.config"; | ||
import Users from "./users"; | ||
|
||
export interface SellerRequestAttributes { | ||
id: string; | ||
userId: string; | ||
requestStatus: string; | ||
createdAt?: Date; | ||
updatedAt?: Date; | ||
} | ||
|
||
export interface SellerRequestCreationAttributes extends Optional<SellerRequestAttributes, "id"> {} | ||
|
||
class SellerRequest extends Model<SellerRequestAttributes, SellerRequestCreationAttributes> implements SellerRequestAttributes { | ||
declare id: string; | ||
declare userId: string; | ||
declare requestStatus: string; | ||
declare createdAt?: Date; | ||
declare updatedAt?: Date; | ||
|
||
static associate() { | ||
SellerRequest.belongsTo(Users, { foreignKey: "userId", as: "user" }); | ||
} | ||
} | ||
|
||
SellerRequest.init( | ||
{ | ||
id: { | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
primaryKey: true, | ||
}, | ||
userId: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
}, | ||
requestStatus: { | ||
type: DataTypes.STRING(128), | ||
allowNull: false, | ||
defaultValue: "Pending", | ||
}, | ||
createdAt: { | ||
field: "createdAt", | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
updatedAt: { | ||
field: "updatedAt", | ||
type: DataTypes.DATE, | ||
allowNull: false, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
}, | ||
{ | ||
sequelize: sequelizeConnection, | ||
tableName: "sellerRequests", | ||
timestamps: true, | ||
modelName: "SellerRequest", | ||
} | ||
); | ||
|
||
export default SellerRequest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ import { | |
userEightId, | ||
userNineId, | ||
userTenId, | ||
userElevenId | ||
userElevenId, | ||
userTwelveId | ||
} from "../../types/uuid"; | ||
|
||
const userOne = { | ||
|
@@ -243,6 +244,28 @@ const userEleven = { | |
is2FAEnabled: false, | ||
}; | ||
|
||
const userTwelve = { | ||
id: userTwelveId, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
passwordUpdatedAt: new Date(), | ||
firstName: "New", | ||
lastName: "Admin", | ||
email: "[email protected]", | ||
password: hashPassword("AdminPassword@123"), | ||
phone: 25089767999, | ||
profilePicture: "", | ||
gender: "male", | ||
birthDate: "1-1-1980", | ||
language: "english", | ||
currency: "USD", | ||
role: "admin", | ||
status: "enabled", | ||
isVerified: true, | ||
is2FAEnabled: false, | ||
}; | ||
|
||
|
||
export const up = (queryInterface: QueryInterface) => | ||
queryInterface.bulkInsert("users", [ | ||
userOne, | ||
|
@@ -255,7 +278,8 @@ export const up = (queryInterface: QueryInterface) => | |
userEight, | ||
userNine, | ||
userTen, | ||
userEleven | ||
userEleven, | ||
userTwelve | ||
]); | ||
|
||
export const down = async (queryInterface: QueryInterface) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.