Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
  • Loading branch information
claudioantonio committed Jan 29, 2021
commit f8d41c3bcda516cd33be25475ac52ab72c376e1f
4 changes: 2 additions & 2 deletions webui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { Route, Switch } from 'react-router';
import Layout from './layout';
import BugPage from './pages/bug';
import ListPage from './pages/list';
import NewPage from './pages/new/NewPage';
import NewBugPage from './pages/new/NewBugPage';

export default function App() {
return (
<Layout>
<Switch>
<Route path="/" exact component={ListPage} />
<Route path="/new" exact component={NewPage} />
<Route path="/new" exact component={NewBugPage} />
<Route path="/bug/:id" exact component={BugPage} />
</Switch>
</Layout>
Expand Down
7 changes: 7 additions & 0 deletions webui/src/pages/new/NewBug.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation newBug($input: NewBugInput!) {
newBug(input: $input) {
bug {
humanId
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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';
import { useNewBugMutation } from './NewBug.generated';

/**
* Styles
*/
const useStyles = makeStyles((theme) => ({
const useStyles = makeStyles((theme: Theme) => ({
main: {
maxWidth: 800,
margin: 'auto',
Expand Down Expand Up @@ -40,41 +39,47 @@ const useStyles = makeStyles((theme) => ({
},
}));

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 NewBugPage() {
const classes = useStyles();
let inputField: any;
const [newBug, { loading, error }] = useNewBugMutation();

function submitNewIssue(e: FormEvent) {
e.preventDefault();
// TODO Call API
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"
/>
<GBButton to="/" text="Submit new issue" />
<button type="submit">Submit</button>
</form>
</Paper>
);
}

export default NewPage;
export default NewBugPage;