Skip to content

Commit

Permalink
fix: product query
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmann7 committed Mar 3, 2024
1 parent c65c75b commit 96a502f
Show file tree
Hide file tree
Showing 22 changed files with 385 additions and 551 deletions.
168 changes: 0 additions & 168 deletions drizzle/schema.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/(dashboard)/dashboard/billing/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { env } from "@/env.js"
import { CheckIcon } from "@radix-ui/react-icons"

import { storeSubscriptionPlans } from "@/config/subscriptions"
import { getCacheduser } from "@/lib/fetchers/auth"
import { getCacheduser } from "@/lib/actions/auth"
import { getSubscriptionPlan } from "@/lib/fetchers/stripe"
import { cn, formatDate, formatPrice } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { redirect } from "next/navigation"

import { dashboardConfig } from "@/config/dashboard"
import { getCacheduser } from "@/lib/fetchers/auth"
import { getCacheduser } from "@/lib/actions/auth"
import { ScrollArea } from "@/components/ui/scroll-area"
import { SidebarNav } from "@/components/layouts/sidebar-nav"
import { SiteFooter } from "@/components/layouts/site-footer"
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/dashboard/purchases/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { env } from "@/env.js"
import type { SearchParams } from "@/types"
import { and, asc, desc, eq, inArray, like, sql } from "drizzle-orm"

import { getCacheduser } from "@/lib/fetchers/auth"
import { getCacheduser } from "@/lib/actions/auth"
import { getUserEmail } from "@/lib/utils"
import { purchasesSearchParamsSchema } from "@/lib/validations/params"
import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/dashboard/stores/[storeId]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { db } from "@/db"
import { stores } from "@/db/schema"
import { eq } from "drizzle-orm"

import { getCacheduser } from "@/lib/fetchers/auth"
import { getCacheduser } from "@/lib/actions/auth"
import { getSubscriptionPlan } from "@/lib/fetchers/stripe"
import { getDashboardRedirectPath } from "@/lib/subscription"
import {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/dashboard/stores/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Metadata } from "next"
import { redirect } from "next/navigation"
import { env } from "@/env.js"

import { getCacheduser } from "@/lib/fetchers/auth"
import { getCacheduser } from "@/lib/actions/auth"
import {
Card,
CardContent,
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/dashboard/stores/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { redirect } from "next/navigation"
import { env } from "@/env.js"
import { RocketIcon } from "@radix-ui/react-icons"

import { getCacheduser } from "@/lib/fetchers/auth"
import { getCacheduser } from "@/lib/actions/auth"
import { getUserStores } from "@/lib/fetchers/store"
import { getSubscriptionPlan } from "@/lib/fetchers/stripe"
import { getDashboardRedirectPath, getPlanFeatures } from "@/lib/subscription"
Expand Down
2 changes: 1 addition & 1 deletion src/app/(lobby)/_components/category-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react"
import Link from "next/link"
import type { Category } from "@/types"

import { getProductCount } from "@/lib/fetchers/product"
import { getProductCount } from "@/lib/actions/product"
import {
Card,
CardContent,
Expand Down
4 changes: 2 additions & 2 deletions src/app/(lobby)/_components/lobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Link from "next/link"

import { productCategories } from "@/config/products"
import { siteConfig } from "@/config/site"
import { type getGithubStars } from "@/lib/fetchers/github"
import { type getFeaturedProducts } from "@/lib/fetchers/product"
import { type getGithubStars } from "@/lib/actions/github"
import { type getFeaturedProducts } from "@/lib/actions/product"
import { type getFeaturedStores } from "@/lib/fetchers/store"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
Expand Down
4 changes: 2 additions & 2 deletions src/app/(lobby)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react"

import { getGithubStars } from "@/lib/fetchers/github"
import { getFeaturedProducts } from "@/lib/fetchers/product"
import { getGithubStars } from "@/lib/actions/github"
import { getFeaturedProducts } from "@/lib/actions/product"
import { getFeaturedStores } from "@/lib/fetchers/store"

import { Lobby } from "./_components/lobby"
Expand Down
6 changes: 3 additions & 3 deletions src/components/forms/add-product-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { type z } from "zod"
import { getSubcategories } from "@/config/products"
import { addProduct, checkProduct } from "@/lib/actions/product"
import { catchError, isArrayOfFile } from "@/lib/utils"
import { productSchema } from "@/lib/validations/product"
import { newProductSchema } from "@/lib/validations/product"
import { Button } from "@/components/ui/button"
import {
Form,
Expand Down Expand Up @@ -43,7 +43,7 @@ interface AddProductFormProps {
storeId: number
}

type Inputs = z.infer<typeof productSchema>
type Inputs = z.infer<typeof newProductSchema>

const { useUploadThing } = generateReactHelpers<OurFileRouter>()

Expand All @@ -55,7 +55,7 @@ export function AddProductForm({ storeId }: AddProductFormProps) {
const { isUploading, startUpload } = useUploadThing("productImage")

const form = useForm<Inputs>({
resolver: zodResolver(productSchema),
resolver: zodResolver(newProductSchema),
defaultValues: {
name: "",
description: "",
Expand Down
2 changes: 1 addition & 1 deletion src/components/products-command-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function ProductsCommandMenu() {

async function fetchData() {
try {
const data = await filterProducts(debouncedQuery)
const { data } = await filterProducts({ query: debouncedQuery })
setData(data)
} catch (err) {
catchError(err)
Expand Down
9 changes: 4 additions & 5 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export const stores = mysqlTable("stores", {
id: varchar("id", { length: 128 })
.$defaultFn(() => createId())
.primaryKey(),
userId: varchar("user_id", { length: 255 }).notNull(),
userId: varchar("user_id", { length: 255 }).notNull().unique(),
name: varchar("name", { length: 191 }).notNull(),
description: text("description"),
slug: text("slug"),
slug: text("slug").unique(),
active: boolean("active").notNull().default(false),
stripeAccountId: varchar("stripe_account_id", { length: 255 }),
createdAt: timestamp("created_at").defaultNow().notNull(),
Expand Down Expand Up @@ -95,13 +95,12 @@ export const notifications = mysqlTable("notifications", {
id: varchar("id", { length: 128 })
.$defaultFn(() => createId())
.primaryKey(),
userId: varchar("user_id", { length: 255 }),
userId: varchar("user_id", { length: 255 }).unique(),
email: varchar("email", { length: 191 }).notNull().unique(),
token: varchar("token", { length: 191 }).notNull().unique(),
referredBy: varchar("referred_by", { length: 191 }),
newsletter: boolean("newsletter").default(false).notNull(),
marketing: boolean("marketing").default(false).notNull(),
transactional: boolean("transactional").default(false).notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").onUpdateNow(),
})
Expand All @@ -113,7 +112,7 @@ export const subscriptions = mysqlTable("subscriptions", {
id: varchar("id", { length: 128 })
.$defaultFn(() => createId())
.primaryKey(),
userId: varchar("user_id", { length: 255 }).unique().notNull(),
userId: varchar("user_id", { length: 255 }).notNull().unique(),
stripeSubscriptionId: varchar("stripe_subscription_id", { length: 255 }),
stripePriceId: varchar("stripe_price_id", { length: 255 }),
stripeCustomerId: varchar("stripe_customer_id", { length: 255 }),
Expand Down
4 changes: 2 additions & 2 deletions src/db/seed.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { seedRealProducts } from "@/lib/actions/product"
import { seedRealProducts } from "@/lib/actions/seed"

async function runSeed() {
console.log("⏳ Running seed...")

const start = Date.now()

await seedRealProducts({ storeId: 1 })
await seedRealProducts({ storeId: "flh0ii4" })

const end = Date.now()

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 96a502f

Please sign in to comment.