Skip to content

Commit 0729ca9

Browse files
author
Pavlenko Viktor
committed
initial
0 parents  commit 0729ca9

Some content is hidden

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

55 files changed

+1217
-0
lines changed

Diff for: .env.example

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NODE_ENV = "development"
2+
SESSION_NAME = "name"
3+
SESSION_SECRET = "secret"
4+
SESSION_MAX_AGE = 7200000 #1000 * 60 * 60 * 2
5+
MONGO_DB_URI = "mongodb+srv://user:password@hostname/test?retryWrites=true&w=majority"
6+
EMAIL_USER = "[email protected]"
7+
EMAIL_PASSWORD = "exaplepassword"

Diff for: .eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
public
3+
dist

Diff for: .eslintrc.json

Whitespace-only changes.

Diff for: .gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.env
2+
node_modules
3+
dist
4+
*.log
5+
package-lock.json
6+
yarn.lock

Diff for: .idea/.gitignore

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/codeStyles/Project.xml

+39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/codeStyles/codeStyleConfig.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/fuck.iml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/inspectionProfiles/Project_Default.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/jsLibraryMappings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/misc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
public

Diff for: .prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"printWidth": 100
4+
}

Diff for: .travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
language: node_js
2+
3+
node_js:
4+
- 8
5+
6+
script:
7+
- npm run build
8+
9+
branches:
10+
only:
11+
- gh-pages
12+
- /.*/

Diff for: LICENSE

Whitespace-only changes.

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
yarn install:all
2+
yarn dev

Diff for: lerna.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"packages": ["src/*"],
3+
"version": "independent"
4+
}

Diff for: package.json

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "vp-test",
3+
"version": "1.0.0",
4+
"description": "test",
5+
"scripts": {
6+
"dev": "lerna exec -- npm run --parallel dev",
7+
"lint": "eslint '**/*.{js,jsx}'",
8+
"lint:fix": "npm run lint -- --fix",
9+
"test": "lerna run --parallel test",
10+
"install:all": "npm install && lerna bootstrap"
11+
},
12+
"devDependencies": {
13+
"babel-eslint": "^10.0.1",
14+
"eslint": "^6.0.1",
15+
"eslint-config-prettier": "^6.0.0",
16+
"eslint-config-standard": "^13.0.1",
17+
"eslint-plugin-import": "^2.18.0",
18+
"eslint-plugin-jest": "^22.6.4",
19+
"eslint-plugin-jsx-a11y": "^6.2.1",
20+
"eslint-plugin-node": "^9.1.0",
21+
"eslint-plugin-prettier": "^3.1.0",
22+
"eslint-plugin-promise": "^4.2.1",
23+
"eslint-plugin-react": "^7.14.2",
24+
"eslint-plugin-standard": "^4.0.0",
25+
"husky": "^3.0.0",
26+
"lerna": "^3.15.0",
27+
"lint-staged": "^9.2.0",
28+
"prettier": "^1.18.2"
29+
},
30+
"husky": {
31+
"hooks": {
32+
"pre-commit": "lint-staged"
33+
}
34+
},
35+
"lint-staged": {
36+
"*.{js,jsx}": [
37+
"eslint"
38+
],
39+
"*.{js,jsx,json,md}": [
40+
"prettier --list-different"
41+
],
42+
"*.js": [
43+
"eslint --fix",
44+
"git add"
45+
]
46+
},
47+
"author": "Victor Pavlenko"
48+
}

Diff for: src/client/App.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Switch, Route } from 'react-router-dom';
4+
5+
import UsersList from './pages/UsersList';
6+
import NotFound from './pages/NotFound';
7+
8+
const App = () => {
9+
return (
10+
<Switch>
11+
<Route exact path="/" component={UsersList} />
12+
<Route component={NotFound} />
13+
</Switch>
14+
);
15+
};
16+
17+
App.propTypes = {
18+
history: PropTypes.object
19+
};
20+
21+
export default App;

Diff for: src/client/components/Layouts/index.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import { Container, Typography } from '@material-ui/core';
3+
4+
5+
const Layout = props => {
6+
7+
8+
return (
9+
<div className="layout" style={{ minHeight: '100vh', background: "#f5deb3" }}>
10+
<Container maxWidth="lg">
11+
<br/>
12+
<header style={{ height: 'unset', textAlign: 'center' }} ><Typography variant="h1">Header</Typography></header>
13+
<br/>
14+
<div>{props.children}</div>
15+
<br/>
16+
<footer style={{ textAlign: 'center' }}><Typography variant="h2">Footer</Typography></footer>
17+
<br/>
18+
</Container>
19+
</div>
20+
);
21+
};
22+
23+
export default Layout;

Diff for: src/client/components/UserList/create.js

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { useForm } from 'react-hook-form';
2+
import { useMutation } from '@apollo/react-hooks';
3+
import schema from '../../graphql/graphql';
4+
import { makeStyles } from '@material-ui/core/styles';
5+
import { Button, Dialog, DialogTitle, TextField, CircularProgress } from '@material-ui/core';
6+
import React from 'react';
7+
import validators from '../../validators';
8+
9+
function CreateUserDialog(props) {
10+
const { onClose, open, limit, skip } = props;
11+
12+
13+
const { register, handleSubmit, watch, errors } = useForm({
14+
validationSchema: validators.user.userSchema,
15+
reValidateMode: 'onChange',
16+
});
17+
18+
const updateCache = (cache, {data}) => {
19+
20+
let show = schema.queries.SHOW_USERS
21+
22+
const users = cache.readQuery({
23+
query: show,
24+
variables: {
25+
limit,
26+
skip
27+
}
28+
});
29+
30+
users.users.push(data.createUser)
31+
32+
cache.writeQuery({
33+
query: schema.queries.SHOW_USERS,
34+
data: { users: users.users },
35+
variables: {
36+
limit,
37+
skip
38+
}
39+
});
40+
};
41+
42+
43+
const [createUser, { loading, error }] = useMutation(schema.mutations.CREATE_USER, { update: updateCache});
44+
45+
const onSubmitCreateUserForm = input => {
46+
try{
47+
let { data } = createUser({ variables: { input } });
48+
49+
if(data) {
50+
onClose()
51+
}
52+
} catch (e) {
53+
e.graphQLErrors.map(x => {
54+
console.log(x.message);
55+
});
56+
}
57+
}
58+
59+
const useStyles = makeStyles((theme) => ({
60+
root: {
61+
'& > *': {
62+
margin: theme.spacing(1),
63+
width: 'calc(100% - 16px)',
64+
display: 'flex'
65+
}
66+
},
67+
}));
68+
const classes = useStyles();
69+
70+
const handleClose = () => {
71+
onClose();
72+
};
73+
74+
return (
75+
<Dialog onClose={handleClose} aria-labelledby="simple-dialog-title" open={open}>
76+
<DialogTitle id="simple-dialog-title">Create user</DialogTitle>
77+
{loading ? <CircularProgress /> :
78+
<form className={classes.root} noValidate autoComplete="off" onSubmit={handleSubmit(onSubmitCreateUserForm)}>
79+
<TextField id="standard-basic" label="Name" name="name" variant="outlined"
80+
inputRef={register}
81+
error={errors.name}
82+
helperText={errors.name ? errors.name.message : ''}
83+
/>
84+
<TextField id="standard-basic" label="Email" name="email" variant="outlined"
85+
inputRef={register}
86+
error={errors.email}
87+
helperText={errors.email ? errors.email.message : ''}
88+
/>
89+
<Button type="submit" variant="contained" color="primary">
90+
Create User
91+
</Button>
92+
</form>
93+
}
94+
</Dialog>
95+
);
96+
}
97+
98+
export default CreateUserDialog

Diff for: src/client/components/UserList/index.css

Whitespace-only changes.

0 commit comments

Comments
 (0)