aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/pages/new/NewBugPage.tsx
diff options
context:
space:
mode:
authorCláudio <claudio.engdist@gmail.com>2021-01-28 21:24:40 -0300
committerCláudio <claudio.engdist@gmail.com>2021-01-28 21:24:40 -0300
commitf8d41c3bcda516cd33be25475ac52ab72c376e1f (patch)
tree333df9ea0ba24dd1064408637b86ae3f36a40800 /webui/src/pages/new/NewBugPage.tsx
parentc009bea662d9fc875c8e7cb266cebbfc2985f226 (diff)
downloadgit-bug-f8d41c3bcda516cd33be25475ac52ab72c376e1f.tar.gz
Partial commit for #158
- It´s possible to create new issues from webui (only title) Next step - Finish new issue form (First comment field and style) - Update Readme about codegen usage and enforcing playground usage
Diffstat (limited to 'webui/src/pages/new/NewBugPage.tsx')
-rw-r--r--webui/src/pages/new/NewBugPage.tsx85
1 files changed, 85 insertions, 0 deletions
diff --git a/webui/src/pages/new/NewBugPage.tsx b/webui/src/pages/new/NewBugPage.tsx
new file mode 100644
index 00000000..925034e1
--- /dev/null
+++ b/webui/src/pages/new/NewBugPage.tsx
@@ -0,0 +1,85 @@
+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 { useNewBugMutation } from './NewBug.generated';
+
+/**
+ * Styles
+ */
+const useStyles = makeStyles((theme: 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',
+ },
+}));
+
+/**
+ * Form to create a new issue
+ */
+function NewBugPage() {
+ const classes = useStyles();
+ let inputField: any;
+ const [newBug, { loading, error }] = useNewBugMutation();
+
+ function submitNewIssue(e: FormEvent) {
+ e.preventDefault();
+ newBug({
+ variables: {
+ input: {
+ title: String(inputField.value),
+ message: 'Message', //TODO
+ },
+ },
+ });
+ inputField.value = '';
+ }
+
+ if (loading) return <div>Loading</div>;
+ if (error) return <div>Error</div>;
+
+ return (
+ <Paper className={classes.main}>
+ <form className={classes.form} onSubmit={submitNewIssue}>
+ <TextField
+ inputRef={(node) => {
+ inputField = node;
+ }}
+ label="Title"
+ className={classes.titleInput}
+ variant="outlined"
+ fullWidth
+ margin="dense"
+ />
+ <button type="submit">Submit</button>
+ </form>
+ </Paper>
+ );
+}
+
+export default NewBugPage;