Skip to content

Commit 4d48f56

Browse files
authored
Merge pull request #189 from osamhack2021/feature/frontend/#33
Bump Feature/frontend/#33 to develop
2 parents a1c8cd5 + 8d2481c commit 4d48f56

25 files changed

Lines changed: 1151 additions & 402 deletions

File tree

backend/InitDB.js

Lines changed: 457 additions & 193 deletions
Large diffs are not rendered by default.

backend/controllers/itemController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = {
109109
if(item === null) throw new NotFoundError(`Item not Found: 존재하지 않는 항목입니다.`);
110110

111111
// Check session's edit authority
112-
if(!item.accessGroups.edit.some(i => i.equals(res.locals.group)) && item.owner._id !== res.locals._id)
112+
if(!item.accessGroups.edit.some(i => i.equals(res.locals.group)) && item.owner._id.toString() !== res.locals._id.toString())
113113
throw new ForbiddenError(`Access denied: 수정 권한이 없습니다.`);
114114

115115
// Append Contributor
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {
2-
mdiFileCabinet, mdiFileDocumentOutline, mdiTextBoxOutline
2+
mdiFileCabinet,
3+
mdiFileDocumentOutline,
4+
mdiTextBoxOutline
35
} from "@mdi/js";
4-
import { Icon } from '@mdi/react';
6+
import { Icon } from "@mdi/react";
57
import React from "react";
68

79
const icon = {
@@ -11,7 +13,10 @@ const icon = {
1113
};
1214

1315
export default function TypeIcon({ type, ...props }) {
14-
return (
16+
const isString = typeof type === "string";
17+
return isString ? (
1518
<Icon path={icon[type]} {...props} />
19+
) : (
20+
<Icon path={type} {...props} />
1621
);
1722
}

frontend/components/environment/Main/Main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import LoginPage from '_pages/LoginPage';
99
import RegisterPage from '_pages/RegisterPage';
1010
import RoutingPage from '_pages/RoutingPage';
1111
import WelcomePage from '_pages/WelcomePage';
12-
import { attemptGetUser } from '_thunks/user';
12+
import { attemptGetCurrentUser } from '_thunks/user';
1313

1414
export default function Main({ location }) {
1515
const dispatch = useDispatch();
@@ -18,7 +18,7 @@ export default function Main({ location }) {
1818
useEffect(() => {
1919
let subscribed = true;
2020

21-
dispatch(attemptGetUser())
21+
dispatch(attemptGetCurrentUser())
2222
.catch(R.identity)
2323
.then(() => subscribed && setLoading(false));
2424

frontend/components/molecules/BreadCrumbs/BreadCrumbs.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ const BreadCrumbItem = ({ item = null }) => {
1010
<Button
1111
variant="text"
1212
size="small"
13-
sx={{ width: item != null ? "auto" : "100px", textTransform: "none" }}
13+
sx={{
14+
width: item != null ? "auto" : "100px",
15+
textTransform: "none",
16+
borderRadius: "16px",
17+
px: 1.5,
18+
backgroundColor: "rgba(0, 0, 0, 0.075)",
19+
color: "black"
20+
}}
1421
component={item != null ? LinkComponent : null}
1522
to={item != null ? `/item/${item._id}` : null}
1623
>

frontend/components/molecules/CardDropdown/CardDropdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function CreateMenuItemArray(groupObjectArray) {
1717
const nameArray = groupObjectArray.map((elem) => elem.name);
1818
for (let i = 0; i < groupObjectArray.length; i++) {
1919
const innerString = nameArray.slice(0, i + 1).join('>');
20-
const value = groupObjectArray[i].Id;
20+
const value = groupObjectArray[i]._id;
2121
returnArray.push({ value, innerString });
2222
}
2323
return returnArray;

frontend/components/molecules/Item/Item.js

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
mdiShare,
1010
mdiStar,
1111
mdiStarOutline,
12-
mdiUpload,
12+
mdiUpload
1313
} from "@mdi/js";
1414
import Icon from "@mdi/react";
1515
import {
@@ -20,20 +20,20 @@ import {
2020
Menu,
2121
MenuItem,
2222
Skeleton,
23-
Tooltip,
23+
Tooltip
2424
} from "@mui/material";
25-
import humanizeDuration from "humanize-duration";
2625
import R from "ramda";
2726
import React, { useEffect, useState } from "react";
2827
import { store as RNC } from "react-notifications-component";
2928
import { useDispatch, useSelector } from "react-redux";
3029
import LinkComponent from "_atoms/LinkComponent";
30+
import { dateElapsed, dateToString } from "_frontend/utils/date";
3131
import {
3232
attemptArchiveItem,
3333
attemptDeleteItem,
3434
attemptGetItem,
3535
attemptGetItemChildren,
36-
attemptPublishItem,
36+
attemptPublishItem
3737
} from "_thunks/item";
3838
import { attemptAddBookmark, attemptRemoveBookmark } from "_thunks/user";
3939
import { deepEqual } from "_utils/compare";
@@ -47,9 +47,7 @@ const borderRadius = {
4747
// Maximum number of line of the content
4848
const LINE_CLAMP = 4;
4949

50-
const content = (item, itemChildren) => {
51-
const dispatch = useDispatch();
52-
50+
const renderContent = (item, itemChildren) => {
5351
if (item == null || !item.hasOwnProperty("content")) return null;
5452

5553
if (item.type === "card") {
@@ -84,17 +82,6 @@ const content = (item, itemChildren) => {
8482
});
8583
};
8684

87-
const dateElapsed = (date) => {
88-
const created = new Date(date);
89-
const now = new Date();
90-
return `${humanizeDuration(now - created, {
91-
language: "ko",
92-
largest: 1,
93-
spacer: "",
94-
round: true,
95-
})} 전`;
96-
};
97-
9885
const statusIcon = {
9986
archived: mdiPackageDown,
10087
public: mdiEarth,
@@ -116,9 +103,7 @@ export default function Item({
116103

117104
const itemId =
118105
itemObject != null
119-
? itemObject.hasOwnProperty("Id")
120-
? itemObject.Id // id from local store
121-
: itemObject.hasOwnProperty("_id")
106+
? itemObject.hasOwnProperty("_id")
122107
? itemObject._id // id from API response
123108
: id
124109
: id; // id from props
@@ -253,7 +238,7 @@ export default function Item({
253238
? "public"
254239
: null;
255240

256-
const isCurrentUserOwner = item ? item.owner._id === user.Id : false;
241+
const isCurrentUserOwner = item ? item.owner._id === user._id : false;
257242
const isCurrentUserEditor =
258243
item != null && item.hasOwnProperty("accessGroups")
259244
? item.accessGroups.edit.includes(user.group)
@@ -292,10 +277,7 @@ export default function Item({
292277
// don't render if visible is false
293278
if (visible == false) return null;
294279

295-
const createdDate = new Date(item.created);
296-
const createdString = `${createdDate.toLocaleDateString(
297-
"ko-KR"
298-
)} ${createdDate.toLocaleTimeString("en-GB")}`;
280+
const content = renderContent(item, itemChildren)
299281

300282
return item == null ? (
301283
<div className="item" key={itemId}>
@@ -362,10 +344,18 @@ export default function Item({
362344
<div />
363345
)}
364346
</div>
365-
<div className="item-content">{content(item, itemChildren)}</div>
347+
{content != null ? (
348+
<div className="item-content">{content}</div>
349+
) : (
350+
<div className="item-content">
351+
<Skeleton width="100%" />
352+
<Skeleton width="100%" />
353+
<Skeleton width="75%" />
354+
</div>
355+
)}
366356
</ButtonBase>
367357
<div className="item-footer">
368-
<Tooltip title={createdString} arrow>
358+
<Tooltip title={dateToString(item.created)} arrow>
369359
<div className="item-description">
370360
{`${item.owner.rank} ${item.owner.name} · ${dateElapsed(
371361
item.created

frontend/components/organisms/GroupSettings/GroupSettings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function GroupSettings() {
1616

1717
// Get managing groups
1818
useEffect(() => {
19-
searchGroupByAdmin(user.Id).then((result) => setManagingGroup(result));
19+
searchGroupByAdmin(user._id).then((result) => setManagingGroup(result));
2020
}, [user]);
2121

2222
// Get group members of each groups after managing groups are fetched & Set division and admin field of each members
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Stack } from "@mui/material";
2+
import React from "react";
3+
import HorizontalScroll from 'react-scroll-horizontal';
4+
import TypeIcon from "_atoms/TypeIcon";
5+
import Item from "_molecules/Item";
6+
7+
export default function ItemList({ items, title, icon, iconType }) {
8+
return (
9+
<div className="item-list">
10+
<div className="item-list-header">
11+
{iconType != null || icon != null ? (
12+
<TypeIcon type={iconType} path={icon} size={1.5} opacity={0.7} />
13+
) : null}
14+
{title && <div className="item-list-title">{title}</div>}
15+
</div>
16+
<HorizontalScroll className="item-list-scroll">
17+
<Stack direction="row" className="item-list-content" spacing={2}>
18+
{items != null ? (
19+
items.length > 0 ? (
20+
items.map((item) => <Item key={item._id} item={item} />)
21+
) : (
22+
<div>표시할 항목이 없습니다.</div>
23+
)
24+
) : (
25+
<div>Loading...</div>
26+
)}
27+
</Stack>
28+
</HorizontalScroll>
29+
</div>
30+
);
31+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ItemList from './ItemList';
2+
3+
export default ItemList;

0 commit comments

Comments
 (0)