diff --git a/frontend/src/apis/user.js b/frontend/src/apis/user.js index d96f601..a08b748 100644 --- a/frontend/src/apis/user.js +++ b/frontend/src/apis/user.js @@ -6,7 +6,6 @@ export const Logout = () => { alert('로그아웃'); sessionStorage.removeItem('userInfo'); UserService.logout(); - window.location.replace('/'); }; // 로그인 diff --git a/frontend/src/components/calendar/calendar.js b/frontend/src/components/calendar/calendar.js index dc90edc..c327a6c 100644 --- a/frontend/src/components/calendar/calendar.js +++ b/frontend/src/components/calendar/calendar.js @@ -57,8 +57,7 @@ function setCalendarEvent() { document.querySelector('.calendar-container').innerHTML = makeCalendar( new Date(currentDate.setYear(this.value)), ); - document.querySelector('.year-wrapper').innerHTML = - yearOption(currentDate); + calendarYear.innerHTML = yearOption(currentDate); }; const prevButton = document .querySelector('.prevDay') @@ -68,7 +67,9 @@ function setCalendarEvent() { new Date(currentDate.setMonth(currentDate.getMonth() - 1)), ); if (parseInt(calendarMonth.innerText) === 1) { - calendarYear.innerText = parseInt(calendarYear.innerText) - 1; + calendarYear.innerHTML = yearOption( + currentDate.setYear(currentDate.getFullYear()), + ); calendarMonth.innerText = 12; } else { calendarMonth.innerText = parseInt(calendarMonth.innerText) - 1; @@ -82,7 +83,9 @@ function setCalendarEvent() { new Date(currentDate.setMonth(currentDate.getMonth() + 1)), ); if (parseInt(calendarMonth.innerText) === 12) { - calendarYear.innerText = parseInt(calendarYear.innerText) + 1; + calendarYear.innerHTML = yearOption( + currentDate.setYear(currentDate.getFullYear()), + ); calendarMonth.innerText = 1; } else { calendarMonth.innerText = parseInt(calendarMonth.innerText) + 1; diff --git a/frontend/src/components/rental/placeCard.js b/frontend/src/components/rental/placeCard.js index 1c3b6df..48b0e0d 100644 --- a/frontend/src/components/rental/placeCard.js +++ b/frontend/src/components/rental/placeCard.js @@ -1,11 +1,11 @@ const placeCard = (id, name, img) => { return ` - + + `; }; diff --git a/frontend/src/components/rental/placeInfo.js b/frontend/src/components/rental/placeInfo.js index 9672de4..1a09c76 100644 --- a/frontend/src/components/rental/placeInfo.js +++ b/frontend/src/components/rental/placeInfo.js @@ -1,7 +1,7 @@ export default [ { id: 1, - name: '교실', + name: '회의실', img: '/src/assets/room.svg', alt: '교실이미지', }, diff --git a/frontend/src/components/track/trackCard.js b/frontend/src/components/track/trackCard.js new file mode 100644 index 0000000..fc0d76c --- /dev/null +++ b/frontend/src/components/track/trackCard.js @@ -0,0 +1,60 @@ +import { $ } from '../../utils/selector'; + +const trackCard = (img, tname) => { + return ` + `; +}; + +function setTrackEvent() { + const trackMake = $('#track-make'); + const trackMakeInput = trackMake.querySelector('.track-input'); + const trackMakeBtn = trackMake.querySelector('.track-button'); + const trackJoin = $('#track-join'); + const trackJoinInput = trackJoin.querySelector('.track-input'); + const trackJoinBtn = trackJoin.querySelector('.track-button'); + + trackMakeInput.addEventListener('input', (e) => { + trackMakeBtn.disabled = e.target.value.length <= 0; + }); + trackMake.addEventListener('click', (e) => { + const makeBtn = e.target.closest('.track-button'); + if (makeBtn) { + trackMake.insertAdjacentHTML( + 'beforebegin', + trackCard('/src/assets/soundless.svg', trackMakeInput.value), + ); //이름이 같은 트랙이 존재하지 않으면 정상 모달 메세지와 함께 트랙 추가 카드 앞에 새로운 트랙 버튼이 생성됨. 그렇지 않으면 오류 모달 메세지 출력. + trackMake.classList.toggle('track-rotate'); + trackMakeInput.value = ''; + trackMakeBtn.disabled = 'true'; + } else { + if (trackMake.classList.contains('track-rotate')) return; + trackMake.classList.toggle('track-rotate'); + trackMakeInput.focus(); + } + }); + + trackJoinInput.addEventListener('input', (e) => { + trackJoinBtn.disabled = e.target.value.length <= 0; + }); + trackJoin.addEventListener('click', (e) => { + const makeBtn = e.target.closest('.track-button'); + if (makeBtn) { + trackJoin.insertAdjacentHTML( + 'beforebegin', + trackCard('/src/assets/soundless.svg', trackJoinInput.value), + ); //초대 코드가 유효할 경우, 정상 모달 메세지와 함께 트랙 추가 카드 앞에 새로운 트랙 버튼이 생성됨. 그렇지 않으면 오류 모달 메세지 출력. + trackJoin.classList.toggle('track-rotate'); + trackJoinInput.value = ''; + trackJoinBtn.disabled = 'true'; + } else { + if (trackJoin.classList.contains('track-rotate')) return; + trackJoin.classList.toggle('track-rotate'); + trackJoinInput.focus(); + } + }); +} + +export { trackCard, setTrackEvent }; diff --git a/frontend/src/components/track/trackInfo.js b/frontend/src/components/track/trackInfo.js new file mode 100644 index 0000000..c22ef47 --- /dev/null +++ b/frontend/src/components/track/trackInfo.js @@ -0,0 +1,14 @@ +export default [ + { + id: 1, + name: '현대자동차그룹 소프티어 부트캠프 2023', + img: '/src/assets/room.svg', + alt: '소프티어', + }, + { + id: 2, + name: '코드스쿼드 마스터즈 코스', + img: '/src/assets/chair.svg', + alt: '마스터즈', + }, +]; diff --git a/frontend/src/main.js b/frontend/src/main.js index 27538bf..e15e869 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -1,5 +1,6 @@ import setHomeEvent from './scripts/home.js'; -import setMainEvent from './scripts/main.js'; +import { setMainEvent } from './scripts/main.js'; +import { setTrackEvent } from './components/track/trackCard.js'; import { setCalendarEvent } from './components/calendar/calendar.js'; const eventdelegator = (root) => { @@ -12,9 +13,10 @@ const eventdelegator = (root) => { setMainEvent(); break; case 'track': + setTrackEvent(); break; case 'attend': - setCalendarEvent + setCalendarEvent(); break; } }; diff --git a/frontend/src/pages/trackPage.js b/frontend/src/pages/trackPage.js index f15b505..88cc031 100644 --- a/frontend/src/pages/trackPage.js +++ b/frontend/src/pages/trackPage.js @@ -1,9 +1,11 @@ import AbstractView from './pageTemplate.js'; import { pageTitleTamplate } from '../components/pageTitle.js'; +import trackInfo from '../components/track/trackInfo.js'; +import { trackCard } from '../components/track/trackCard.js'; export default class trackPage extends AbstractView { async getHtml() { - return ` + return /*html */ `