Skip to content

Commit

Permalink
Merge pull request #9 from sahrohit/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sahrohit authored Sep 9, 2023
2 parents 8e6f5a1 + 5700652 commit 5d33014
Show file tree
Hide file tree
Showing 75 changed files with 1,333 additions and 413 deletions.
37 changes: 33 additions & 4 deletions apps/admin/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,20 @@ export type Cart = {
export type CreateOrderInput = {
addressId: Scalars["Float"];
promoCode: Scalars["String"];
shippingMethod: Scalars["String"];
shippingId: Scalars["Float"];
};

export type CreatePaymentResponse = {
__typename?: "CreatePaymentResponse";
amt?: Maybe<Scalars["Int"]>;
paymentUrl?: Maybe<Scalars["String"]>;
pdc?: Maybe<Scalars["Int"]>;
pid?: Maybe<Scalars["String"]>;
provider: Scalars["String"];
psc?: Maybe<Scalars["Int"]>;
scd?: Maybe<Scalars["String"]>;
tAmt?: Maybe<Scalars["Int"]>;
txAmt?: Maybe<Scalars["Int"]>;
};

export type Discount = {
Expand Down Expand Up @@ -121,8 +134,8 @@ export type Mutation = {
addToFavourite: Favourite;
changePassword: UserResponse;
clearCart: Scalars["Boolean"];
createOrder: Scalars["String"];
createPayment: Scalars["String"];
createOrder: OrderDetail;
createPayment: CreatePaymentResponse;
deleteAddress: Scalars["Boolean"];
deleteCategory: Scalars["Boolean"];
deleteDiscount?: Maybe<Scalars["Boolean"]>;
Expand Down Expand Up @@ -187,6 +200,7 @@ export type MutationCreateOrderArgs = {

export type MutationCreatePaymentArgs = {
orderId: Scalars["String"];
provider: Scalars["String"];
};

export type MutationDeleteAddressArgs = {
Expand Down Expand Up @@ -271,7 +285,8 @@ export type MutationUpdateReviewArgs = {

export type MutationUpdateStatusArgs = {
orderId: Scalars["String"];
pidx: Scalars["String"];
pidx?: InputMaybe<Scalars["String"]>;
refId?: InputMaybe<Scalars["String"]>;
};

export type MutationVerifyEmailArgs = {
Expand All @@ -289,6 +304,8 @@ export type OrderDetail = {
paymentdetails?: Maybe<Array<PaymentDetail>>;
promo?: Maybe<Promo>;
promoId?: Maybe<Scalars["Int"]>;
shipping: ShippingMethod;
shippingId: Scalars["Int"];
status: Scalars["String"];
updated_at: Scalars["String"];
userId: Scalars["Int"];
Expand Down Expand Up @@ -456,6 +473,7 @@ export type Query = {
fetchCartItems?: Maybe<Array<Cart>>;
hello: Scalars["String"];
me?: Maybe<User>;
meWithAccount?: Maybe<User>;
orderById?: Maybe<OrderDetail>;
orders?: Maybe<Array<OrderDetail>>;
product?: Maybe<Product>;
Expand All @@ -468,6 +486,7 @@ export type Query = {
reviews?: Maybe<Array<ProductReview>>;
roles: Array<UserRole>;
searchProducts?: Maybe<Array<Product>>;
shippingmethods: Array<ShippingMethod>;
variants: Array<Variant>;
};

Expand Down Expand Up @@ -524,6 +543,16 @@ export type ReviewSummaryResponse = {
rating?: Maybe<Scalars["Float"]>;
};

export type ShippingMethod = {
__typename?: "ShippingMethod";
created_at: Scalars["String"];
dispatch_in: Scalars["Int"];
id: Scalars["Int"];
name: Scalars["String"];
price: Scalars["Int"];
updated_at: Scalars["String"];
};

export type UpdateCategoryInput = {
desc?: InputMaybe<Scalars["String"]>;
identifier?: InputMaybe<Scalars["String"]>;
Expand Down
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"ioredis": "^4.28.5",
"joi": "^17.9.2",
"jsonwebtoken": "^9.0.2",
"nanoid": "3.3.4",
"nodemailer": "^6.9.4",
"pg": "^8.11.2",
"reflect-metadata": "^0.1.13",
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export const COMPANY = {
country: "Nepal",
};
export const GOOGLE_OAUTH_REDIRECT_URL = `${process.env.API_URL}/auth/google/callback`;
export const ESEWA_MERCHANT_CODE = "EPAYTEST";
4 changes: 4 additions & 0 deletions apps/api/src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { Promo } from "./entities/Promo";
import { Favourite } from "./entities/Favourite";
import { ProductReview } from "./entities/ProductReview";
import { Account } from "./entities/Account";
import { ShippingMethod } from "./entities/ShippingMethod";
import { Tenant } from "./entities/Tenant";

export const AppDataSource = new DataSource({
type: "postgres",
Expand Down Expand Up @@ -48,6 +50,8 @@ export const AppDataSource = new DataSource({
Favourite,
ProductReview,
Account,
ShippingMethod,
Tenant,
],
migrations: ["dist/migration/**/*.js"],
subscribers: [],
Expand Down
9 changes: 9 additions & 0 deletions apps/api/src/entities/OrderDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { PaymentDetail } from "./PaymentDetail";
import { User } from "./User";
import { Promo } from "./Promo";
import { Address } from "./Address";
import { ShippingMethod } from "./ShippingMethod";

export type OrderStatus =
| "PENDING"
Expand Down Expand Up @@ -51,6 +52,14 @@ export class OrderDetail extends BaseEntity {
@ManyToOne(() => Address, (address) => address.orderdetails)
address!: Address;

@Field(() => Int)
@Column()
shippingId!: number;

@Field(() => ShippingMethod)
@ManyToOne(() => ShippingMethod, (shipping) => shipping.orderdetails)
shipping!: ShippingMethod;

@Field(() => Int, { nullable: true })
@Column({ nullable: true })
promoId!: number;
Expand Down
42 changes: 42 additions & 0 deletions apps/api/src/entities/ShippingMethod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Field, Int, ObjectType } from "type-graphql";
import {
Entity,
PrimaryGeneratedColumn,
CreateDateColumn,
UpdateDateColumn,
BaseEntity,
Column,
OneToMany,
} from "typeorm";
import { OrderDetail } from "./OrderDetail";

@ObjectType()
@Entity()
export class ShippingMethod extends BaseEntity {
@Field(() => Int)
@PrimaryGeneratedColumn()
id!: number;

@Field()
@Column()
name!: string;

@Field(() => Int)
@Column()
price!: number;

@Field(() => Int)
@Column()
dispatch_in!: number;

@OneToMany(() => OrderDetail, (orderdetails) => orderdetails.address)
orderdetails!: OrderDetail[];

@Field(() => String)
@CreateDateColumn()
created_at = new Date();

@Field(() => String)
@UpdateDateColumn()
updated_at = new Date();
}
71 changes: 71 additions & 0 deletions apps/api/src/entities/Tenant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Field, Int, ObjectType } from "type-graphql";
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
BaseEntity,
ManyToOne,
} from "typeorm";
import { User } from "./User";

@ObjectType()
@Entity()
export class Tenant extends BaseEntity {
@Field(() => Int)
@PrimaryGeneratedColumn()
id!: number;

@Field()
@Column()
name!: string;

@Field()
@Column()
desc!: string;

@Field()
@Column({
nullable: true,
default:
"https://tailwindcss.com/_next/static/media/tailwindcss-mark.3c5441fc7a190fb1800d4a5c7f07ba4b1345a9c8.svg",
})
logo?: string;

@Field()
@Column({
nullable: true,
default: "Popins",
})
font?: string;

@Field()
@Column()
subdomain!: string;

@Field()
@Column({ nullable: true })
customDomain?: string;

@Field()
@Column({
default: false,
})
defaultForPreview!: boolean;

@Field()
@Column()
userId!: number;

@ManyToOne(() => User, (user) => user.addresses)
user!: User;

@Field(() => String)
@CreateDateColumn()
created_at = new Date();

@Field(() => String)
@UpdateDateColumn()
updated_at = new Date();
}
4 changes: 4 additions & 0 deletions apps/api/src/entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { UserPayment } from "./UserPayment";
import { UserRole } from "./UserRole";
import { ProductReview } from "./ProductReview";
import { Account } from "./Account";
import { Tenant } from "./Tenant";

@ObjectType()
@Entity()
Expand Down Expand Up @@ -71,6 +72,9 @@ export class User extends BaseEntity {
@OneToMany(() => Address, (address) => address.user)
addresses!: Address[];

@OneToMany(() => Tenant, (tenant) => tenant.user)
tenants!: Tenant[];

@OneToMany(() => OrderDetail, (orderdetails) => orderdetails.user)
orderdetails!: OrderDetail[];

Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import Redis from "ioredis";
import { Product } from "./entities/Product";
import { InvoiceResolver } from "./resolvers/invoice";
import authRouter from "./routers/auth";
import tenantRouter from "./routers/tenant";
import { ShippingMethodResolver } from "./resolvers/shipping";

const Server = async () => {
AppDataSource.initialize()
Expand Down Expand Up @@ -81,6 +83,7 @@ const Server = async () => {
});

app.use("/auth", authRouter);
app.use("/tenant", tenantRouter);

app.get("/products", async (_req, res) => {
res.json(
Expand Down Expand Up @@ -123,6 +126,7 @@ const Server = async () => {
FavouriteResolver,
ReviewResolver,
InvoiceResolver,
ShippingMethodResolver,
],
validate: false,
}),
Expand Down
34 changes: 32 additions & 2 deletions apps/api/src/resolvers/GqlObjets/OrderInput.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InputType, Field, ObjectType } from "type-graphql";
import { InputType, Field, ObjectType, Int } from "type-graphql";

@InputType()
export class CreateOrderInput {
Expand All @@ -9,7 +9,7 @@ export class CreateOrderInput {
addressId!: number;

@Field()
shippingMethod!: string;
shippingId!: number;
}

@ObjectType()
Expand All @@ -26,3 +26,33 @@ export class CreateOrderResponse {
@Field()
provider!: string;
}

@ObjectType()
export class CreatePaymentResponse {
@Field()
provider!: string;

@Field(() => Int, { nullable: true })
amt?: number;

@Field(() => Int, { nullable: true })
psc?: number;

@Field(() => Int, { nullable: true })
pdc?: number;

@Field(() => Int, { nullable: true })
txAmt?: number;

@Field(() => Int, { nullable: true })
tAmt?: number;

@Field(() => String, { nullable: true })
pid?: string;

@Field(() => String, { nullable: true })
scd?: string;

@Field(() => String, { nullable: true })
paymentUrl?: string;
}
Loading

2 comments on commit 5d33014

@vercel
Copy link

@vercel vercel bot commented on 5d33014 Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ecommerce-admin-client – ./apps/admin

ecommerce-admin-client-git-main-sahrohit.vercel.app
ecommerce-admin-client-sahrohit.vercel.app
ecommerce-admin-client.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 5d33014 Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.