|
1 | | -import { useSnapshot } from "valtio" |
2 | | - |
3 | | -import { Button, Column, Row, Text, TextInput } from "@code-glue/paradigm" |
| 1 | +import { Button, ButtonRow, Row, Text, TextInput } from "@code-glue/paradigm" |
| 2 | +import { Header } from "@/components/Header" |
4 | 3 | import { useCurrentAutomation } from "@/hooks/useAutomation" |
5 | | -import { store } from "@/store" |
| 4 | +import { useRouter } from "@/hooks/useRouter" |
6 | 5 |
|
7 | | -export const Header = () => { |
| 6 | +export const AutomationHeader = () => { |
8 | 7 | const { automation, automationSnapshot, saveCurrentAutomation } = |
9 | 8 | useCurrentAutomation() |
10 | | - const { isBodyEdited, newAutomationTitle } = useSnapshot(store.state) |
| 9 | + const [, navigateTo] = useRouter() |
11 | 10 |
|
12 | 11 | return ( |
13 | | - <Column |
14 | | - borderBottomColor="$borderColor" |
15 | | - borderBottomWidth="$size.stroke" |
16 | | - noShrink |
17 | | - > |
| 12 | + <Header> |
18 | 13 | <Row mx={12}> |
19 | 14 | <Text>Name:</Text> |
20 | 15 | <TextInput |
21 | 16 | onChangeText={(title) => { |
22 | 17 | if (automation) { |
23 | 18 | automation.update({ title }) |
24 | | - } else { |
25 | | - store.state.newAutomationTitle = title |
26 | 19 | } |
27 | 20 | }} |
28 | | - value={automation ? automationSnapshot.title : newAutomationTitle} |
| 21 | + value={automation ? automationSnapshot.title : ""} |
29 | 22 | /> |
30 | 23 | </Row> |
31 | 24 | <Row> |
32 | 25 | <Text>Status:</Text> |
33 | | - <Text>{isBodyEdited ? "Edited" : "Unedited"}</Text> |
34 | | - <Button label="Save" onPress={saveCurrentAutomation} /> |
| 26 | + <Text>{automation?._isEdited ? "Edited" : "Unedited"}</Text> |
| 27 | + <ButtonRow> |
| 28 | + <Button label="Save" isRaised onPress={saveCurrentAutomation} /> |
| 29 | + <Button |
| 30 | + label="Delete" |
| 31 | + isRaised |
| 32 | + isNegative |
| 33 | + onPress={() => { |
| 34 | + automation?.delete() |
| 35 | + navigateTo("home") |
| 36 | + }} |
| 37 | + /> |
| 38 | + </ButtonRow> |
35 | 39 | </Row> |
36 | | - </Column> |
| 40 | + </Header> |
37 | 41 | ) |
38 | 42 | } |
0 commit comments