Skip to content

Commit

Permalink
1.2.0 (#9)
Browse files Browse the repository at this point in the history
* update whitebook ordering

* change to jsx

* use correct useEffect

* whitebook database done

* use correct useEffect

* add alt prop

* use correct useEffect
  • Loading branch information
BlueHorn07 authored Feb 18, 2022
1 parent d835686 commit 83d4c98
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 58 deletions.
2 changes: 1 addition & 1 deletion components/equipment/equipment.table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const EquipmentTable = () => {
const [equipments, setEquipments] = useState([])

// TODO: move out to caller component
useEffect(async () => {
useEffect(() => {
axios
.get(`${process.env.NEXT_PUBLIC_API}/equip`)
.then((res) => setEquipments(res.data))
Expand Down
27 changes: 15 additions & 12 deletions components/statistics/new-reservation.bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ const NewReservationBar = () => {
const [rawData, setRawData] = useState([])
const [barData, setBarData] = useState([])

useEffect(async () => {
const nextMonth = moment().add(1, 'M');
const res = await axios.get(`${process.env.NEXT_PUBLIC_API}/statistics/reservation?start=202101&end=${nextMonth}`)
setRawData(res.data.data)
useEffect(() => {
const nextMonth = moment().add(1, 'M')
axios.get(
`${process.env.NEXT_PUBLIC_API}/statistics/reservation?start=202101&end=${nextMonth}`).
then((res) => {
setRawData(res.data.data)

// process data format
const barData = []
for (const [key, value] of Object.entries(res.data.data)) {
barData.push({
'month': key,
'new-reservation': value
// process data format
const barData = []
for (const [key, value] of Object.entries(res.data.data)) {
barData.push({
'month': key,
'new-reservation': value,
})
}
setBarData(barData)
})
}
setBarData(barData)
}, [])

return (
Expand Down
24 changes: 13 additions & 11 deletions components/statistics/new-user.bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ const NewUserBar = () => {
const [rawData, setRawData] = useState([])
const [barData, setBarData] = useState([])

useEffect(async () => {
useEffect(() => {
const nextMonth = moment().add(1, 'M');
const res = await axios.get(`${process.env.NEXT_PUBLIC_API}/statistics/user?start=202101&end=${nextMonth}`)
setRawData(res.data.data)
axios.get(`${process.env.NEXT_PUBLIC_API}/statistics/user?start=202101&end=${nextMonth}`).
then((res) => {
setRawData(res.data.data)

// process data format
const barData = []
for (const [key, value] of Object.entries(res.data.data)) {
barData.push({
'month': key,
'new-user': value
// process data format
const barData = []
for (const [key, value] of Object.entries(res.data.data)) {
barData.push({
'month': key,
'new-user': value
})
}
setBarData(barData)
})
}
setBarData(barData)
}, [])

return (
Expand Down
2 changes: 1 addition & 1 deletion pages/404.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ErrorPage = () => {
<LoginLayout>
<Image
src={'/popo.svg'}
/>
alt={'popo_logo'}/>
<h2>
잘못된 주소이거나 현재 개발중인 페이지 입니다 🙏
</h2>
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pages/board/whitebook.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const WhitebookPage = () => {
const [whitebooks, setWhitebooks] = useState([])

useEffect(() => {
axios.get(`${process.env.NEXT_PUBLIC_API}/whitebook`).
axios.get(`${process.env.NEXT_PUBLIC_API}/whitebook?orderBy=click_count`).
then((res) => setWhitebooks(res.data)).
catch((err) => {
alert('생활백서 목록을 불러오는데 실패했습니다.')
Expand Down
16 changes: 9 additions & 7 deletions pages/equipment/reservation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ const EquipmentReservationPage = () => {
const [total_count, setTotalCount] = useState(0)
const page_size = 10

useEffect(async () => {
useEffect(() => {
try {
const res = await axios.get(
axios.get(
`${process.env.NEXT_PUBLIC_API}/reservation-equip?take=${page_size}`, {
withCredentials: true,
})
setReservations(res.data)
const res2 = await axios.get(
}).then((res) => {
setReservations(res.data)
})
axios.get(
`${process.env.NEXT_PUBLIC_API}/reservation-equip/count`,
)
setTotalCount(res2.data)
).then((res) => {
setTotalCount(res.data)
})
} catch (err) {
alert('장비 예약 목록을 불러오는데 실패했습니다.')
console.log(err)
Expand Down
1 change: 0 additions & 1 deletion pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const HomePage = () => {
<List as="ul">
<List.Item as="li">게시판 기능</List.Item>
<List.Item as="li">PoApper SSO 유저 정보 이전</List.Item>
<List.Item as="li">생활백서 데이터베이스화</List.Item>
<List.Item as="li">Full Responsive Web</List.Item>
</List>
</Grid.Column>
Expand Down
2 changes: 1 addition & 1 deletion pages/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const LoginPage = () => {
<LoginLayout>
<Image
src={'/popo.svg'}
/>
alt={'popo-logo'}/>
<SubTitle>관리자 페이지</SubTitle>
<LoginFormDiv>
<Form>
Expand Down
16 changes: 9 additions & 7 deletions pages/place/reservation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ const PlaceReservationPage = () => {
const [total_count, setTotalCount] = useState(0)
const page_size = 10

useEffect(async () => {
useEffect(() => {
try {
const res = await axios.get(
axios.get(
`${process.env.NEXT_PUBLIC_API}/reservation-place?take=${page_size}`, {
withCredentials: true,
})
setReservations(res.data)
const res2 = await axios.get(
}).then((res) => {
setReservations(res.data)
})
axios.get(
`${process.env.NEXT_PUBLIC_API}/reservation-place/count`,
)
setTotalCount(res2.data)
).then((res) => {
setTotalCount(res.data)
})
} catch (err) {
alert('장소 예약 목록을 불러오는데 실패했습니다.')
console.log(err)
Expand Down
20 changes: 11 additions & 9 deletions pages/reservation/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ const ReservationPage = () => {
const [place_reservations, setPlaceReservations] = useState([])
const [equip_reservations, setEquipReservations] = useState([])

useEffect(async () => {
const res1 = await axios.get(
useEffect(() => {
axios.get(
`${process.env.NEXT_PUBLIC_API}/reservation-place?status=심사중`,
)
setPlaceReservations(res1.data)
const res2 = await axios.get(
).then((res) => {
setPlaceReservations(res.data)
})
axios.get(
`${process.env.NEXT_PUBLIC_API}/reservation-equip?status=심사중`,
)
setEquipReservations(res2.data)
).then((res) => {
setEquipReservations(res.data)
})
}, [])

return (
<ReservationLayout>
<h3>예약 대기 목록</h3>
<p><b>심사중</b>인 모든 예약이 이곳에 표시됩니다.</p>
<div style={{marginBottom: "1rem"}}>
<div style={{marginBottom: 24}}>
<h4>장소 예약</h4>
{
place_reservations.length ?
Expand All @@ -35,7 +37,7 @@ const ReservationPage = () => {
/> : <p>대기 중인 장소 예약이 없습니다 🎈</p>
}
</div>
<div style={{marginBottom: "1rem"}}>
<div style={{marginBottom: 24}}>
<h4>장비 예약</h4>
{
equip_reservations.length ?
Expand Down
16 changes: 9 additions & 7 deletions pages/user.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ const UserPage = () => {
const [total_count, setTotalCount] = useState(0)
const page_size = 10

useEffect(async () => {
useEffect(() => {
try {
const res = await axios.get(
axios.get(
`${process.env.NEXT_PUBLIC_API}/user?take=${page_size}`,
{ withCredentials: true })
setUsers(res.data)
const res2 = await axios.get(
{ withCredentials: true }).then((res) => {
setUsers(res.data)
})
axios.get(
`${process.env.NEXT_PUBLIC_API}/user/count`,
)
setTotalCount(res2.data)
).then((res) => {
setTotalCount(res.data)
})
} catch (err) {
alert('유저 목록을 불러오는데 실패했습니다.')
console.log(err)
Expand Down

0 comments on commit 83d4c98

Please sign in to comment.