From 9d763e843214576a1d4f7b2ddab063704c77a857 Mon Sep 17 00:00:00 2001 From: SUMMERLOVE7 Date: Thu, 23 Feb 2023 16:56:29 +0900 Subject: [PATCH] =?UTF-8?q?fix(FE):=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=A0=84?= =?UTF-8?q?=ED=99=98=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/MainPage.js | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/client/src/pages/MainPage.js b/client/src/pages/MainPage.js index 3fc8fbc..e678b38 100644 --- a/client/src/pages/MainPage.js +++ b/client/src/pages/MainPage.js @@ -92,7 +92,11 @@ const handleClickSearchIcon = (target) => async (e) => { if (target.classList.contains('searching')) return; const newData = await getCardList(inputTarget.value); setCardDatas(newData); - navigateMain(cardDatas); + + const cardsSection = $.qs('.cards-section'); + let isList = false; + if (cardsSection.classList.contains('list')) isList = true; + navigateMain(cardDatas, isList); }; const toggleDropdown = () => { @@ -111,7 +115,12 @@ const makeGrayScale = async ({ target }) => { const list = target.closest('.card-lists'); const id = list.querySelector('.card-id').innerText; await usedCard({ gifticonId: id }); - navigateMain('/card'); + + const cardsSection = $.qs('.cards-section'); + let isList = false; + if (cardsSection.classList.contains('list')) isList = true; + + navigateMain('/card', isList); }; const makeUsedState = (targets) => @@ -188,7 +197,12 @@ const deleteCard = async (e) => { const list = e.target.closest('.card-lists'); const id = list.querySelector('.card-id').innerText; await deleteACard(id); - navigateMain('/card'); + + const cardsSection = $.qs('.cards-section'); + let isList = false; + if (cardsSection.classList.contains('list')) isList = true; + + navigateMain('/card', isList); }; const deleteCardEvent = (targets) => @@ -238,7 +252,14 @@ const comparison = () => { buttonText === '금액순' && priceComparison(); buttonText === '마감순' && dateComparison(); buttonText === '등록순' && registerDateComparison(); - navigateMain(cardDatas); + + const cardsSection = $.qs('.cards-section'); + let isList = false; + if(cardsSection.classList.contains('list')) isList = true; + + navigateMain(cardDatas, isList); + + }; const findTarget = (child, parent) => () => $.qsa(child, parent); @@ -281,7 +302,7 @@ MainPage.render = () => // prettier-ignore // const navigateMain = async (newData = '') => { -const navigateMain = async (newData) => { +const navigateMain = async (newData, isList) => { if(newData === '/card') { newData = ''; @@ -301,6 +322,11 @@ const navigateMain = async (newData) => { () => $.qs('.list-card-button'), $.on('click', switchLayout), () => MainPage.handleClickaddCard()); + + if(isList) { + const cardsSection = $.qs('.cards-section'); + cardsSection.classList.add('list'); + } createBarcode(); header({color: 'mint'})();