Skip to content

Commit

Permalink
feat(root): ✨ added help center with minor oauth changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sahrohit committed Sep 11, 2023
1 parent 2a21917 commit f826a21
Show file tree
Hide file tree
Showing 29 changed files with 2,028 additions and 45 deletions.
6 changes: 6 additions & 0 deletions apps/api/src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { ProductReview } from "./entities/ProductReview";
import { Account } from "./entities/Account";
import { ShippingMethod } from "./entities/ShippingMethod";
import { Tenant } from "./entities/Tenant";
import { Issue } from "./entities/Issue";
import { IssueCategory } from "./entities/IssueCategory";
import { IssueComment } from "./entities/IssueComment";

export const AppDataSource = new DataSource({
type: "postgres",
Expand Down Expand Up @@ -52,6 +55,9 @@ export const AppDataSource = new DataSource({
Account,
ShippingMethod,
Tenant,
Issue,
IssueCategory,
IssueComment,
],
migrations: ["dist/migration/**/*.js"],
subscribers: [],
Expand Down
108 changes: 108 additions & 0 deletions apps/api/src/entities/Issue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Field, Int, ObjectType } from "type-graphql";
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
BaseEntity,
ManyToOne,
JoinTable,
OneToMany,
} from "typeorm";
import { User } from "./User";
import { IssueCategory } from "./IssueCategory";
import { IssueComment } from "./IssueComment";

export const POSSIBLE_ISSUE_STATUS = [
"SUBMITTED",
"OPEN",
"IN_PROGRESS",
"ON_HOLD",
"CLOSED",
"REJECTED",
"RESOLVED_BY_CUSTOMER",
"PENDING_CUSTOMER_RESPONSE",
];

export type IssueStatus =
| "SUBMITTED"
| "OPEN"
| "IN_PROGRESS"
| "ON_HOLD"
| "CLOSED"
| "REJECTED"
| "RESOLVED_BY_CUSTOMER"
| "PENDING_CUSTOMER_RESPONSE";

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

@Field(() => String)
@Column()
subject!: string;

@Field(() => String)
@Column({
type: "text",
})
content!: string;

@Field(() => String, {
nullable: true,
})
@Column({
type: "text",
nullable: true,
})
html?: string;

@Field(() => String)
@Column({
type: "enum",
enum: POSSIBLE_ISSUE_STATUS,
default: "SUBMITTED",
})
status!: IssueStatus;

@Field(() => [IssueComment], { nullable: true })
@OneToMany(() => IssueComment, (comment) => comment.issue)
@JoinTable({ name: "comment_id" })
comments?: IssueComment[];

@Field(() => String, { nullable: true })
@Column({
type: "timestamp with time zone",
nullable: true,
})
completed_at?: string;

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

@Field(() => IssueCategory)
@ManyToOne(() => IssueCategory, (category) => category.issues)
@JoinTable({ name: "category_id" })
category!: IssueCategory;

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

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

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

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

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

@Field(() => String)
@Column()
name!: string;

@Field(() => String)
@Column({ unique: true })
identifier!: string;

@Field(() => String)
@Column({ type: "text" })
desc!: string;

@Field(() => [Issue], { nullable: true })
@OneToMany(() => Issue, (issue) => issue.category)
@JoinTable({ name: "issue_id" })
issues?: Issue[];

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

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

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

@Field(() => String)
@Column({
type: "text",
})
content!: string;

@Field(() => String, {
nullable: true,
})
@Column({
type: "text",
nullable: true,
})
html?: string;

@Field(() => String, { nullable: true })
@Column({
type: "timestamp with time zone",
nullable: true,
})
completed_at?: string;

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

@Field(() => Issue)
@ManyToOne(() => Issue, (issue) => issue.comments)
@JoinTable({ name: "issue_id" })
issue!: Issue;

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

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

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

@Field(() => String)
@UpdateDateColumn()
updated_at = new Date();
}
18 changes: 10 additions & 8 deletions apps/api/src/entities/OrderDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ import { Promo } from "./Promo";
import { Address } from "./Address";
import { ShippingMethod } from "./ShippingMethod";

export const POSSIBLE_ORDER_STATUS = [
"PENDING",
"PLACED",
"SHIPPED",
"OUTFORDELIVERY",
"DELIVERED",
"REJECTED",
];

export type OrderStatus =
| "PENDING"
| "PLACED"
Expand Down Expand Up @@ -71,14 +80,7 @@ export class OrderDetail extends BaseEntity {
@Field(() => String)
@Column({
type: "enum",
enum: [
"PENDING",
"PLACED",
"SHIPPED",
"OUTFORDELIVERY",
"DELIVERED",
"REJECTED",
],
enum: POSSIBLE_ORDER_STATUS,
default: "PENDING",
})
status!: OrderStatus;
Expand Down
9 changes: 9 additions & 0 deletions apps/api/src/entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { UserRole } from "./UserRole";
import { ProductReview } from "./ProductReview";
import { Account } from "./Account";
import { Tenant } from "./Tenant";
import { Issue } from "./Issue";
import { IssueComment } from "./IssueComment";

@ObjectType()
@Entity()
Expand Down Expand Up @@ -76,6 +78,7 @@ export class User extends BaseEntity {
@Column({ default: 1 })
roleId!: number;

@Field(() => UserRole)
@ManyToOne(() => UserRole, (role) => role.users)
role!: UserRole;

Expand All @@ -88,6 +91,12 @@ export class User extends BaseEntity {
@OneToMany(() => Address, (address) => address.user)
addresses!: Address[];

@OneToMany(() => Issue, (issue) => issue.user)
issues!: Issue[];

@OneToMany(() => IssueComment, (comment) => comment.user)
comments!: IssueComment[];

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

Expand Down
5 changes: 3 additions & 2 deletions apps/api/src/entities/UserRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Column,
CreateDateColumn,
Entity,
OneToOne,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from "typeorm";
Expand All @@ -21,7 +21,8 @@ export class UserRole extends BaseEntity {
@Column()
name!: string;

@OneToOne(() => User, (user) => user.role)
@Field(() => [User])
@ManyToOne(() => User, (user) => user.role)
users!: User[];

@Field(() => String)
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { InvoiceResolver } from "./resolvers/invoice";
import authRouter from "./routers/auth";
import tenantRouter from "./routers/tenant";
import { ShippingMethodResolver } from "./resolvers/shipping";
import { IssueResolver } from "./resolvers/issue";

const Server = async () => {
AppDataSource.initialize()
Expand Down Expand Up @@ -127,6 +128,7 @@ const Server = async () => {
ReviewResolver,
InvoiceResolver,
ShippingMethodResolver,
IssueResolver,
],
validate: false,
}),
Expand Down
16 changes: 16 additions & 0 deletions apps/api/src/resolvers/GqlObjets/Issue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { InputType, Field } from "type-graphql";

@InputType()
export default class IssueInput {
@Field()
subject!: string;

@Field()
content!: string;

@Field()
html!: string;

@Field()
categoryId!: number;
}
Loading

2 comments on commit f826a21

@vercel
Copy link

@vercel vercel bot commented on f826a21 Sep 11, 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-sahrohit.vercel.app
ecommerce-admin-client.vercel.app
ecommerce-admin-client-git-main-sahrohit.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f826a21 Sep 11, 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.