aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/pages/new
diff options
context:
space:
mode:
authorCláudio <claudio.engdist@gmail.com>2021-01-26 14:54:58 -0300
committerCláudio <claudio.engdist@gmail.com>2021-01-26 14:54:58 -0300
commitc009bea662d9fc875c8e7cb266cebbfc2985f226 (patch)
treec4f435f28317f3d79f1be569eabfab19cb0e1990 /webui/src/pages/new
parent343ef1455edca4e9b807700885c53cc6c43d19d9 (diff)
downloadgit-bug-c009bea662d9fc875c8e7cb266cebbfc2985f226.tar.gz
Partial commit for #158
- Component GBButton created - New issue form partially created (only title) - Refactoring for GBButon usage Next steps - Practice GraphQL calls - Finish New issue form (add first comment and submit)
Diffstat (limited to 'webui/src/pages/new')
-rw-r--r--webui/src/pages/new/NewPage.tsx80
1 files changed, 80 insertions, 0 deletions
diff --git a/webui/src/pages/new/NewPage.tsx b/webui/src/pages/new/NewPage.tsx
new file mode 100644
index 00000000..b485987e
--- /dev/null
+++ b/webui/src/pages/new/NewPage.tsx
@@ -0,0 +1,80 @@
+import { gql, useMutation } from '@apollo/client';
+import React, { FormEvent } from 'react';
+
+import Paper from '@material-ui/core/Paper/Paper';
+import TextField from '@material-ui/core/TextField/TextField';
+import { fade, makeStyles, Theme } from '@material-ui/core/styles';
+
+import GBButton from '../../components/Button/GBButton';
+
+/**
+ * Styles
+ */
+const useStyles = makeStyles((theme) => ({
+ main: {
+ maxWidth: 800,
+ margin: 'auto',
+ marginTop: theme.spacing(4),
+ marginBottom: theme.spacing(4),
+ padding: theme.spacing(2),
+ overflow: 'hidden',
+ },
+ titleInput: {
+ borderRadius: theme.shape.borderRadius,
+ borderColor: fade(theme.palette.primary.main, 0.2),
+ borderStyle: 'solid',
+ borderWidth: '1px',
+ backgroundColor: fade(theme.palette.primary.main, 0.05),
+ padding: theme.spacing(0, 0),
+ transition: theme.transitions.create([
+ 'width',
+ 'borderColor',
+ 'backgroundColor',
+ ]),
+ },
+ form: {
+ display: 'flex',
+ flexDirection: 'row',
+ flexWrap: 'wrap',
+ justifyContent: 'flex-end',
+ },
+}));
+
+const NEW_BUG = gql`
+ mutation NewBug($input: NewBugInput) {
+ newBug(input: $input) {
+ title
+ message
+ }
+ }
+`;
+
+/**
+ * Form to create a new issue
+ */
+function NewPage() {
+ const classes = useStyles({ searching: false });
+ const [newBugInput] = useMutation(NEW_BUG);
+
+ function submitNewIssue(e: FormEvent) {
+ e.preventDefault();
+ // TODO Call API
+ }
+
+ return (
+ <Paper className={classes.main}>
+ <form className={classes.form} onSubmit={submitNewIssue}>
+ <TextField
+ label="Title"
+ className={classes.titleInput}
+ variant="outlined"
+ fullWidth
+ margin="dense"
+ />
+ <GBButton to="/" text="Submit new issue" />
+ </form>
+ </Paper>
+ );
+}
+
+export default NewPage;