Skip to content

Commit 504e0cf

Browse files
committed
Submit Project with Formik
* small tweak on cards, fixed updateProject reducer * cleaned up Filter ui, card, and buttons * adding more padding to button
1 parent a4f86c6 commit 504e0cf

File tree

35 files changed

+266
-182
lines changed

35 files changed

+266
-182
lines changed

src/components/app/App.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ import ProfilePage from '../profile-page';
3030
import ExploreProfiles from '../explore-profiles';
3131
import ExploreProjects from '../explore-projects';
3232
import ForgotPassword from '../forgot-password';
33+
import SubmitProject from '../submit-project';
3334

3435
import './App.css';
3536
import useUser from '../../hooks/use-user';
37+
import useProjects from '../../hooks/use-projects';
3638

3739
const mainContainerStyle = { marginBottom: '100px', marginTop: '50px' };
3840

@@ -53,6 +55,8 @@ library.add(
5355

5456
const App = () => {
5557
useUser(true);
58+
useProjects(true);
59+
5660
return (
5761
<ThemeProvider theme={{ mode: 'bubbly' }}>
5862
<div className="App">
@@ -70,6 +74,7 @@ const App = () => {
7074
<Route path="/profile/:id" exact component={ProfilePage} />
7175
<Route path="/signupin" exact component={SignUpIn} />
7276
<Route path="/signupin/forgotpassword" exact component={ForgotPassword} />
77+
<Route path="/submitproject" exact component={SubmitProject} />
7378
<MessengerCustomerChat pageId="1191043211036808" appId="295451067827152" />
7479
</Container>
7580
<Footer />

src/components/app/actions/project.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ export const getProject = createAction('GET_PROJECT', async (pid) => {
2323
return normalize(response, schema.project);
2424
});
2525

26-
export const updateProject = createAction('UPDATE_PROJECT', async ({ pid, values }) => {
26+
export const updateProject = createAction('UPDATE_PROJECT', async ({ values }) => {
2727
let imageURLs = [ ...values.images ];
2828
if (values.images.length > 0 && values.images[0] instanceof File) {
29-
await storage.deleteProjectImages(pid);
30-
imageURLs = await storage.uploadProjectImages(pid, imageURLs);
29+
await storage.deleteProjectImages(values.id);
30+
imageURLs = await storage.uploadProjectImages(values.id, imageURLs);
3131
}
3232
// update Project
33-
await db.update('projects')(pid)({
34-
...values,
33+
const { id, ...rest } = values;
34+
await db.update('projects')(values.id)({
35+
...rest,
3536
images: imageURLs,
3637
});
3738
return normalize({ ...values, images: imageURLs }, schema.project);

src/components/create-project/CreateProject.jsx

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

src/components/create-project/components/create-button/CreateButton.jsx

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

src/components/create-project/components/create-button/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/create-project/components/new-project-modal/NewProjectModal.jsx

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

src/components/create-project/components/new-project-modal/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/create-project/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/explore-projects/ExploreProjects.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ProjectList from './components/project-list';
66
import useProjects from '../../hooks/use-projects';
77

88
const Header = styled.h2`
9-
margin-bottom: 20px;
9+
margin-bottom: 0px;
1010
`;
1111

1212
const filterTypes = [ 'project-category', 'release-status', 'organization' ];

src/components/home/Home.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const Home = ({ history }) => {
2121
<Header>
2222
<h1>Find any opportunity anytime. </h1>
2323
<Banner
24+
gotoSubmit={() => history.push('/submitproject')}
2425
goToSignUp={() => history.push('/signupin')}
2526
goToAbout={() => history.push('/about')}
2627
/>

src/components/home/components/banner/Banner.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import styled from 'styled-components';
33
import Button from '../../../shared/button';
4-
import CreateProject from '../../../create-project';
54

65
const Container = styled.div`
76
span {
@@ -10,13 +9,15 @@ const Container = styled.div`
109
}
1110
`;
1211

13-
const Banner = ({ goToSignUp, goToAbout }) => (
12+
const Banner = ({ goToSignUp, goToAbout, gotoSubmit }) => (
1413
<Container>
1514
<Button variant="link" onClick={goToAbout}>
1615
Learn More
1716
</Button>
1817
<span>&emsp; | &emsp;</span>
19-
<CreateProject />
18+
<Button variant="link" onClick={gotoSubmit}>
19+
Submit a Project
20+
</Button>
2021
<span>&emsp; | &emsp;</span>
2122
<Button variant="link" onClick={goToSignUp}>
2223
Sign Up

src/components/project-page/components/dashboard/Dashboard.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ const Dashboard = ({ pid, onClose }) => {
9292
};
9393

9494
const handleSubmit = (values) => {
95-
const { id, ...rest } = values;
96-
updateProject({ pid, values: rest });
95+
updateProject({ values });
9796
setTimeout(onClose, 3000);
9897
};
9998

src/components/shared/button/Button.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const buttonStyle = theme.variants('mode', 'variant', {
88
border: 2px solid ${ props => props.color || '#ff6e6e' };
99
color: ${ props => props.color || '#ff6e6e' };
1010
font-weight: bold;
11-
1211
:focus {
1312
outline: 0;
1413
box-shadow: 0 0 0 0.2rem #d7d9e8;
@@ -51,9 +50,10 @@ const buttonStyle = theme.variants('mode', 'variant', {
5150
});
5251

5352
const Button = styled.button`
54-
padding: 0.2em 1em;
53+
padding: 0.4em 1em;
5554
font-family: HelveticaNeue;
5655
border-radius: 3px;
56+
background: white;
5757
${ buttonStyle }
5858
`;
5959

src/components/shared/card/Card.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const Container = styled.div`
1212
display: flex;
1313
flex-direction: column;
1414
border: 1px solid rgba(33, 33, 33, 0.2);
15-
border-radius: 0.5rem;
16-
margin-bottom: 10px;
15+
border-radius: 2rem;
16+
margin-bottom: 30px;
1717
min-width: 318px;
1818
max-width: 320px;
1919

src/components/shared/card/components/card-image/CardImage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Container = styled.div`
1212

1313
const CardImage = ({ image }) => (
1414
<Container>
15-
<img src={image || 'https://via.placeholder.com/300'} alt="project cover" />
15+
{image && <img src={image || 'https://via.placeholder.com/300'} alt="project cover" />}
1616
</Container>
1717
);
1818

src/components/shared/filter/Filter.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SearchBar from './components/search-bar';
99

1010
const Container = styled.div`
1111
margin-bottom: 10px;
12+
padding: 15px 20px;
1213
`;
1314

1415
const Filter = ({ types, onFilter }) => {

src/components/shared/filter/components/filter-dropdown/FilterDropdown.jsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React from 'react';
2-
import { Dropdown,
2+
import {
3+
Dropdown,
34
DropdownMenu,
45
DropdownToggle,
56
DropdownItem,
67
Col,
78
Label,
8-
Input } from 'reactstrap';
9+
Input,
10+
} from 'reactstrap';
911

1012
const DropdownElement = ({ checked, index, label, onSelect }) => (
1113
<DropdownItem onClick={() => onSelect(index)}>
@@ -16,15 +18,26 @@ const DropdownElement = ({ checked, index, label, onSelect }) => (
1618
</DropdownItem>
1719
);
1820

19-
const MenuModifiers = { setMaxHeight: { enabled: true,
20-
order: 890,
21-
fn: data => ({ ...data, styles: { ...data.styles, overflow: 'auto', maxHeight: 200 } }) } };
21+
const titles = {
22+
'project-category': 'Discipline',
23+
'release-status': 'Status',
24+
organization: 'Organization Type',
25+
};
26+
const getMappedTitle = title => titles[title];
27+
28+
const MenuModifiers = {
29+
setMaxHeight: {
30+
enabled: true,
31+
order: 890,
32+
fn: data => ({ ...data, styles: { ...data.styles, overflow: 'auto', maxHeight: 200 } }),
33+
},
34+
};
2235

2336
const FilterDropdown = ({ isOpen, toggle, title, filterItems, onSelect }) => (
2437
<Col>
2538
<Dropdown style={{ marginTop: 5 }} isOpen={isOpen} toggle={toggle}>
2639
<DropdownToggle caret tag="span" style={{ cursor: 'pointer' }}>
27-
{title}
40+
{getMappedTitle(title)}
2841
</DropdownToggle>
2942
<DropdownMenu modifiers={MenuModifiers}>
3043
{filterItems.map((item, i) => (

src/components/shared/filter/components/tag/Tag.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import React from 'react';
33
import styled from 'styled-components';
44

5-
import { Button } from 'reactstrap';
65
import { Icon } from 'react-icons-kit';
76
import { ic_clear } from 'react-icons-kit/md/ic_clear';
7+
import Button from '../../../button';
88

99
const Tag = ({ text, handleCancel, className }) => (
10-
<Button onClick={handleCancel} className={className}>
10+
<Button color="#A6A7AB" onClick={handleCancel} className={className}>
1111
{text} <Icon icon={ic_clear} />
1212
</Button>
1313
);

src/components/shared/footer/Footer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ const Container = styled.footer`
1212
}
1313
`;
1414

15-
const Footer = () => <Container>©Thinkspaces 2018. All rights reserved.</Container>;
15+
const Footer = () => <Container>©Thinkspaces 2019. All rights reserved.</Container>;
1616

1717
export default Footer;

src/components/shared/navbar/Navbar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const Navbar = () => {
6060
</NavLink>
6161
</NavItem>
6262
<NavItem>
63-
<NavLink className="nav" to="/">
63+
<NavLink className="nav" to="/submitproject">
6464
Submit a Project
6565
</NavLink>
6666
</NavItem>

0 commit comments

Comments
 (0)