송용우

Update Challenge Layout

...@@ -1982,9 +1982,9 @@ ...@@ -1982,9 +1982,9 @@
1982 } 1982 }
1983 }, 1983 },
1984 "@material-ui/core": { 1984 "@material-ui/core": {
1985 - "version": "4.10.2", 1985 + "version": "4.11.0",
1986 - "resolved": "https://registry.npmjs.org/@material-ui/core/-/core-4.10.2.tgz", 1986 + "resolved": "https://registry.npmjs.org/@material-ui/core/-/core-4.11.0.tgz",
1987 - "integrity": "sha512-Uf4iDLi9sW6HKbVQDyDZDr1nMR4RUAE7w/RIIJZGNVZResC0xwmpLRZMtaUdSO43N0R0yJehfxTi4Z461Cd49A==", 1987 + "integrity": "sha512-bYo9uIub8wGhZySHqLQ833zi4ZML+XCBE1XwJ8EuUVSpTWWG57Pm+YugQToJNFsEyiKFhPh8DPD0bgupz8n01g==",
1988 "requires": { 1988 "requires": {
1989 "@babel/runtime": "^7.4.4", 1989 "@babel/runtime": "^7.4.4",
1990 "@material-ui/styles": "^4.10.0", 1990 "@material-ui/styles": "^4.10.0",
...@@ -2000,6 +2000,18 @@ ...@@ -2000,6 +2000,18 @@
2000 "react-transition-group": "^4.4.0" 2000 "react-transition-group": "^4.4.0"
2001 } 2001 }
2002 }, 2002 },
2003 + "@material-ui/lab": {
2004 + "version": "4.0.0-alpha.56",
2005 + "resolved": "https://registry.npmjs.org/@material-ui/lab/-/lab-4.0.0-alpha.56.tgz",
2006 + "integrity": "sha512-xPlkK+z/6y/24ka4gVJgwPfoCF4RCh8dXb1BNE7MtF9bXEBLN/lBxNTK8VAa0qm3V2oinA6xtUIdcRh0aeRtVw==",
2007 + "requires": {
2008 + "@babel/runtime": "^7.4.4",
2009 + "@material-ui/utils": "^4.10.2",
2010 + "clsx": "^1.0.4",
2011 + "prop-types": "^15.7.2",
2012 + "react-is": "^16.8.0"
2013 + }
2014 + },
2003 "@material-ui/styles": { 2015 "@material-ui/styles": {
2004 "version": "4.10.0", 2016 "version": "4.10.0",
2005 "resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.10.0.tgz", 2017 "resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.10.0.tgz",
...@@ -5322,12 +5334,19 @@ ...@@ -5322,12 +5334,19 @@
5322 } 5334 }
5323 }, 5335 },
5324 "dom-helpers": { 5336 "dom-helpers": {
5325 - "version": "5.1.4", 5337 + "version": "5.2.0",
5326 - "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.1.4.tgz", 5338 + "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.0.tgz",
5327 - "integrity": "sha512-TjMyeVUvNEnOnhzs6uAn9Ya47GmMo3qq7m+Lr/3ON0Rs5kHvb8I+SQYjLUSYn7qhEm0QjW0yrBkvz9yOrwwz1A==", 5339 + "integrity": "sha512-Ru5o9+V8CpunKnz5LGgWXkmrH/20cGKwcHwS4m73zIvs54CN9epEmT/HLqFJW3kXpakAFkEdzgy1hzlJe3E4OQ==",
5328 "requires": { 5340 "requires": {
5329 "@babel/runtime": "^7.8.7", 5341 "@babel/runtime": "^7.8.7",
5330 - "csstype": "^2.6.7" 5342 + "csstype": "^3.0.2"
5343 + },
5344 + "dependencies": {
5345 + "csstype": {
5346 + "version": "3.0.3",
5347 + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.3.tgz",
5348 + "integrity": "sha512-jPl+wbWPOWJ7SXsWyqGRk3lGecbar0Cb0OvZF/r/ZU011R4YqiRehgkQ9p4eQfo9DSDLqLL3wHwfxeJiuIsNag=="
5349 + }
5331 } 5350 }
5332 }, 5351 },
5333 "dom-serializer": { 5352 "dom-serializer": {
...@@ -7343,9 +7362,9 @@ ...@@ -7343,9 +7362,9 @@
7343 "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=" 7362 "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM="
7344 }, 7363 },
7345 "hyphenate-style-name": { 7364 "hyphenate-style-name": {
7346 - "version": "1.0.3", 7365 + "version": "1.0.4",
7347 - "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.3.tgz", 7366 + "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz",
7348 - "integrity": "sha512-EcuixamT82oplpoJ2XU4pDtKGWQ7b00CD9f1ug9IaQ3p1bkHMiKCZ9ut9QDI6qsa6cpUuB+A/I+zLtdNK4n2DQ==" 7367 + "integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ=="
7349 }, 7368 },
7350 "iconv-lite": { 7369 "iconv-lite": {
7351 "version": "0.4.24", 7370 "version": "0.4.24",
...@@ -8537,81 +8556,88 @@ ...@@ -8537,81 +8556,88 @@
8537 } 8556 }
8538 }, 8557 },
8539 "jss": { 8558 "jss": {
8540 - "version": "10.3.0", 8559 + "version": "10.4.0",
8541 - "resolved": "https://registry.npmjs.org/jss/-/jss-10.3.0.tgz", 8560 + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz",
8542 - "integrity": "sha512-B5sTRW9B6uHaUVzSo9YiMEOEp3UX8lWevU0Fsv+xtRnsShmgCfIYX44bTH8bPJe6LQKqEXku3ulKuHLbxBS97Q==", 8561 + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==",
8543 "requires": { 8562 "requires": {
8544 "@babel/runtime": "^7.3.1", 8563 "@babel/runtime": "^7.3.1",
8545 - "csstype": "^2.6.5", 8564 + "csstype": "^3.0.2",
8546 "is-in-browser": "^1.1.3", 8565 "is-in-browser": "^1.1.3",
8547 "tiny-warning": "^1.0.2" 8566 "tiny-warning": "^1.0.2"
8567 + },
8568 + "dependencies": {
8569 + "csstype": {
8570 + "version": "3.0.3",
8571 + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.3.tgz",
8572 + "integrity": "sha512-jPl+wbWPOWJ7SXsWyqGRk3lGecbar0Cb0OvZF/r/ZU011R4YqiRehgkQ9p4eQfo9DSDLqLL3wHwfxeJiuIsNag=="
8573 + }
8548 } 8574 }
8549 }, 8575 },
8550 "jss-plugin-camel-case": { 8576 "jss-plugin-camel-case": {
8551 - "version": "10.3.0", 8577 + "version": "10.4.0",
8552 - "resolved": "https://registry.npmjs.org/jss-plugin-camel-case/-/jss-plugin-camel-case-10.3.0.tgz", 8578 + "resolved": "https://registry.npmjs.org/jss-plugin-camel-case/-/jss-plugin-camel-case-10.4.0.tgz",
8553 - "integrity": "sha512-tadWRi/SLWqLK3EUZEdDNJL71F3ST93Zrl9JYMjV0QDqKPAl0Liue81q7m/nFUpnSTXczbKDy4wq8rI8o7WFqA==", 8579 + "integrity": "sha512-9oDjsQ/AgdBbMyRjc06Kl3P8lDCSEts2vYZiPZfGAxbGCegqE4RnMob3mDaBby5H9vL9gWmyyImhLRWqIkRUCw==",
8554 "requires": { 8580 "requires": {
8555 "@babel/runtime": "^7.3.1", 8581 "@babel/runtime": "^7.3.1",
8556 "hyphenate-style-name": "^1.0.3", 8582 "hyphenate-style-name": "^1.0.3",
8557 - "jss": "^10.3.0" 8583 + "jss": "10.4.0"
8558 } 8584 }
8559 }, 8585 },
8560 "jss-plugin-default-unit": { 8586 "jss-plugin-default-unit": {
8561 - "version": "10.3.0", 8587 + "version": "10.4.0",
8562 - "resolved": "https://registry.npmjs.org/jss-plugin-default-unit/-/jss-plugin-default-unit-10.3.0.tgz", 8588 + "resolved": "https://registry.npmjs.org/jss-plugin-default-unit/-/jss-plugin-default-unit-10.4.0.tgz",
8563 - "integrity": "sha512-tT5KkIXAsZOSS9WDSe8m8lEHIjoEOj4Pr0WrG0WZZsMXZ1mVLFCSsD2jdWarQWDaRNyMj/I4d7czRRObhOxSuw==", 8589 + "integrity": "sha512-BYJ+Y3RUYiMEgmlcYMLqwbA49DcSWsGgHpVmEEllTC8MK5iJ7++pT9TnKkKBnNZZxTV75ycyFCR5xeLSOzVm4A==",
8564 "requires": { 8590 "requires": {
8565 "@babel/runtime": "^7.3.1", 8591 "@babel/runtime": "^7.3.1",
8566 - "jss": "^10.3.0" 8592 + "jss": "10.4.0"
8567 } 8593 }
8568 }, 8594 },
8569 "jss-plugin-global": { 8595 "jss-plugin-global": {
8570 - "version": "10.3.0", 8596 + "version": "10.4.0",
8571 - "resolved": "https://registry.npmjs.org/jss-plugin-global/-/jss-plugin-global-10.3.0.tgz", 8597 + "resolved": "https://registry.npmjs.org/jss-plugin-global/-/jss-plugin-global-10.4.0.tgz",
8572 - "integrity": "sha512-etYTG/y3qIR/vxZnKY+J3wXwObyBDNhBiB3l/EW9/pE3WHE//BZdK8LFvQcrCO48sZW1Z6paHo6klxUPP7WbzA==", 8598 + "integrity": "sha512-b8IHMJUmv29cidt3nI4bUI1+Mo5RZE37kqthaFpmxf5K7r2aAegGliAw4hXvA70ca6ckAoXMUl4SN/zxiRcRag==",
8573 "requires": { 8599 "requires": {
8574 "@babel/runtime": "^7.3.1", 8600 "@babel/runtime": "^7.3.1",
8575 - "jss": "^10.3.0" 8601 + "jss": "10.4.0"
8576 } 8602 }
8577 }, 8603 },
8578 "jss-plugin-nested": { 8604 "jss-plugin-nested": {
8579 - "version": "10.3.0", 8605 + "version": "10.4.0",
8580 - "resolved": "https://registry.npmjs.org/jss-plugin-nested/-/jss-plugin-nested-10.3.0.tgz", 8606 + "resolved": "https://registry.npmjs.org/jss-plugin-nested/-/jss-plugin-nested-10.4.0.tgz",
8581 - "integrity": "sha512-qWiEkoXNEkkZ+FZrWmUGpf+zBsnEOmKXhkjNX85/ZfWhH9dfGxUCKuJFuOWFM+rjQfxV4csfesq4hY0jk8Qt0w==", 8607 + "integrity": "sha512-cKgpeHIxAP0ygeWh+drpLbrxFiak6zzJ2toVRi/NmHbpkNaLjTLgePmOz5+67ln3qzJiPdXXJB1tbOyYKAP4Pw==",
8582 "requires": { 8608 "requires": {
8583 "@babel/runtime": "^7.3.1", 8609 "@babel/runtime": "^7.3.1",
8584 - "jss": "^10.3.0", 8610 + "jss": "10.4.0",
8585 "tiny-warning": "^1.0.2" 8611 "tiny-warning": "^1.0.2"
8586 } 8612 }
8587 }, 8613 },
8588 "jss-plugin-props-sort": { 8614 "jss-plugin-props-sort": {
8589 - "version": "10.3.0", 8615 + "version": "10.4.0",
8590 - "resolved": "https://registry.npmjs.org/jss-plugin-props-sort/-/jss-plugin-props-sort-10.3.0.tgz", 8616 + "resolved": "https://registry.npmjs.org/jss-plugin-props-sort/-/jss-plugin-props-sort-10.4.0.tgz",
8591 - "integrity": "sha512-boetORqL/lfd7BWeFD3K+IyPqyIC+l3CRrdZr+NPq7Noqp+xyg/0MR7QisgzpxCEulk+j2CRcEUoZsvgPC4nTg==", 8617 + "integrity": "sha512-j/t0R40/2fp+Nzt6GgHeUFnHVY2kPGF5drUVlgkcwYoHCgtBDOhTTsOfdaQFW6sHWfoQYgnGV4CXdjlPiRrzwA==",
8592 "requires": { 8618 "requires": {
8593 "@babel/runtime": "^7.3.1", 8619 "@babel/runtime": "^7.3.1",
8594 - "jss": "^10.3.0" 8620 + "jss": "10.4.0"
8595 } 8621 }
8596 }, 8622 },
8597 "jss-plugin-rule-value-function": { 8623 "jss-plugin-rule-value-function": {
8598 - "version": "10.3.0", 8624 + "version": "10.4.0",
8599 - "resolved": "https://registry.npmjs.org/jss-plugin-rule-value-function/-/jss-plugin-rule-value-function-10.3.0.tgz", 8625 + "resolved": "https://registry.npmjs.org/jss-plugin-rule-value-function/-/jss-plugin-rule-value-function-10.4.0.tgz",
8600 - "integrity": "sha512-7WiMrKIHH3rwxTuJki9+7nY11r1UXqaUZRhHvqTD4/ZE+SVhvtD5Tx21ivNxotwUSleucA/8boX+NF21oXzr5Q==", 8626 + "integrity": "sha512-w8504Cdfu66+0SJoLkr6GUQlEb8keHg8ymtJXdVHWh0YvFxDG2l/nS93SI5Gfx0fV29dO6yUugXnKzDFJxrdFQ==",
8601 "requires": { 8627 "requires": {
8602 "@babel/runtime": "^7.3.1", 8628 "@babel/runtime": "^7.3.1",
8603 - "jss": "^10.3.0", 8629 + "jss": "10.4.0",
8604 "tiny-warning": "^1.0.2" 8630 "tiny-warning": "^1.0.2"
8605 } 8631 }
8606 }, 8632 },
8607 "jss-plugin-vendor-prefixer": { 8633 "jss-plugin-vendor-prefixer": {
8608 - "version": "10.3.0", 8634 + "version": "10.4.0",
8609 - "resolved": "https://registry.npmjs.org/jss-plugin-vendor-prefixer/-/jss-plugin-vendor-prefixer-10.3.0.tgz", 8635 + "resolved": "https://registry.npmjs.org/jss-plugin-vendor-prefixer/-/jss-plugin-vendor-prefixer-10.4.0.tgz",
8610 - "integrity": "sha512-sZQbrcZyP5V0ADjCLwUA1spVWoaZvM7XZ+2fSeieZFBj31cRsnV7X70FFDerMHeiHAXKWzYek+67nMDjhrZAVQ==", 8636 + "integrity": "sha512-DpF+/a+GU8hMh/948sBGnKSNfKkoHg2p9aRFUmyoyxgKjOeH9n74Ht3Yt8lOgdZsuWNJbPrvaa3U4PXKwxVpTQ==",
8611 "requires": { 8637 "requires": {
8612 "@babel/runtime": "^7.3.1", 8638 "@babel/runtime": "^7.3.1",
8613 "css-vendor": "^2.0.8", 8639 "css-vendor": "^2.0.8",
8614 - "jss": "^10.3.0" 8640 + "jss": "10.4.0"
8615 } 8641 }
8616 }, 8642 },
8617 "jsx-ast-utils": { 8643 "jsx-ast-utils": {
...@@ -8928,6 +8954,11 @@ ...@@ -8928,6 +8954,11 @@
8928 "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 8954 "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
8929 "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 8955 "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
8930 }, 8956 },
8957 + "memoize-one": {
8958 + "version": "5.1.1",
8959 + "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.1.1.tgz",
8960 + "integrity": "sha512-HKeeBpWvqiVJD57ZUAsJNm71eHTykffzcLZVYWiVfQeI1rJtuEaS7hQiEpWfVVk18donPwJEcFKIkCmPJNOhHA=="
8961 + },
8931 "memory-fs": { 8962 "memory-fs": {
8932 "version": "0.4.1", 8963 "version": "0.4.1",
8933 "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", 8964 "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz",
...@@ -14326,6 +14357,15 @@ ...@@ -14326,6 +14357,15 @@
14326 "whatwg-fetch": "^3.0.0" 14357 "whatwg-fetch": "^3.0.0"
14327 } 14358 }
14328 }, 14359 },
14360 + "react-calendar-heatmap": {
14361 + "version": "1.8.1",
14362 + "resolved": "https://registry.npmjs.org/react-calendar-heatmap/-/react-calendar-heatmap-1.8.1.tgz",
14363 + "integrity": "sha512-4Hbq/pDMJoCPzZnyIWFfHgokLlLXzKyGsDcMgNhYpi7zcKHcvsK9soLEPvhW2dBBqgDrQOSp/uG4wtifaDg4eQ==",
14364 + "requires": {
14365 + "memoize-one": "^5.0.0",
14366 + "prop-types": "^15.6.2"
14367 + }
14368 + },
14329 "react-dev-utils": { 14369 "react-dev-utils": {
14330 "version": "10.2.1", 14370 "version": "10.2.1",
14331 "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-10.2.1.tgz", 14371 "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-10.2.1.tgz",
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
3 "version": "0.1.0", 3 "version": "0.1.0",
4 "private": true, 4 "private": true,
5 "dependencies": { 5 "dependencies": {
6 - "@material-ui/core": "^4.10.2", 6 + "@material-ui/core": "^4.11.0",
7 + "@material-ui/lab": "^4.0.0-alpha.56",
7 "@testing-library/jest-dom": "^4.2.4", 8 "@testing-library/jest-dom": "^4.2.4",
8 "@testing-library/react": "^9.3.2", 9 "@testing-library/react": "^9.3.2",
9 "@testing-library/user-event": "^7.1.2", 10 "@testing-library/user-event": "^7.1.2",
......
1 import React from 'react'; 1 import React from 'react';
2 import { makeStyles } from '@material-ui/core/styles'; 2 import { makeStyles } from '@material-ui/core/styles';
3 +import Accordion from '@material-ui/core/Accordion';
4 +import AccordionSummary from '@material-ui/core/AccordionSummary';
5 +import AccordionDetails from '@material-ui/core/AccordionDetails';
3 import Paper from '@material-ui/core/Paper'; 6 import Paper from '@material-ui/core/Paper';
4 import Grid from '@material-ui/core/Grid'; 7 import Grid from '@material-ui/core/Grid';
8 +import TextField from '@material-ui/core/TextField';
9 +import Autocomplete from '@material-ui/lab/Autocomplete';
5 import palette from '../../lib/styles/palette'; 10 import palette from '../../lib/styles/palette';
11 +import Typography from '@material-ui/core/Typography';
12 +
13 +const useStyles = makeStyles((theme) => ({
14 + root: {
15 + flexGrow: 1,
16 + background: palette.gray[2],
17 + padding: theme.spacing(8),
18 + },
19 + paper: {
20 + padding: theme.spacing(8),
21 + margin: 'auto',
22 + textAlign: 'center',
23 + color: theme.palette.text.secondary,
24 + },
25 +}));
26 +
6 const ChallengeForm = () => { 27 const ChallengeForm = () => {
7 - return <div></div>; 28 + const classes = useStyles();
29 + return (
30 + <div className={classes.root}>
31 + <Grid container spacing={5}>
32 + <Grid item xs={12}>
33 + <Accordion>
34 + <AccordionSummary>
35 + <Typography>챌린지 참여하기</Typography>
36 + </AccordionSummary>
37 + <AccordionDetails>
38 + <Paper className={classes.paper}>
39 + 챌린지 참여하기
40 + <Autocomplete
41 + style={{ width: 300 }}
42 + options={['전체', '준비', '진행 중', '마감']}
43 + renderInput={(params) => (
44 + <TextField
45 + {...params}
46 + label="검색 기준"
47 + variant="outlined"
48 + inputProps={{
49 + ...params.inputProps,
50 + Autocomplete: 'new-password',
51 + }}
52 + />
53 + )}
54 + />
55 + </Paper>
56 + </AccordionDetails>
57 + </Accordion>
58 + </Grid>
59 + <Grid item xs={12}>
60 + <Paper className={classes.paper}>
61 + 참여중인 챌린지
62 + <Autocomplete
63 + style={{ width: 300 }}
64 + options={['전체', '준비', '진행 중', '마감']}
65 + renderInput={(params) => (
66 + <TextField
67 + {...params}
68 + label="검색 기준"
69 + variant="outlined"
70 + inputProps={{
71 + ...params.inputProps,
72 + Autocomplete: 'new-password',
73 + }}
74 + />
75 + )}
76 + />
77 + <Grid container spacing={5}>
78 + <Grid item xs={4}>
79 + <Paper className={classes.paper}>
80 + 챌린지 이름, 기간, 참여 인원수
81 + </Paper>
82 + </Grid>
83 + <Grid item xs={4}>
84 + <Paper className={classes.paper}> 배경 변경 필요</Paper>
85 + </Grid>
86 + <Grid item xs={4}>
87 + <Paper className={classes.paper}>test3</Paper>
88 + </Grid>
89 + <Grid item xs={4}>
90 + <Paper className={classes.paper}>test4</Paper>
91 + </Grid>
92 + </Grid>
93 + </Paper>
94 + </Grid>
95 + </Grid>
96 + </div>
97 + );
8 }; 98 };
9 99
10 /* 100 /*
11 -Todo 101 +TODO:
102 +챌린지 목록
12 챌린지 이름 103 챌린지 이름
13 챌린지 기간 (Start - End) 104 챌린지 기간 (Start - End)
14 챌린지 세션 정보 (일 간격과 목표 문제) 105 챌린지 세션 정보 (일 간격과 목표 문제)
......
...@@ -50,6 +50,7 @@ const HomeForm = ({ PSdata, HMArr, goalNum }) => { ...@@ -50,6 +50,7 @@ const HomeForm = ({ PSdata, HMArr, goalNum }) => {
50 </Grid> 50 </Grid>
51 <Grid item xs={12}> 51 <Grid item xs={12}>
52 <Paper className={classes.paper}> 52 <Paper className={classes.paper}>
53 + <h1>알고리즘 기록</h1>
53 <HeatMap HMArr={HMArr} /> 54 <HeatMap HMArr={HMArr} />
54 </Paper> 55 </Paper>
55 </Grid> 56 </Grid>
......
...@@ -4,7 +4,7 @@ import { withRouter } from 'react-router-dom'; ...@@ -4,7 +4,7 @@ import { withRouter } from 'react-router-dom';
4 import ChallengeForm from '../../components/challenge/ChallengeForm'; 4 import ChallengeForm from '../../components/challenge/ChallengeForm';
5 5
6 const ChallengeContainer = () => { 6 const ChallengeContainer = () => {
7 - return <div></div>; 7 + return <ChallengeForm />;
8 }; 8 };
9 9
10 export default ChallengeContainer; 10 export default ChallengeContainer;
......
...@@ -2,7 +2,7 @@ const Challenge = require("../../models/challenge"); ...@@ -2,7 +2,7 @@ const Challenge = require("../../models/challenge");
2 const Session = require("../../models/session"); 2 const Session = require("../../models/session");
3 const Participation = require("../../models/participation"); 3 const Participation = require("../../models/participation");
4 const Group = require("../../models/group"); 4 const Group = require("../../models/group");
5 -const User = require('../../models/user'); 5 +const User = require("../../models/user");
6 6
7 const Joi = require("joi"); 7 const Joi = require("joi");
8 /*POST /api/challenge/getChallenge 8 /*POST /api/challenge/getChallenge
...@@ -13,7 +13,9 @@ const Joi = require("joi"); ...@@ -13,7 +13,9 @@ const Joi = require("joi");
13 exports.getChallenge = async (ctx) => { 13 exports.getChallenge = async (ctx) => {
14 try { 14 try {
15 const { challengeName } = ctx.request.body; 15 const { challengeName } = ctx.request.body;
16 - const challenge = await Challenge.findByChallengeName(challengeName).select('-_id'); 16 + const challenge = await Challenge.findByChallengeName(challengeName).select(
17 + "-_id"
18 + );
17 if (!challenge) { 19 if (!challenge) {
18 ctx.status = 401; 20 ctx.status = 401;
19 return; 21 return;
...@@ -39,7 +41,7 @@ exports.addChallenge = async (ctx) => { ...@@ -39,7 +41,7 @@ exports.addChallenge = async (ctx) => {
39 startDate: Joi.date(), 41 startDate: Joi.date(),
40 endDate: Joi.date(), 42 endDate: Joi.date(),
41 durationPerSession: Joi.string(), 43 durationPerSession: Joi.string(),
42 - goalPerSession: Joi.number() 44 + goalPerSession: Joi.number(),
43 }) 45 })
44 .unknown(); 46 .unknown();
45 const result = Joi.validate(ctx.request.body, schema); 47 const result = Joi.validate(ctx.request.body, schema);
...@@ -58,7 +60,9 @@ exports.addChallenge = async (ctx) => { ...@@ -58,7 +60,9 @@ exports.addChallenge = async (ctx) => {
58 } = ctx.request.body; 60 } = ctx.request.body;
59 61
60 try { 62 try {
61 - const isChallengeExist = await Challenge.findByChallengeName(challengeName).select('-_id'); 63 + const isChallengeExist = await Challenge.findByChallengeName(
64 + challengeName
65 + ).select("-_id");
62 66
63 if (isChallengeExist) { 67 if (isChallengeExist) {
64 ctx.status = 409; 68 ctx.status = 409;
...@@ -73,54 +77,50 @@ exports.addChallenge = async (ctx) => { ...@@ -73,54 +77,50 @@ exports.addChallenge = async (ctx) => {
73 }); 77 });
74 78
75 await challenge.save(); 79 await challenge.save();
76 - 80 +
77 - const newChallenge=await Challenge.findByChallengeName(challengeName); 81 + const newChallenge = await Challenge.findByChallengeName(challengeName);
78 - const newChallenge_id=newChallenge._id; 82 + const newChallenge_id = newChallenge._id;
79 - const timeStep=Number(durationPerSession.slice(0,-1)) 83 + const timeStep = Number(durationPerSession.slice(0, -1));
80 - if(typeof(startDate)=='string'){ 84 + if (typeof startDate == "string") {
81 - startDate=new Date(startDate); 85 + startDate = new Date(startDate);
82 } 86 }
83 - if(typeof(endDate)=='string'){ 87 + if (typeof endDate == "string") {
84 - endDate=new Date(endDate); 88 + endDate = new Date(endDate);
85 } 89 }
86 - for(let s_date=new Date(startDate);s_date<endDate;){ 90 + for (let s_date = new Date(startDate); s_date < endDate; ) {
87 - let e_date=new Date(s_date); 91 + let e_date = new Date(s_date);
88 - if(durationPerSession[durationPerSession.length-1]==='d'){ 92 + if (durationPerSession[durationPerSession.length - 1] === "d") {
89 - console.log('day'); 93 + console.log("day");
90 - e_date.setDate(s_date.getDate()+timeStep); 94 + e_date.setDate(s_date.getDate() + timeStep);
91 - } 95 + } else if (durationPerSession[durationPerSession.length - 1] === "w") {
92 - else if(durationPerSession[durationPerSession.length-1]==='w'){ 96 + console.log("week");
93 - console.log('week'); 97 + e_date.setDate(s_date.getDate() + timeStep * 7);
94 - e_date.setDate(s_date.getDate()+timeStep*7); 98 + } else if (durationPerSession[durationPerSession.length - 1] === "m") {
99 + console.log("month");
100 + e_date.setMonth(s_date.getMonth() + timeStep);
95 } 101 }
96 - else if(durationPerSession[durationPerSession.length-1]==='m'){ 102 + e_date.setMinutes(e_date.getMinutes() - 1);
97 - console.log('month'); 103 + if (e_date > endDate) {
98 - e_date.setMonth(s_date.getMonth()+timeStep);
99 - }
100 - e_date.setMinutes(e_date.getMinutes()-1);
101 - if(e_date>endDate){
102 break; 104 break;
103 } 105 }
104 - let status=""; 106 + let status = "";
105 - if (s_date>new Date()){ 107 + if (s_date > new Date()) {
106 - status="enrolled"; 108 + status = "enrolled";
107 - } 109 + } else if (s_date <= new Date() && new Date() <= e_date) {
108 - else if (s_date<=new Date() && new Date() <= e_date){ 110 + status = "progress";
109 - status="progress"; 111 + } else {
110 - } 112 + status = "end";
111 - else{
112 - status="end";
113 } 113 }
114 console.log(`start:${s_date}\nend:${e_date}`); 114 console.log(`start:${s_date}\nend:${e_date}`);
115 - const session=new Session({ 115 + const session = new Session({
116 - challengeId:newChallenge_id, 116 + challengeId: newChallenge_id,
117 - sessionStartDate:s_date, 117 + sessionStartDate: s_date,
118 - sessionEndDate:e_date, 118 + sessionEndDate: e_date,
119 - status:status, 119 + status: status,
120 }); 120 });
121 await session.save(); 121 await session.save();
122 - s_date=new Date(e_date); 122 + s_date = new Date(e_date);
123 - s_date.setMinutes(s_date.getMinutes()+1); 123 + s_date.setMinutes(s_date.getMinutes() + 1);
124 } 124 }
125 ctx.body = challenge; 125 ctx.body = challenge;
126 } catch (e) { 126 } catch (e) {
...@@ -128,24 +128,23 @@ exports.addChallenge = async (ctx) => { ...@@ -128,24 +128,23 @@ exports.addChallenge = async (ctx) => {
128 } 128 }
129 }; 129 };
130 130
131 -
132 /* GET /api/challenge/list?status 131 /* GET /api/challenge/list?status
133 query string status can be in ['all','enrolled','progress','end'] 132 query string status can be in ['all','enrolled','progress','end']
134 */ 133 */
135 exports.list = async (ctx) => { 134 exports.list = async (ctx) => {
136 - try{ 135 + try {
137 const status = ctx.query.status; 136 const status = ctx.query.status;
138 - if (status!=='all'){ 137 + if (status !== "all") {
139 - const challenges = await Challenge.find({status:status}).select('-_id'); 138 + const challenges = await Challenge.find({ status: status }).select(
139 + "-_id"
140 + );
140 ctx.body = challenges; 141 ctx.body = challenges;
141 - } 142 + } else {
142 - else { 143 + const challenges = await Challenge.find({}).select("-_id");
143 - const challenges = await Challenge.find({}).select('-_id');
144 ctx.body = challenges; 144 ctx.body = challenges;
145 } 145 }
146 - } 146 + } catch (e) {
147 - catch(e){ 147 + ctx.throw(500, e);
148 - ctx.throw(500,e);
149 } 148 }
150 }; 149 };
151 150
...@@ -156,40 +155,39 @@ exports.list = async (ctx) => { ...@@ -156,40 +155,39 @@ exports.list = async (ctx) => {
156 } 155 }
157 */ 156 */
158 157
159 -exports.participate=async (ctx)=>{ 158 +exports.participate = async (ctx) => {
160 - try{ 159 + try {
161 - /* 160 + /*
162 TODO: access token validation, 161 TODO: access token validation,
163 recommend:get username from access_token 162 recommend:get username from access_token
164 */ 163 */
165 console.log(ctx.request.body); 164 console.log(ctx.request.body);
166 - const {username,challengeName}=ctx.request.body; 165 + const { username, challengeName } = ctx.request.body;
167 - const challenge=await Challenge.findByChallengeName(challengeName); 166 + const challenge = await Challenge.findByChallengeName(challengeName);
168 - const challenge_id=challenge._id; 167 + const challenge_id = challenge._id;
169 - const user=await User.findByUsername(username); 168 + const user = await User.findByUsername(username);
170 - const user_id=user._id; 169 + const user_id = user._id;
171 - const newGroup=new Group({ 170 + const newGroup = new Group({
172 - members:[user_id], 171 + members: [user_id],
173 }); 172 });
174 - let newGroup_id="" 173 + let newGroup_id = "";
175 - await newGroup.save(async (err,product)=>{ 174 + await newGroup.save(async (err, product) => {
176 - if(err){ 175 + if (err) {
177 throw err; 176 throw err;
178 } 177 }
179 - newGroup_id=product._id; 178 + newGroup_id = product._id;
180 - const sessions=await Session.findByChallengeId(challenge_id); 179 + const sessions = await Session.findByChallengeId(challenge_id);
181 sessions.forEach(async (elem) => { 180 sessions.forEach(async (elem) => {
182 - const newParticipation=new Participation({ 181 + const newParticipation = new Participation({
183 - sessionId:elem._id, 182 + sessionId: elem._id,
184 - groupId:newGroup_id, 183 + groupId: newGroup_id,
185 - problems:[], 184 + problems: [],
186 }); 185 });
187 await newParticipation.save(); 186 await newParticipation.save();
188 }); 187 });
189 }); 188 });
190 - } 189 + } catch (e) {
191 - catch(e){
192 console.error(e); 190 console.error(e);
193 - ctx.throw(500,e); 191 + ctx.throw(500, e);
194 } 192 }
195 -};
...\ No newline at end of file ...\ No newline at end of file
193 +};
......