Skip to content

Commit

Permalink
feat: add json to public folder
Browse files Browse the repository at this point in the history
  • Loading branch information
chertik77 committed Feb 16, 2025
1 parent 6cf2f3a commit f837d81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
File renamed without changes.
17 changes: 14 additions & 3 deletions src/shared/components/RadioInputBgImages.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import type { BoardTypes } from '@/shared/api/board'
import type { UserTypes } from '@/shared/api/user'
import type { Control } from 'react-hook-form'

import { Item, Root } from '@radix-ui/react-radio-group'
import { useQuery } from '@tanstack/react-query'
import { Controller } from 'react-hook-form'

import images from '@/features/board/data/board-bg-images.json'

import { useAuthStore } from '@/shared/store'

type BoardImages = {
id: string
icon: string | Record<UserTypes.Theme, string>
}[]

type RadioInputBgImagesProps = {
control: Control<BoardTypes.BoardSchema>
}

export const RadioInputBgImages = ({ control }: RadioInputBgImagesProps) => {
const theme = useAuthStore(state => state.user.theme)

const { data: boardImages } = useQuery<BoardImages>({
queryKey: ['board-bg-images'],
queryFn: async () =>
await fetch('/board-bg-images.json').then(res => res.json())
})

return (
<>
<p className='mt-6'>Background</p>
Expand All @@ -25,7 +36,7 @@ export const RadioInputBgImages = ({ control }: RadioInputBgImagesProps) => {
<Root
className='mb-10 mt-3.5 flex max-w-[280px] flex-wrap gap-2'
onValueChange={field.onChange}>
{images.map(({ id, icon }) => (
{boardImages?.map(({ id, icon }) => (
<Item
checked={field.value === id}
value={id}
Expand Down

0 comments on commit f837d81

Please sign in to comment.