|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { ArrowUpDown, Plus } from 'lucide-react'; |
| 4 | +import dynamic from 'next/dynamic'; |
| 5 | +import { GetGroupStudiesSortEnum } from '@/api/openapi/api/group-study-management-api'; |
| 6 | +import Button from '@/components/common/ui/button'; |
| 7 | +import SortDropdown from '@/components/common/ui/filters/sort-dropdown'; |
| 8 | +import StudyFilter, { |
| 9 | + type StudyFilterValues, |
| 10 | +} from '@/components/filtering/study-filter'; |
| 11 | +import StudySearch from '@/components/filtering/study-search'; |
| 12 | +import type { StudyClassification } from '@/types/schemas/group-study-form.schema'; |
| 13 | + |
| 14 | +const GroupStudyFormModal = dynamic( |
| 15 | + () => import('@/components/common/modals/group-study-form-modal'), |
| 16 | + { ssr: false }, |
| 17 | +); |
| 18 | + |
| 19 | +const SORT_OPTIONS = [ |
| 20 | + { value: GetGroupStudiesSortEnum.Latest, label: '최신순' }, |
| 21 | + { value: GetGroupStudiesSortEnum.Deadline, label: '마감임박순' }, |
| 22 | + { value: GetGroupStudiesSortEnum.ViewCount, label: '조회수순' }, |
| 23 | +] as const; |
| 24 | + |
| 25 | +interface StudyListToolbarProps { |
| 26 | + title: string; |
| 27 | + classification: StudyClassification; |
| 28 | + isAuthReady: boolean; |
| 29 | + controls: { |
| 30 | + searchQuery: string; |
| 31 | + filterValues: StudyFilterValues; |
| 32 | + sort: GetGroupStudiesSortEnum; |
| 33 | + onSearchChange: (query: string) => void; |
| 34 | + onFilterChange: (values: StudyFilterValues) => void; |
| 35 | + onSortChange: (value: GetGroupStudiesSortEnum) => void; |
| 36 | + }; |
| 37 | +} |
| 38 | + |
| 39 | +export default function StudyListToolbar({ |
| 40 | + title, |
| 41 | + classification, |
| 42 | + isAuthReady, |
| 43 | + controls, |
| 44 | +}: StudyListToolbarProps) { |
| 45 | + return ( |
| 46 | + <> |
| 47 | + <div className="mb-400 flex flex-col items-start gap-200 sm:flex-row sm:items-center sm:justify-between"> |
| 48 | + <h1 className="font-designer-24b text-text-default">{title}</h1> |
| 49 | + <GroupStudyFormModal |
| 50 | + mode="create" |
| 51 | + classification={classification} |
| 52 | + trigger={ |
| 53 | + <Button |
| 54 | + color="primary" |
| 55 | + size="small" |
| 56 | + icon={<Plus className="h-200 w-200" />} |
| 57 | + iconPosition="left" |
| 58 | + disabled={!isAuthReady} |
| 59 | + > |
| 60 | + 스터디 개설하기 |
| 61 | + </Button> |
| 62 | + } |
| 63 | + /> |
| 64 | + </div> |
| 65 | + |
| 66 | + <div className="mb-400 flex flex-col gap-200 sm:flex-row sm:items-center sm:justify-between"> |
| 67 | + <StudyFilter |
| 68 | + values={controls.filterValues} |
| 69 | + onChange={controls.onFilterChange} |
| 70 | + /> |
| 71 | + <div className="flex items-center gap-200"> |
| 72 | + <StudySearch |
| 73 | + value={controls.searchQuery} |
| 74 | + onChange={controls.onSearchChange} |
| 75 | + /> |
| 76 | + <SortDropdown |
| 77 | + value={controls.sort} |
| 78 | + options={SORT_OPTIONS} |
| 79 | + onChange={controls.onSortChange} |
| 80 | + icon={<ArrowUpDown className="h-3 w-3" />} |
| 81 | + /> |
| 82 | + </div> |
| 83 | + </div> |
| 84 | + </> |
| 85 | + ); |
| 86 | +} |
0 commit comments