From 184a2672d402947bd80b084dcf62bc2aad5efafa Mon Sep 17 00:00:00 2001 From: yoonc01 Date: Wed, 14 Aug 2024 17:56:58 +0900 Subject: [PATCH] add AdminEventStatus page but not done --- admin/src/App.jsx | 2 +- .../AdminEventStatus/AdminEventStatus.jsx | 8 ++ .../pages/AdminEventStatus/RadioButton.jsx | 25 ++++ .../pages/AdminEventStatus/TableComponent.jsx | 130 ++++++++++++++++++ admin/src/pages/AdminEventStatus/TableRow.jsx | 23 ++++ admin/src/styles/global.css | 7 + 6 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 admin/src/pages/AdminEventStatus/AdminEventStatus.jsx create mode 100644 admin/src/pages/AdminEventStatus/RadioButton.jsx create mode 100644 admin/src/pages/AdminEventStatus/TableComponent.jsx create mode 100644 admin/src/pages/AdminEventStatus/TableRow.jsx create mode 100644 admin/src/styles/global.css diff --git a/admin/src/App.jsx b/admin/src/App.jsx index e0f9dfb..dacc082 100644 --- a/admin/src/App.jsx +++ b/admin/src/App.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import AdminEventStatus from './pages/AdminEventStatus/AdminEventStatus'; +import AdminEventStatus from '@/pages/AdminEventStatus/AdminEventStatus'; function App() { return ( diff --git a/admin/src/pages/AdminEventStatus/AdminEventStatus.jsx b/admin/src/pages/AdminEventStatus/AdminEventStatus.jsx new file mode 100644 index 0000000..e3865a8 --- /dev/null +++ b/admin/src/pages/AdminEventStatus/AdminEventStatus.jsx @@ -0,0 +1,8 @@ +import React, { useEffect } from 'react'; +import TableComponent from '@/pages/AdminEventStatus/TableComponent'; + +function AdminEventStatus() { + return ; +} + +export default AdminEventStatus; diff --git a/admin/src/pages/AdminEventStatus/RadioButton.jsx b/admin/src/pages/AdminEventStatus/RadioButton.jsx new file mode 100644 index 0000000..ec8f2ad --- /dev/null +++ b/admin/src/pages/AdminEventStatus/RadioButton.jsx @@ -0,0 +1,25 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +function RadioButton({ value, rowsPerPage, onChange }) { + return ( + + ); +} + +RadioButton.propTypes = { + value: PropTypes.number.isRequired, + rowsPerPage: PropTypes.number.isRequired, + onChange: PropTypes.func.isRequired, +}; + +export default RadioButton; diff --git a/admin/src/pages/AdminEventStatus/TableComponent.jsx b/admin/src/pages/AdminEventStatus/TableComponent.jsx new file mode 100644 index 0000000..aaa0baf --- /dev/null +++ b/admin/src/pages/AdminEventStatus/TableComponent.jsx @@ -0,0 +1,130 @@ +import React, { useState, useEffect } from 'react'; +import TableRow from '@/pages/AdminEventStatus/TableRow'; +import RadioButton from '@/pages/AdminEventStatus/RadioButton'; + +const TableComponent = () => { + const [rowsPerPage, setRowsPerPage] = useState(10); + const [totalRows, setTotalRows] = useState(-1); + const [currentPage, setCurrentPage] = useState(1); + const [pageData, setPageData] = useState([ + { id: 1, phoneNumber: '10', time: 's', result: '1' }, + { id: 2, phoneNumber: '10', time: 's', result: '1' }, + { id: 3, phoneNumber: '10', time: 's', result: '1' }, + { id: 4, phoneNumber: '10', time: 's', result: '1' }, + { id: 5, phoneNumber: '10', time: 's', result: '1' }, + { id: 6, phoneNumber: '10', time: 's', result: '1' }, + { id: 7, phoneNumber: '10', time: 's', result: '1' }, + { id: 8, phoneNumber: '10', time: 's', result: '1' }, + ]); + + useEffect(() => { + getCurrentPageData(currentPage); + }, [rowsPerPage, currentPage]); + + useEffect(() => { + setTotalRows(156); //TODO API 통신으로 가져오기 및 데이터를 가져오기 + }, []); + + const totalPages = Math.ceil(totalRows / rowsPerPage); + const startPage = Math.floor((currentPage - 1) / 10) * 10 + 1; + const endPage = Math.min(startPage + 9, totalPages); + + const handleRowsPerPageChange = event => { + setRowsPerPage(Number(event.target.value)); + setCurrentPage(1); + }; + + const handlePageChange = newPage => { + setCurrentPage(newPage); + }; + + const getCurrentPageData = currentPage => { + // try{ + // const data //API 통신 + // } + //setPageData(data); // data의 정보 array 가져오기 + }; + + return ( +
+
+
+
전체 {totalRows}
+
+ + + +
+
+
+
순번
+
전화번호
+
응모 시간
+
응모 결과
+
+ {pageData.map(item => ( + + ))} +
+ + + {Array.from({ length: endPage - startPage + 1 }).map((_, index) => ( + + ))} + + +
+
+
+ ); +}; + +export default TableComponent; diff --git a/admin/src/pages/AdminEventStatus/TableRow.jsx b/admin/src/pages/AdminEventStatus/TableRow.jsx new file mode 100644 index 0000000..37836a1 --- /dev/null +++ b/admin/src/pages/AdminEventStatus/TableRow.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import '@/styles/global.css'; + +function TableRow({ id, phoneNumber, time, result }) { + return ( +
+
{id}
+
{phoneNumber}
+
{time}
+
{result}
+
+ ); +} + +TableRow.propTypes = { + id: PropTypes.number.isRequired, + phoneNumber: PropTypes.string.isRequired, + time: PropTypes.string.isRequired, + result: PropTypes.string.isRequired, +}; + +export default TableRow; diff --git a/admin/src/styles/global.css b/admin/src/styles/global.css new file mode 100644 index 0000000..524e624 --- /dev/null +++ b/admin/src/styles/global.css @@ -0,0 +1,7 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +.set-center { + @apply flex items-center justify-center; +}