Skip to content

Commit

Permalink
fix lint and format errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmann7 committed Dec 3, 2023
1 parent 6766b42 commit fce0b65
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RESEND_API_KEY="re_"
# Register a domain at https://resend.com/domains
# Or we can use this email provided by resend for only testing: "[email protected]"
# It is not recommended tho
EMAIL_FROM_ADDRESS="mail@[yourdomain]"
EMAIL_FROM_ADDRESS="mail@your_domain.com"

# uploadthing
UPLOADTHING_SECRET="sk_live_"
Expand Down
4 changes: 1 addition & 3 deletions .react-email/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export const inter = Inter({
variable: '--font-inter',
});

export default function RootLayout({
children,
}: React.PropsWithChildren ) {
export default function RootLayout({ children }: React.PropsWithChildren) {
return (
<html lang="en">
<body className="bg-black text-slate-12 font-sans">
Expand Down
271 changes: 160 additions & 111 deletions drizzle/schema.ts
Original file line number Diff line number Diff line change
@@ -1,119 +1,168 @@
import { mysqlTable, mysqlSchema, AnyMySqlColumn, primaryKey, serial, varchar, timestamp, json, tinyint, int, decimal, text, mysqlEnum } from "drizzle-orm/mysql-core"
import { sql } from "drizzle-orm"
import {
AnyMySqlColumn,
decimal,
int,
json,
mysqlEnum,
mysqlSchema,
mysqlTable,
primaryKey,
serial,
text,
timestamp,
tinyint,
varchar,
} from "drizzle-orm/mysql-core"

export const addresses = mysqlTable(
"addresses",
{
id: serial("id").notNull(),
line1: varchar("line1", { length: 191 }),
line2: varchar("line2", { length: 191 }),
city: varchar("city", { length: 191 }),
state: varchar("state", { length: 191 }),
postalCode: varchar("postalCode", { length: 191 }),
country: varchar("country", { length: 191 }),
createdAt: timestamp("createdAt", { mode: "string" }).defaultNow(),
},
(table) => {
return {
addressesId: primaryKey(table.id),
}
}
)

export const addresses = mysqlTable("addresses", {
id: serial("id").notNull(),
line1: varchar("line1", { length: 191 }),
line2: varchar("line2", { length: 191 }),
city: varchar("city", { length: 191 }),
state: varchar("state", { length: 191 }),
postalCode: varchar("postalCode", { length: 191 }),
country: varchar("country", { length: 191 }),
createdAt: timestamp("createdAt", { mode: 'string' }).defaultNow(),
},
(table) => {
return {
addressesId: primaryKey(table.id),
}
});
export const carts = mysqlTable(
"carts",
{
id: serial("id").notNull(),
paymentIntentId: varchar("paymentIntentId", { length: 191 }),
clientSecret: varchar("clientSecret", { length: 191 }),
items: json("items").default("null"),
createdAt: timestamp("createdAt", { mode: "string" }).defaultNow(),
closed: tinyint("closed").default(0).notNull(),
},
(table) => {
return {
cartsId: primaryKey(table.id),
}
}
)

export const carts = mysqlTable("carts", {
id: serial("id").notNull(),
paymentIntentId: varchar("paymentIntentId", { length: 191 }),
clientSecret: varchar("clientSecret", { length: 191 }),
items: json("items").default('null'),
createdAt: timestamp("createdAt", { mode: 'string' }).defaultNow(),
closed: tinyint("closed").default(0).notNull(),
},
(table) => {
return {
cartsId: primaryKey(table.id),
}
});
export const emailPreferences = mysqlTable(
"email_preferences",
{
id: serial("id").notNull(),
userId: varchar("userId", { length: 191 }),
email: varchar("email", { length: 191 }).notNull(),
token: varchar("token", { length: 191 }).notNull(),
newsletter: tinyint("newsletter").default(0).notNull(),
marketing: tinyint("marketing").default(0).notNull(),
transactional: tinyint("transactional").default(0).notNull(),
createdAt: timestamp("createdAt", { mode: "string" }).defaultNow(),
},
(table) => {
return {
emailPreferencesId: primaryKey(table.id),
}
}
)

export const emailPreferences = mysqlTable("email_preferences", {
id: serial("id").notNull(),
userId: varchar("userId", { length: 191 }),
email: varchar("email", { length: 191 }).notNull(),
token: varchar("token", { length: 191 }).notNull(),
newsletter: tinyint("newsletter").default(0).notNull(),
marketing: tinyint("marketing").default(0).notNull(),
transactional: tinyint("transactional").default(0).notNull(),
createdAt: timestamp("createdAt", { mode: 'string' }).defaultNow(),
},
(table) => {
return {
emailPreferencesId: primaryKey(table.id),
}
});
export const orders = mysqlTable(
"orders",
{
id: serial("id").notNull(),
storeId: int("storeId").notNull(),
items: json("items").default("null"),
amount: decimal("amount", { precision: 10, scale: 2 })
.default("0.00")
.notNull(),
stripePaymentIntentId: varchar("stripePaymentIntentId", {
length: 191,
}).notNull(),
stripePaymentIntentStatus: varchar("stripePaymentIntentStatus", {
length: 191,
}).notNull(),
name: varchar("name", { length: 191 }),
email: varchar("email", { length: 191 }),
addressId: int("addressId"),
createdAt: timestamp("createdAt", { mode: "string" }).defaultNow(),
quantity: int("quantity"),
},
(table) => {
return {
ordersId: primaryKey(table.id),
}
}
)

export const orders = mysqlTable("orders", {
id: serial("id").notNull(),
storeId: int("storeId").notNull(),
items: json("items").default('null'),
amount: decimal("amount", { precision: 10, scale: 2 }).default('0.00').notNull(),
stripePaymentIntentId: varchar("stripePaymentIntentId", { length: 191 }).notNull(),
stripePaymentIntentStatus: varchar("stripePaymentIntentStatus", { length: 191 }).notNull(),
name: varchar("name", { length: 191 }),
email: varchar("email", { length: 191 }),
addressId: int("addressId"),
createdAt: timestamp("createdAt", { mode: 'string' }).defaultNow(),
quantity: int("quantity"),
},
(table) => {
return {
ordersId: primaryKey(table.id),
}
});
export const payments = mysqlTable(
"payments",
{
id: serial("id").notNull(),
storeId: int("storeId").notNull(),
stripeAccountId: varchar("stripeAccountId", { length: 191 }).notNull(),
stripeAccountCreatedAt: int("stripeAccountCreatedAt"),
stripeAccountExpiresAt: int("stripeAccountExpiresAt"),
detailsSubmitted: tinyint("detailsSubmitted").default(0).notNull(),
createdAt: timestamp("createdAt", { mode: "string" }).defaultNow(),
},
(table) => {
return {
paymentsId: primaryKey(table.id),
}
}
)

export const payments = mysqlTable("payments", {
id: serial("id").notNull(),
storeId: int("storeId").notNull(),
stripeAccountId: varchar("stripeAccountId", { length: 191 }).notNull(),
stripeAccountCreatedAt: int("stripeAccountCreatedAt"),
stripeAccountExpiresAt: int("stripeAccountExpiresAt"),
detailsSubmitted: tinyint("detailsSubmitted").default(0).notNull(),
createdAt: timestamp("createdAt", { mode: 'string' }).defaultNow(),
},
(table) => {
return {
paymentsId: primaryKey(table.id),
}
});
export const products = mysqlTable(
"products",
{
id: serial("id").notNull(),
name: varchar("name", { length: 191 }).notNull(),
description: text("description"),
images: json("images").default("null"),
price: decimal("price", { precision: 10, scale: 2 })
.default("0.00")
.notNull(),
inventory: int("inventory").default(0).notNull(),
rating: int("rating").default(0).notNull(),
storeId: int("storeId").notNull(),
createdAt: timestamp("createdAt", { mode: "string" }).defaultNow(),
tags: json("tags").default("null"),
category: mysqlEnum("category", [
"skateboards",
"clothing",
"shoes",
"accessories",
])
.default("skateboards")
.notNull(),
subcategory: varchar("subcategory", { length: 191 }),
},
(table) => {
return {
productsId: primaryKey(table.id),
}
}
)

export const products = mysqlTable("products", {
id: serial("id").notNull(),
name: varchar("name", { length: 191 }).notNull(),
description: text("description"),
images: json("images").default('null'),
price: decimal("price", { precision: 10, scale: 2 }).default('0.00').notNull(),
inventory: int("inventory").default(0).notNull(),
rating: int("rating").default(0).notNull(),
storeId: int("storeId").notNull(),
createdAt: timestamp("createdAt", { mode: 'string' }).defaultNow(),
tags: json("tags").default('null'),
category: mysqlEnum("category", ['skateboards','clothing','shoes','accessories']).default('skateboards').notNull(),
subcategory: varchar("subcategory", { length: 191 }),
},
(table) => {
return {
productsId: primaryKey(table.id),
}
});

export const stores = mysqlTable("stores", {
id: serial("id").notNull(),
userId: varchar("userId", { length: 191 }).notNull(),
name: varchar("name", { length: 191 }).notNull(),
description: text("description"),
slug: text("slug"),
createdAt: timestamp("createdAt", { mode: 'string' }).defaultNow(),
active: tinyint("active").default(0).notNull(),
stripeAccountId: varchar("stripeAccountId", { length: 191 }),
},
(table) => {
return {
storesId: primaryKey(table.id),
}
});
export const stores = mysqlTable(
"stores",
{
id: serial("id").notNull(),
userId: varchar("userId", { length: 191 }).notNull(),
name: varchar("name", { length: 191 }).notNull(),
description: text("description"),
slug: text("slug"),
createdAt: timestamp("createdAt", { mode: "string" }).defaultNow(),
active: tinyint("active").default(0).notNull(),
stripeAccountId: varchar("stripeAccountId", { length: 191 }),
},
(table) => {
return {
storesId: primaryKey(table.id),
}
}
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"typecheck": "contentlayer build && tsc --noEmit",
"format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache",
"format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache",
"check": "pnpm lint && pnpm typecheck",
"check": "pnpm lint && pnpm typecheck && pnpm format:check",
"db:generate": "dotenv drizzle-kit generate:mysql",
"db:push": "dotenv drizzle-kit push:mysql",
"db:introspect": "dotenv drizzle-kit introspect:mysql",
Expand Down
5 changes: 3 additions & 2 deletions src/app/(checkout)/cart/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { currentUser } from "@clerk/nextjs"

import { SiteHeader } from "@/components/layouts/site-header"


export default async function CartLayout({ children }: React.PropsWithChildren) {
export default async function CartLayout({
children,
}: React.PropsWithChildren) {
const user = await currentUser()

if (!user) {
Expand Down
1 change: 0 additions & 1 deletion src/app/(checkout)/checkout/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { redirect } from "next/navigation"
import { currentUser } from "@clerk/nextjs"


export default async function CheckoutLayout({
children,
}: React.PropsWithChildren) {
Expand Down
1 change: 0 additions & 1 deletion src/app/(dashboard)/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { SidebarNav } from "@/components/layouts/sidebar-nav"
import { SiteFooter } from "@/components/layouts/site-footer"
import { SiteHeader } from "@/components/layouts/site-header"


export default async function DashboardLayout({
children,
}: React.PropsWithChildren) {
Expand Down
12 changes: 5 additions & 7 deletions src/app/(dashboard)/dashboard/stores/[storeId]/orders/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as React from "react"
import type { Metadata } from "next"
import { notFound } from "next/navigation"
import { db } from "@/db"
import { orders, stores, type Order } from "@/db/schema"
import { env } from "@/env.mjs"
import { and, asc, desc, eq, gte, inArray, like, lte, sql } from "drizzle-orm"
import type { Metadata } from "next"
import { notFound } from "next/navigation"
import * as React from "react"

import { ordersSearchParamsSchema } from "@/lib/validations/params"
import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"
import { DateRangePicker } from "@/components/date-range-picker"
import { OrdersTableShell } from "@/components/shells/orders-table-shell"
import { ordersSearchParamsSchema } from "@/lib/validations/params"

export const metadata: Metadata = {
metadataBase: new URL(env.NEXT_PUBLIC_APP_URL),
Expand Down Expand Up @@ -141,9 +141,7 @@ export default async function OrdersPage({
<h2 className="text-2xl font-bold tracking-tight">Orders</h2>
<DateRangePicker align="end" />
</div>
<React.Suspense
fallback={<DataTableSkeleton columnCount={6} />}
>
<React.Suspense fallback={<DataTableSkeleton columnCount={6} />}>
<OrdersTableShell
transaction={transaction}
limit={limit}
Expand Down
5 changes: 3 additions & 2 deletions src/app/(lobby)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { currentUser } from "@clerk/nextjs"
import { SiteFooter } from "@/components/layouts/site-footer"
import { SiteHeader } from "@/components/layouts/site-header"


export default async function LobbyLayout({ children }: React.PropsWithChildren ) {
export default async function LobbyLayout({
children,
}: React.PropsWithChildren) {
const user = await currentUser()

return (
Expand Down
2 changes: 1 addition & 1 deletion src/app/(lobby)/store/[storeId]/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ export default function ProductLoading() {
</div>
</Shell>
)
}
}
4 changes: 2 additions & 2 deletions src/components/data-table/data-table-column-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export function DataTableColumnHeader<TData, TValue>({
column.getIsSorted() === "desc"
? `Sorted descending. Click to sort ascending.`
: column.getIsSorted() === "asc"
? `Sorted ascending. Click to sort descending.`
: `Not sorted. Click to sort ascending.`
? `Sorted ascending. Click to sort descending.`
: `Not sorted. Click to sort ascending.`
}
variant="ghost"
size="sm"
Expand Down

1 comment on commit fce0b65

@vercel
Copy link

@vercel vercel bot commented on fce0b65 Dec 3, 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.