Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,242 changes: 1,113 additions & 129 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"js-cookie": "^3.0.5",
"lucide-react": "^0.468.0",
"react": "^19.1.0",
"react-day-picker": "8.10.1",
"react-day-picker": "^9.9.0",
"react-dom": "^19.1.0",
"react-hook-form": "^7.57.0",
"recharts": "^2.15.3",
Expand Down Expand Up @@ -78,14 +78,16 @@
"globals": "^15.15.0",
"husky": "^9.1.7",
"jira-prepare-commit-msg": "^1.7.2",
"jsdom": "^26.1.0",
"knip": "^5.59.1",
"postcss": "^8.5.4",
"prettier": "^3.5.3",
"prettier-plugin-tailwindcss": "^0.6.12",
"tailwindcss": "^3.4.17",
"typescript": "~5.7.3",
"typescript-eslint": "^8.33.1",
"vite": "^6.3.5"
"vite": "^6.3.5",
"vitest": "^3.2.4"
},
"jira-prepare-commit-msg": {
"jiraTicketPattern": "I25-\\d+",
Expand Down
239 changes: 192 additions & 47 deletions src/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,71 +1,216 @@
import * as React from 'react'
import { ChevronLeft, ChevronRight } from 'lucide-react'
import { DayPicker } from 'react-day-picker'
"use client"

import * as React from "react"
import {
ChevronDownIcon,
ChevronLeftIcon,
ChevronRightIcon,
} from "lucide-react"
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker"
import { ko } from "date-fns/locale";
import { cn } from '@/lib/utils'
import { buttonVariants } from '@/components/ui/button'

export type CalendarProps = React.ComponentProps<typeof DayPicker>
import { cn } from "@/lib/utils"
import { Button, buttonVariants } from "@/components/ui/button"

function Calendar({
className,
classNames,
showOutsideDays = true,
captionLayout = "label",
buttonVariant = "ghost",
formatters,
components,
...props
}: CalendarProps) {
}: React.ComponentProps<typeof DayPicker> & {
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
}) {
const defaultClassNames = getDefaultClassNames()

return (
<DayPicker
locale={ko}
showOutsideDays={showOutsideDays}
className={cn('p-3', className)}
className={cn(
"bg-background group/calendar p-3 [--cell-size:3rem] [[data-slot=card-co…ntent]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
className
)}
captionLayout={captionLayout}
formatters={{
formatMonthDropdown: (date) =>
date.toLocaleString("default", { month: "short" }),
...formatters,
}}
classNames={{
months: 'flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0',
month: 'space-y-4',
caption: 'flex justify-center pt-1 relative items-center',
caption_label: 'text-sm font-medium',
nav: 'space-x-1 flex items-center',
nav_button: cn(
buttonVariants({ variant: 'outline' }),
'h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100'
),
nav_button_previous: 'absolute left-1',
nav_button_next: 'absolute right-1',
table: 'w-full border-collapse space-y-1',
head_row: 'flex gap-3 justify-center',
head_cell:
'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]',
row: 'flex w-full mt-2',
cell: cn(
'relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md',
props.mode === 'range'
? '[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md'
: '[&:has([aria-selected])]:rounded-md'
root: cn("w-fit", defaultClassNames.root),
months: cn(
"relative flex flex-col gap-4 md:flex-row",
defaultClassNames.months
),
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
nav: cn(
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap…1",
defaultClassNames.nav
),
button_previous: cn(
buttonVariants({ variant: buttonVariant }),
"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity…50",
defaultClassNames.button_previous
),
button_next: cn(
buttonVariants({ variant: buttonVariant }),
"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity…50",
defaultClassNames.button_next
),
month_caption: cn(
"flex h-[--cell-size] w-full items-center justify-center px-[--cell-si…ze]",
defaultClassNames.month_caption
),
dropdowns: cn(
"flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-…sm font-medium",
defaultClassNames.dropdowns
),
dropdown_root: cn(
"has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 h…as-focus:ring-[3px] relative rounded-md border",
defaultClassNames.dropdown_root
),
dropdown: cn("absolute inset-0 opacity-0", defaultClassNames.dropdown),
caption_label: cn(
"select-none font-medium",
captionLayout === "label"
? "text-sm"
: "[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded…md pl-2 pr-1 text-sm [&>svg]:size-3.5",
defaultClassNames.caption_label
),
table: "w-full border-collapse",
weekdays: cn("flex", defaultClassNames.weekdays),
weekday: cn(
"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] fon…t-normal",
defaultClassNames.weekday
),
week: cn("mt-2 flex w-full", defaultClassNames.week),
week_number_header: cn(
"w-[--cell-size] select-none",
defaultClassNames.week_number_header
),
week_number: cn(
"text-muted-foreground select-none text-[0.8rem]",
defaultClassNames.week_number
),
day: cn(
buttonVariants({ variant: 'ghost' }),
'h-8 w-11 p-0 font-normal aria-selected:opacity-100'
),
day_range_start: 'day-range-start',
day_range_end: 'day-range-end',
day_selected:
'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground',
day_today: 'bg-accent text-accent-foreground',
day_outside:
'day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground',
day_disabled: 'text-muted-foreground opacity-50',
day_range_middle:
'aria-selected:bg-accent aria-selected:text-accent-foreground',
day_hidden: 'invisible',
"group/day relative h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data…-selected=true]_button]:rounded-r-md",
defaultClassNames.day
),
range_start: cn("rounded-l-md bg-accent", defaultClassNames.range_start),
range_middle: cn(
"rounded-none bg-accent",
defaultClassNames.range_middle
),
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
today: cn(
"bg-warning rounded-md data-[selected=true]:rounded-none data-[selected=true]:bg-accent",
defaultClassNames.today
),
outside: cn(
"text-muted-foreground aria-selected:text-muted-foreground",
defaultClassNames.outside
),
disabled: cn(
"text-muted-foreground opacity-50",
defaultClassNames.disabled
),
hidden: cn("invisible", defaultClassNames.hidden),
...classNames,
}}
components={{
IconLeft: () => <ChevronLeft className='h-4 w-4' />,
IconRight: () => <ChevronRight className='h-4 w-4' />,
Root: ({ className, rootRef, ...props }) => {
return (
<div
data-slot="calendar"
ref={rootRef}
className={cn(className)}
{...props}
/>
)
},
Chevron: ({ className, orientation, ...props }) => {
if (orientation === "left") {
return (
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
)
}

if (orientation === "right") {
return (
<ChevronRightIcon
className={cn("size-4", className)}
{...props}
/>
)
}

return (
<ChevronDownIcon className={cn("size-4", className)} {...props} />
)
},
DayButton: CalendarDayButton,
WeekNumber: ({ children, ...props }) => {
return (
<td {...props}>
<div className="flex size-[--cell-size] items-center justify-cente…r text-center">
{children}
</div>
</td>
)
},
...components,
}}
{...props}
/>
)
}
Calendar.displayName = 'Calendar'

export { Calendar }
function CalendarDayButton({
className,
day,
modifiers,
...props
}: React.ComponentProps<typeof DayButton>) {
const defaultClassNames = getDefaultClassNames()

const ref = React.useRef<HTMLButtonElement>(null)
React.useEffect(() => {
if (modifiers.focused) ref.current?.focus()
}, [modifiers.focused])

return (
<Button
ref={ref}
variant="ghost"
size="default"
data-day={day.date.toLocaleDateString()}
data-selected-single={
modifiers.selected &&
!modifiers.range_start &&
!modifiers.range_end &&
!modifiers.range_middle
}
data-range-start={modifiers.range_start}
data-range-end={modifiers.range_end}
data-range-middle={modifiers.range_middle}
className={cn(
"hover:bg-accent/80 rounded-md",
"data-[selected-single=true]:bg-primary data-[selected-single=true]:!text-primary-foreground",
"data-[range-start=true]:bg-primary data-[range-start=true]:!text-primary-foreground",
"data-[range-end=true]:bg-primary data-[range-end=true]:!text-primary-foreground",
"data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground",
defaultClassNames.day,
className
)}
{...props}
/>
)
}

export { Calendar, CalendarDayButton }
47 changes: 26 additions & 21 deletions src/features/users/components/StudentDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Separator } from '@/components/ui/separator'
import Loader from '@/components/loader'
import { DetailType, useEditUser } from '../context/edit-context'
import { UserDetailType } from '../data/schema'
import { useHandleEmploymentMutation } from '../services/employment-companies/handleEmployment'
import { useHandleFieldTrainingMutation } from '../services/field-training/handleFieldTraining'
import { MutationOperation, UserDetailType } from '../data/schema'
import { useHandleUserMutation } from '../services/handleUserMutation'
import { useUserDetailQuery } from '../services/selectUser'
import { useUserListQuery } from '../services/seleteUserList'
import { AfterCourses } from './after-courses'
Expand Down Expand Up @@ -88,29 +87,35 @@ export function StudentDetail({ student_id }: { student_id: string }) {
const { data, isLoading, refetch, isFetching } =
useUserDetailQuery(student_id)
const { refetch: userRefetch } = useUserListQuery()
const { mutateAsync: handleFieldTrainingMutation } =
useHandleFieldTrainingMutation()
const { mutateAsync: handleEmploymentMutation } =
useHandleEmploymentMutation()
const { mutateAsync: handleUserMutation } = useHandleUserMutation()

const saveEditing = async () => {
if (!editData) return

// 현장실습 데이터 처리
const fieldTrainingData = editData.filter(
(item) => 'field_training' in item.datas
)
if (fieldTrainingData.length > 0) {
await handleFieldTrainingMutation(fieldTrainingData)
}
const operations: MutationOperation[] = editData.map(item => {
const tableName = Object.keys(item.datas)[0]
const data = Object.values(item.datas)[0]

// 취업 데이터 처리
const employmentData = editData.filter(
(item) => 'employment_companies' in item.datas
)
if (employmentData.length > 0) {
await handleEmploymentMutation(employmentData)
}
const op: MutationOperation = {
tableName,
action: item.action,
data,
}

if (item.action === 'update' || item.action === 'delete') {
op.matchColumns = {
student_id: data.student_id,
company_id: data.company_id,
}
if (data.job_id) {
op.matchColumns.job_id = data.job_id
}
}

return op
})

await handleUserMutation(operations)

await refetch()
setEditingSection(null)
Expand Down
Loading