Skip to content

Commit 32a9069

Browse files
committed
Merge branch 'feature/frontend/#33' into develop
2 parents b5bf599 + d53aadc commit 32a9069

74 files changed

Lines changed: 1909 additions & 1479 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"version": "0.0.1",
44
"private": true,
55
"scripts": {
6-
"start": "nodemon --watch . app.js"
6+
"start": "npm run start:linux",
7+
"start:linux": "nodemon --watch . app.js",
8+
"start:windows": "nodemon --legacy-watch app.js"
79
},
810
"dependencies": {
911
"cookie-parser": "~1.4.4",

frontend/api/item.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,62 @@
11
import request from 'superagent';
2-
import { handleSuccess, handleError } from '_utils/api';
2+
import { handleError, handleSuccess } from '_utils/api';
33

4-
// from userID, get all the items the user created
5-
export const getItemByUserId = (userId) => request.get('/api/item/')
6-
.query({ owner: userId })
4+
// get item with item id
5+
export const getItem = (itemId) => request.get(`/api/item/${itemId}`)
76
.then(handleSuccess)
87
.catch(handleError);
98

10-
export const getItemByItemId = (itemId) => request.get(`/api/item/${itemId}`)
11-
// .query({ item_id: item_id })
9+
// get all items from user with user id
10+
// all item's owner property would be same current as user's id
11+
export const getUserItem = (userId) => request.get('/api/item/')
12+
.query({ owner: userId })
1213
.then(handleSuccess)
1314
.catch(handleError);
1415

15-
export const getItemChild = (itemPath) => request.get('/api/item')
16+
// get item's children if exists
17+
// searches with ?path={itemPath} query
18+
export const getItemChildren = (itemPath) => request.get('/api/item')
1619
.query({ path: itemPath })
1720
.then(handleSuccess)
1821
.catch(handleError);
1922

20-
export const getRecommendItem = (id) => request.get('/api/recommend')
21-
.query({ userId: id })
23+
// get recommended items with user id
24+
export const getRecommendItem = (userId) => request.get('/api/recommend')
25+
.query({ userId: userId })
2226
.then(handleSuccess)
2327
.catch(handleError);
2428

29+
// get Algolia search result
2530
export const algoliaSearch = (query) => request.get(`/api/item/algolia/${query}`)
2631
// .query({ query })
2732
.then(handleSuccess)
2833
.catch(handleError);
2934

35+
// update item with item id
3036
export const updateItem = (itemId, object) => request.put(`/api/item/${itemId}`)
3137
.send(object)
3238
.then(handleSuccess)
3339
.catch(handleError);
3440

41+
// update item.status to 'archived' with item id
42+
export const archiveItem = (itemId) => request.put(`/api/item/${itemId}`)
43+
.send({status: 'archived'})
44+
.then(handleSuccess)
45+
.catch(handleError);
46+
47+
// update item.status to 'published' with item id
48+
export const publishItem = (itemId) => request.put(`/api/item/${itemId}`)
49+
.send({status: 'published'})
50+
.then(handleSuccess)
51+
.catch(handleError);
52+
53+
// delete item with item id
3554
export const deleteItem = (itemId) => request.delete(`/api/item/${itemId}`)
3655
.then(handleSuccess)
3756
.catch(handleError);
3857

39-
export const createItem = (object) => request.post('api/item')
58+
// create item with object
59+
export const createItem = (object) => request.post('/api/item')
4060
.send(object)
4161
.then(handleSuccess)
4262
.catch(handleError);

frontend/api/todos.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

frontend/components/atoms/LinkComponent/LinkComponent.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { props } from "ramda";
21
import React from "react";
32
import { Link } from "react-router-dom";
43

54
// Component used to render MUI components as React Router
65
// <Link> components using MUI's `component` property.
76
// Read more here: https://mui.com/guides/composition/#caveat-with-refs
8-
export const LinkComponent = React.forwardRef((props, ref) => (
7+
export default React.forwardRef((props, ref) => (
98
<Link {...props} ref={ref}>
109
{props.children}
1110
</Link>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {
2+
mdiFileCabinet, mdiFileDocumentOutline, mdiTextBoxOutline
3+
} from "@mdi/js";
4+
import { Icon } from '@mdi/react';
5+
import React from "react";
6+
7+
const icon = {
8+
cabinet: mdiFileCabinet,
9+
document: mdiFileDocumentOutline,
10+
card: mdiTextBoxOutline,
11+
};
12+
13+
export default function TypeIcon({ type, ...props }) {
14+
return (
15+
<Icon path={icon[type]} {...props} />
16+
);
17+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import TypeIcon from './TypeIcon';
2+
3+
export default TypeIcon;

frontend/components/environment/Main/Main.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
import React, { useState, useEffect } from 'react';
21
import PropTypes from 'prop-types';
3-
import { Switch, Route, Redirect } from 'react-router';
2+
import R from 'ramda';
3+
import React, { useEffect, useState } from 'react';
44
import ReactNotification from 'react-notifications-component';
55
import { useDispatch } from 'react-redux';
6-
import R from 'ramda';
7-
8-
import { attemptGetUser } from '_thunks/user';
9-
10-
import WelcomePage from '_pages/WelcomePage';
6+
import { Redirect, Route, Switch } from 'react-router';
7+
import AboutPage from '_pages/AboutPage';
118
import LoginPage from '_pages/LoginPage';
129
import RegisterPage from '_pages/RegisterPage';
1310
import RoutingPage from '_pages/RoutingPage';
14-
15-
// import Navigation from '_organisms/Navigation';
16-
// import Footer from '_organisms/Footer';
11+
import WelcomePage from '_pages/WelcomePage';
12+
import { attemptGetUser } from '_thunks/user';
1713

1814
export default function Main({ location }) {
1915
const dispatch = useDispatch();
@@ -43,7 +39,7 @@ export default function Main({ location }) {
4339
<div className="main">
4440
<Switch>
4541
<Route exact path="/" component={WelcomePage} />
46-
<Route path="/about" component={WelcomePage} />
42+
<Route path="/about" component={AboutPage} />
4743
<Route path="/help" component={WelcomePage} />
4844
<Route path="/login" component={LoginPage} />
4945
<Route path="/register" component={RegisterPage} />
@@ -55,7 +51,9 @@ export default function Main({ location }) {
5551
<Route path="/item" component={RoutingPage} />
5652
<Route path="/account" component={RoutingPage} />
5753
<Route path="/user" component={RoutingPage} />
58-
<Route path="/leftpane" component={RoutingPage} />
54+
<Route exact path="/bookmarks" component={RoutingPage} />
55+
<Route exact path="/recents" component={RoutingPage} />
56+
<Route exact path="/drafts" component={RoutingPage} />
5957

6058
{/* 404 Fallback page */}
6159
<Route path="/error">
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { mdiChevronRight } from "@mdi/js";
2+
import { Icon } from "@mdi/react";
3+
import { Breadcrumbs, Button, Skeleton, Stack } from "@mui/material";
4+
import React from "react";
5+
import LinkComponent from "_atoms/LinkComponent";
6+
import TypeIcon from "_atoms/TypeIcon";
7+
8+
const BreadCrumbItem = ({ item = null }) => {
9+
return (
10+
<Button
11+
variant="text"
12+
size="small"
13+
sx={{ width: item != null ? "auto" : "100px", textTransform: "none" }}
14+
component={item != null ? LinkComponent : null}
15+
to={item != null ? `/item/${item._id}` : null}
16+
>
17+
<Stack direction="row" spacing={0.75} sx={{ alignItems: "center" }}>
18+
{item != null ? <TypeIcon type={item.type} size={0.75} /> : null}
19+
{item != null ? (
20+
<div className="breadcrumb-text">{item.title}</div>
21+
) : (
22+
<Skeleton width="100%" />
23+
)}
24+
</Stack>
25+
</Button>
26+
);
27+
};
28+
29+
export default function BreadCrumbs({ itemArray = null, hierarchyLevel = 3 }) {
30+
return (
31+
<Breadcrumbs
32+
sx={{
33+
".MuiBreadcrumbs-separator": { margin: 0 },
34+
}}
35+
separator={<Icon path={mdiChevronRight} size={0.75} />}
36+
>
37+
{itemArray != null
38+
? itemArray.map((item, index) => (
39+
<BreadCrumbItem item={item} key={index} />
40+
))
41+
: [...Array(hierarchyLevel).keys()].map((i, index) => (
42+
<BreadCrumbItem key={index} />
43+
))}
44+
</Breadcrumbs>
45+
);
46+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import BreadCrumbs from './BreadCrumbs';
2+
3+
export default BreadCrumbs;

0 commit comments

Comments
 (0)