-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feat/#151 사장님 백엔드 연동 완료
- Loading branch information
Showing
40 changed files
with
1,351 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.react-calendar { | ||
border: none !important; | ||
width: 100% !important; | ||
height: 70% !important; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
} | ||
|
||
.react-calendar__navigation { | ||
margin-top: 8px; | ||
} | ||
|
||
/* 요일 타일 스타일링 */ | ||
.react-calendar__month-view__weekdays { | ||
@apply bg-hanaLightGreen text-center p-1 font-semibold rounded-md; | ||
} | ||
|
||
/* 요일 타일 텍스트 스타일링 */ | ||
.react-calendar__month-view__weekdays__weekday { | ||
@apply text-sm text-white; | ||
} | ||
|
||
/* 날짜 타일 기본 스타일링 */ | ||
.react-calendar__tile { | ||
@apply text-center p-2 m-1 hover:bg-blue-100 flex flex-col border border-b-2; | ||
border-bottom: 2px solid #ccc !important; | ||
} | ||
|
||
/* 오늘 날짜 타일 스타일링 */ | ||
/* .react-calendar__tile--now { | ||
@apply !bg-blue-300 !text-white; | ||
} */ | ||
|
||
/* 선택된 날짜 타일 스타일링 .react-calendar__tile--active { | ||
@apply !bg-yellow-100 !text-white; | ||
} */ | ||
|
||
/* 선택할 수 없는 날짜 타일 스타일링 */ | ||
.react-calendar__tile--disabled { | ||
@apply text-gray-400; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { useEffect, useState } from 'react'; | ||
import './CalendarEmployee.css'; | ||
import Calendar, { OnArgs } from 'react-calendar'; | ||
import 'react-calendar/dist/Calendar.css'; | ||
// import CalendarMark from './CalendarMark'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useCalendarData } from '../../contexts/Calender-Data-Context'; | ||
import ApiClient from '../../api/apiClient'; | ||
import { parseYYYMMDD } from '../../utils/date-util'; | ||
import { useEmployeeCalendarData } from '../../contexts/Employee-Calender-Data-Context'; | ||
import CalendarMark from '../ui/CalendarMark'; | ||
|
||
type ValuePiece = Date | null; | ||
type Value = ValuePiece | [ValuePiece, ValuePiece]; | ||
|
||
const currentDate = new Date(); | ||
|
||
const CalendarEmployee = () => { | ||
const [value, setValue] = useState<Value>(currentDate); | ||
const { calendarData, setCalendarData } = useEmployeeCalendarData(); | ||
const navigate = useNavigate(); | ||
|
||
console.log('🚀 CalendarCustom value:', value); | ||
|
||
useEffect(() => { | ||
if (value instanceof Date) { | ||
const year = value.getFullYear(); | ||
const month = value.getMonth() + 1; | ||
fetchData(year, month); | ||
} | ||
}, [value]); | ||
|
||
const fetchData = async (year: number, month: number) => { | ||
try { | ||
const response = await ApiClient.getInstance().getEmployeeCalendarData( | ||
year, | ||
month | ||
); | ||
console.log('API 호출 결과:', response); | ||
setCalendarData(response); | ||
} catch (error) { | ||
console.error('API 호출 실패:', error); | ||
} | ||
}; | ||
|
||
const onChangeCurrentDate = (args: OnArgs) => { | ||
const { action, activeStartDate, value, view } = args; | ||
// console.log('🚀 activeStartDate:', activeStartDate); | ||
// console.log('🚀 view:', view); | ||
// console.log('🚀 value:', value); | ||
// console.log('🚀 action:', action); | ||
setValue(activeStartDate!); | ||
}; | ||
|
||
const onClickDate = (date: Date) => { | ||
const localDateString = date.toLocaleDateString('en-CA'); // 'YYYY-MM-DD' 형식 | ||
navigate(`/owner/calendar/${localDateString}`); | ||
}; | ||
|
||
const getListForDate = (date: Date) => { | ||
const list = []; | ||
calendarData && | ||
calendarData.list.map((workPlace) => { | ||
if ( | ||
new Date(parseYYYMMDD(workPlace.attendDate)).toDateString() === | ||
date.toDateString() | ||
) { | ||
list.push({ | ||
...workPlace, | ||
}); | ||
} | ||
}); | ||
return list; | ||
}; | ||
|
||
// const getEventsForDate = (date: Date) => { | ||
// const events = []; | ||
// calendarData.forEach((workPlace) => { | ||
// workPlace.days.forEach((day) => { | ||
// if (new Date(day.startTime).toDateString() === date.toDateString()) { | ||
// events.push({ | ||
// ...day, | ||
// workPlaceName: workPlace.workPlaceName, | ||
// workPlaceColor: workPlace.workPlaceColor, | ||
// }); | ||
// } | ||
// }); | ||
// }); | ||
// return events; | ||
// }; | ||
|
||
// 날짜 타일에 맞춤 콘텐츠를 추가한다. | ||
const tileContent = ({ date, view }: { date: Date; view: string }) => { | ||
if (view === 'month') { | ||
// const events = getEventsForDate(date); | ||
const list = getListForDate(date); | ||
console.log(list, '>>>>>>>>>>>>>>>>>'); | ||
return ( | ||
// <div>헬로</div> | ||
<div className='h-full w-full'> | ||
{list.map((data) => ( | ||
<div key={`${data}`}>{data.workPlaceName}</div> | ||
// <CalendarMark key={`${data}`} {...data} /> | ||
))} | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className='rounded-mdw-ful'> | ||
<Calendar | ||
locale='en' | ||
className={'w-full'} | ||
onChange={setValue} | ||
onClickDay={onClickDate} | ||
onActiveStartDateChange={onChangeCurrentDate} | ||
value={value} | ||
tileClassName={['h-28']} | ||
tileContent={tileContent} | ||
/> | ||
</div> | ||
); | ||
}; | ||
export default CalendarEmployee; |
Oops, something went wrong.