-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: 조준호 <junho@jojunhoui-MacBookAir.local>
- Loading branch information
Showing
6 changed files
with
81 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,45 @@ | ||
import React from 'react' | ||
import React, { useEffect, useState } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Card, Col, Row } from 'antd' | ||
import { Link } from 'react-router-dom' | ||
import { getGroups } from '../../apis/groups' | ||
const ShowGroupList = () => { | ||
const [groups, setGroups] = useState([]) | ||
|
||
const dummy = { | ||
users: [{ userId: 1 }, { userId: 2 }, { userId: 3 }], | ||
|
||
groups: [ | ||
{ | ||
id: 1, | ||
name: '모임1', | ||
descript: '모임1입니다.', | ||
}, | ||
{ | ||
id: 2, | ||
name: '모임2', | ||
descript: '모임2입니다.', | ||
}, | ||
{ | ||
id: 3, | ||
name: '모임3', | ||
descript: '모임3입니다.', | ||
}, | ||
], | ||
} | ||
useEffect(() => { | ||
getGroups().then((data) => { | ||
setGroups(data) | ||
}) | ||
}, []) | ||
|
||
console.log(dummy) | ||
const ShowGroupList = () => { | ||
return ( | ||
<div> | ||
<div>나의 모임</div> | ||
<Row gutter={16}> | ||
<Col span={8}> | ||
{dummy.groups.map((data) => ( | ||
<Card title={data.name} bordered={false} key={data.id}> | ||
{data.descript} | ||
</Card> | ||
{groups.map((group) => ( | ||
<GroupCard key={group._id} group={group} /> | ||
))} | ||
</Col> | ||
</Row> | ||
{/* <Row gutter={16}> | ||
<Col span={8}> | ||
<Card title="Card title" bordered={false}> | ||
Card content | ||
</Card> | ||
</Col> | ||
<Col span={8}> | ||
<Card title="Card title" bordered={false}> | ||
Card content | ||
</Card> | ||
</Col> | ||
</Row> */} | ||
</div> | ||
) | ||
} | ||
|
||
const GroupCard = ({ group }) => { | ||
return ( | ||
<Link to={`/group/${group._id}/showGroupDetails`}> | ||
<Card title={group.name} style={{ marginBottom: '16px' }}> | ||
<p>{group.description}</p> | ||
</Card> | ||
</Link> | ||
) | ||
} | ||
GroupCard.propTypes = { | ||
group: PropTypes.shape({ | ||
_id: PropTypes.number.isRequired, | ||
name: PropTypes.string.isRequired, | ||
description: PropTypes.string.isRequired, | ||
}).isRequired, | ||
} | ||
export default ShowGroupList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import api from './index' | ||
|
||
export const getGroups = async () => { | ||
const response = await api.get('/group') | ||
return response.data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import axios from 'axios' | ||
|
||
const api = axios.create({ | ||
baseURL: 'https://sumtime-be.w8385.dev', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
|
||
export default api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import api from './index' | ||
|
||
export const getMembers = async () => { | ||
const response = await api.get('/members') | ||
return response.data | ||
} |