-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
59 lines (49 loc) · 1.44 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import React, { useState } from 'react';
import { graphql } from 'react-apollo';
import styled from 'styled-components';
import { EXECUTE_ACTION } from 'no-stack';
import { CREATE_ISCOMPLETED_FOR_TODO_ACTION_ID } from '../../config';
const Form = styled.div`
padding: 1em;
margin: 1.5em;
background-color: #F5F5F5;
border-radius: 3px;
`;
const Button = styled.button``;
function CreateIsCompletedForm({ createIsCompleted, currentTodoId, refetchQueries }) {
const [ isCompletedName, updateIsCompletedName ] = useState('');
function handleChange(e) {
updateIsCompletedName(e.target.value);
}
async function handleSubmit(e) {
e.preventDefault();
if (!isCompletedName) {
return;
}
await createIsCompleted({
variables: {
actionId: CREATE_ISCOMPLETED_FOR_TODO_ACTION_ID,
executionParameters: JSON.stringify({
parentInstanceId: currentTodoId,
value: isCompletedName,
}),
unrestricted: false,
},
refetchQueries,
})
}
return (
<Form>
<label htmlFor="is-completed-name">
IsCompleted Name:
<input
id="is-completed-name"
type="text"
onChange={handleChange}
value={isCompletedName} />
</label>
<Button type="submit" onClick={handleSubmit}>Add IsCompleted</Button>
</Form>
);
}
export default graphql(EXECUTE_ACTION, { name: 'createIsCompleted' })(CreateIsCompletedForm);