Skip to content

Commit

Permalink
fix(mobile): fix category id could not be parsed correctly (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkdev98 committed Jul 23, 2024
1 parent f5a614b commit 6c8c4c6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/mobile/stores/category/queries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getHonoClient } from '@/lib/client'
import { type Category, CategorySchema } from '@6pm/validation'
import { createQueryKeys } from '@lukemorales/query-key-factory'
import { z } from 'zod'

export const categoryQueries = createQueryKeys('categories', {
all: ({
Expand All @@ -15,7 +16,11 @@ export const categoryQueries = createQueryKeys('categories', {
}

const items = await res.json()
const categories = items.map((item) => CategorySchema.parse(item))
const categories = items.map((item) =>
CategorySchema.extend({
id: z.string().cuid2(),
}).parse(item),
)

setCategoriesState(categories)

Expand Down

0 comments on commit 6c8c4c6

Please sign in to comment.