Skip to content

Commit

Permalink
feat: renew mainpage article list
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanKIMHG committed Nov 4, 2022
1 parent 963f0e8 commit 59bacfe
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion client/src/Pages/MainPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ const MainPage = () => {
axios.get('http://localhost:3001/articles', {
withCredentials: true
}).then((res) => {
console.log(res.data)
setMainArticles(res.data);
}).catch((err) => {
console.error(err);
});
}, []);


return (
<ThemeProvider theme={context.state.theme}>
<Grid container spacing={4} justifyContent='center'>
Expand All @@ -33,7 +35,7 @@ const MainPage = () => {
<ListContainer id="main-list"/>
</Grid>
<Grid item xs={6} mt={10} sx={{ width: '100%', height: 'auto' }}>
{mainArticles.map((item) => {
{[...mainArticles].reverse().map((item) => {
return <Article key={item._id} userId={item.author.userId} title={item.title} content={item.content} imgFile={item.imgFile} />;
})}
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion client/src/Pages/WritePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function WritePage () {
</Typography>
<Stepper activeStep={activeStep} sx={{ pt: 3, pb: 5 }}>
{steps.map((label) => (
<Step key={label} >
<Step className='step-container' key={label} >
<StepLabel>{label}</StepLabel>
</Step>
))}
Expand Down
1 change: 1 addition & 0 deletions client/src/components/ListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const ListContainer = () => {
pr: 3,
}}>
<List

component="nav" className='nav-list'
subheader={
<ListSubheader sx={{
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/ListContainerByRegion.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ListContainerByRegion = ({primary}) => {
const {setMainArticles} = context.action;

const handleButtonClick = useCallback((e) => {
// post parameter로.
axios.get(`http://localhost:3001/articles?city=${e.target.innerText}`)
.then((res) => {
console.log(res.data)
Expand All @@ -25,8 +26,8 @@ const ListContainerByRegion = ({primary}) => {
}, [mainArticles])

return (
<List component="div" disablePadding>
<ListItemButton sx={{ pl:4 }} onClick={handleButtonClick}>
<List component="div" disablePadding >
<ListItemButton sx={{ pl:4 }} onClick={handleButtonClick} >
<ListItemIcon>
<FlagCircleIcon id="flag"/>
</ListItemIcon>
Expand Down
3 changes: 1 addition & 2 deletions client/src/components/WriteForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export default function WriteForm (props) {
}
};

const handleRegionChange = useCallback(
(e) => {
const handleRegionChange = useCallback((e) => {
const target = e.target.value
setRegion(target);
if (target === "Asia") {
Expand Down
5 changes: 5 additions & 0 deletions client/src/utils/Header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.sticky {
position: fixed;
top: 0;
width: 100%
}
2 changes: 1 addition & 1 deletion server/router/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const router = express.Router();

router.get('/', find);
router.post('/write', write);
router.post('/comment', comment);
router.post('/comment', comment); // delete는 똑같이 여기로 보내는데 query만 추가.
router.patch('/like', like);

module.exports = router;

0 comments on commit 59bacfe

Please sign in to comment.