From 2e6340d816e7366191b558c7382f7b22bab22d76 Mon Sep 17 00:00:00 2001 From: dokimion24 Date: Sun, 5 Mar 2023 12:21:28 +0900 Subject: [PATCH 1/6] =?UTF-8?q?Feat:=20=EC=A3=BC=EC=84=9D=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/page/admin/product.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/ts/page/admin/product.ts b/src/ts/page/admin/product.ts index e829bc0..574103d 100644 --- a/src/ts/page/admin/product.ts +++ b/src/ts/page/admin/product.ts @@ -168,14 +168,6 @@ export const handleProductPage = async (): Promise => { } if (confirm('선택한 상품을 삭제하시겠습니까? ')) { - // async function deleteProductPromise(newProductsEl) { - // const productsMap = newProductsEl.map(async (newProductEl) => { - // return await deleteProduct(newProductEl.dataset.id); - // }); - // return productsMap; - // } - - // await deleteProductPromise(newProductsEl); await Promise.all( newProductsEl.map( async (newProductEl: any) => From e5e4734c741dab4fa7e59bc0d3ae657ebdc0a241 Mon Sep 17 00:00:00 2001 From: dokimion24 Date: Sun, 5 Mar 2023 12:53:20 +0900 Subject: [PATCH 2/6] =?UTF-8?q?Fix:=20=EA=B1=B0=EB=9E=98=EB=82=B4=EC=97=AD?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EA=B2=80=EC=83=89=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/page/admin/order.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ts/page/admin/order.ts b/src/ts/page/admin/order.ts index d141a52..472dbe1 100644 --- a/src/ts/page/admin/order.ts +++ b/src/ts/page/admin/order.ts @@ -52,13 +52,15 @@ export const handleOrderPage = async (): Promise => { '.order-container__search-container--input input', ); + const searchedOrderBtn = $( + '.order-container__search-container--input input', + ); + const searchOrderHandler = (): void => { const filteredOrder = orders.filter((order) => order.user.displayName.includes(searchedOrderInput.value), ); - orders = filteredOrder; - orderList.innerHTML = ``; renderPageBtn(orderPageBtn, filteredOrder, 1, itemsPerPage, 1); newOrders = getOrderCurrentPage(filteredOrder, 1, itemsPerPage); @@ -67,19 +69,16 @@ export const handleOrderPage = async (): Promise => { /** 거래내역 검색(enter) 이벤트 리스너 */ searchedOrderInput.addEventListener('keydown', (e) => { - if (e.key === 'Enter' && !e.isComposing) { + if (e.key === 'Enter') { searchOrderHandler(); } }); - searchedOrderInput.addEventListener('input', async () => { - searchedOrderInput.value === '' ? (orders = await getAllOrder()) : orders; + /** 거래내역 검색(버튼 클릭) 이벤트 리스너 */ + searchedOrderBtn.addEventListener('click', async () => { searchOrderHandler(); }); - /** 거래내역 검색(버튼 클릭) 이벤트 리스너 */ - // searchedOrderBtn.addEventListener('click', searchOrderHandler); - /** 버튼 클릭 페이지 이동 이벤트 리스너 */ orderPageBtn.addEventListener('click', (e: MouseEvent) => { if ((e.target as HTMLButtonElement).classList.contains('btn-page')) return; From 2c76759b654d398fa2866cf473586a0d9f5bb395 Mon Sep 17 00:00:00 2001 From: dokimion24 Date: Sun, 5 Mar 2023 12:54:10 +0900 Subject: [PATCH 3/6] =?UTF-8?q?Fix:=20=EC=83=81=ED=92=88=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EA=B2=80=EC=83=89=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/page/admin/product.ts | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/ts/page/admin/product.ts b/src/ts/page/admin/product.ts index 574103d..97137f8 100644 --- a/src/ts/page/admin/product.ts +++ b/src/ts/page/admin/product.ts @@ -40,26 +40,29 @@ let newProducts = getProductCurrentPage( /** 상품관리 페이지 핸들러 */ export const handleProductPage = async (): Promise => { - const productList = $('.product-container__list') as HTMLUListElement; - const checkProductAll = $( + const productList = $('.product-container__list'); + const checkProductAll = $( '.product-container__title input', - ) as HTMLInputElement; - const productPageBtn = $('.product-container__btn-page') as HTMLButtonElement; + ); + const productPageBtn = $('.product-container__btn-page'); products = await getAllProducts(); setUpUI(productPageBtn, productList); - const searchedProductInput = $( + const searchedProductInput = $( '.product-container__search-container--input input', - ) as HTMLInputElement; + ); + + const searchedProductBtn = $( + '.product-container__search-container--input input', + ); const searchProductHandler = (): void => { const filteredProduct = products.filter((product) => - product.title.toLowerCase().includes(searchedProductInput.value), + product.title.toLowerCase().trim().includes(searchedProductInput.value), ); - products = filteredProduct; productList.innerHTML = ``; renderPageBtn(productPageBtn, filteredProduct, 1, itemsPerPage, 1); newProducts = getProductCurrentPage(filteredProduct, 1, itemsPerPage); @@ -68,21 +71,16 @@ export const handleProductPage = async (): Promise => { /** 상품 검색(enter) 이벤트 리스너 */ searchedProductInput.addEventListener('keydown', (e: KeyboardEvent) => { - if (e.key === 'Enter' && !e.isComposing) { + if (e.key === 'Enter') { searchProductHandler(); } }); - searchedProductInput.addEventListener('input', async () => { - searchedProductInput.value === '' - ? (products = await getAllProducts()) - : products; + /** 상품 검색 이벤트 리스너 */ + searchedProductBtn.addEventListener('click', async () => { searchProductHandler(); }); - /** 상품 검색(버튼 클릭) 이벤트 리스너 */ - // searchedProductBtn.addEventListener('click', searchProductHandler); - /** 페이지 버튼 클릭 이벤트 리스너 */ productPageBtn.addEventListener('click', (e: MouseEvent) => { if ( From 4a1d239af86eb9d445d806dd1944ede6672ec2df Mon Sep 17 00:00:00 2001 From: dokimion24 Date: Sun, 5 Mar 2023 13:31:11 +0900 Subject: [PATCH 4/6] =?UTF-8?q?Fix:=20=EA=B8=88=EC=A3=BC=20=EA=B1=B0?= =?UTF-8?q?=EB=9E=98=ED=86=B5=EA=B3=84=EC=B0=A8=ED=8A=B8=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=ED=91=9C=EC=8B=9C=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/page/admin/dashboard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/page/admin/dashboard.ts b/src/ts/page/admin/dashboard.ts index 9ea54e2..6e8a073 100644 --- a/src/ts/page/admin/dashboard.ts +++ b/src/ts/page/admin/dashboard.ts @@ -93,7 +93,7 @@ const setDashBoardChartAmount = ( const thisWeek: number[] = []; for (let i = 0; i < 7; i++) { - thisWeek.unshift(Number(getDate().today) - i); + thisWeek.unshift(Number(getDate(i).date)); } const amountOfthisWeek: number[] = []; From b01ce2de13f4b0c357fc72e32714d3486c28c8e3 Mon Sep 17 00:00:00 2001 From: dokimion24 Date: Sun, 5 Mar 2023 13:31:52 +0900 Subject: [PATCH 5/6] =?UTF-8?q?Feat:=20getDate=20=ED=95=A8=EC=88=98=20-=20?= =?UTF-8?q?=EC=9D=B4=EC=A0=84=20=EB=82=A0=EC=A7=9C=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/utils/date.ts | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/ts/utils/date.ts b/src/ts/utils/date.ts index 28a2f3b..8a5ff86 100644 --- a/src/ts/utils/date.ts +++ b/src/ts/utils/date.ts @@ -1,17 +1,32 @@ interface getDateInterface { - date: Date; + year: string; month: string; - today: string; + date: string; } -export const getDate = (): getDateInterface => { +export const getDate = (prevDateNum: number = 0): getDateInterface => { const today = new Date(); const dateObj: getDateInterface = { - date: today, + year: String(today.getFullYear()), month: String(today.getMonth() + 1).padStart(2, '0'), - today: String(today.getDate()).padStart(2, '0'), + date: String(today.getDate()).padStart(2, '0'), }; - return dateObj; + if (!prevDateNum) return dateObj; + else { + const prevDate = new Date( + Number(dateObj.year), + Number(dateObj.month) - 1, + Number(dateObj.date) - prevDateNum, + ); + + const prevDateObj: getDateInterface = { + year: String(prevDate.getFullYear()), + month: String(prevDate.getMonth() + 1).padStart(2, '0'), + date: String(prevDate.getDate()).padStart(2, '0'), + }; + + return prevDateObj; + } }; From a69ac7d537abdb9e6ef34afdf2bedd39c7dc2687 Mon Sep 17 00:00:00 2001 From: dokimion24 Date: Sun, 5 Mar 2023 13:39:11 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Feat:=20=EB=AA=A9=EB=A1=9D=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20trim,=20toLowerCase=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/page/admin/order.ts | 5 ++++- src/ts/page/admin/product.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ts/page/admin/order.ts b/src/ts/page/admin/order.ts index 472dbe1..3bfb1f3 100644 --- a/src/ts/page/admin/order.ts +++ b/src/ts/page/admin/order.ts @@ -58,7 +58,10 @@ export const handleOrderPage = async (): Promise => { const searchOrderHandler = (): void => { const filteredOrder = orders.filter((order) => - order.user.displayName.includes(searchedOrderInput.value), + order.user.displayName + .trim() + .toLowerCase() + .includes(searchedOrderInput.value), ); orderList.innerHTML = ``; diff --git a/src/ts/page/admin/product.ts b/src/ts/page/admin/product.ts index 97137f8..4049c57 100644 --- a/src/ts/page/admin/product.ts +++ b/src/ts/page/admin/product.ts @@ -60,7 +60,7 @@ export const handleProductPage = async (): Promise => { const searchProductHandler = (): void => { const filteredProduct = products.filter((product) => - product.title.toLowerCase().trim().includes(searchedProductInput.value), + product.title.trim().toLowerCase().includes(searchedProductInput.value), ); productList.innerHTML = ``;