1
1
import React , { useState } from 'react'
2
2
import { styled } from 'inlines'
3
3
import { useClient , useQuery } from '@based/react'
4
- import {
5
- Text ,
6
- Badge ,
7
- Row ,
8
- FormGroup ,
9
- IconArrowLeft ,
10
- color ,
11
- ScrollArea ,
12
- } from '@based/ui'
4
+ import { color , ScrollArea } from '@based/ui'
13
5
import { PublishSideBar } from './PublishSideBar'
14
6
import { useRoute } from 'kabouter'
7
+ import { Text , Badge , Stack , IconArrowLeft , Form } from 'better-ui'
15
8
16
9
const FILTER_FIELDS = [
17
10
'type' ,
@@ -43,8 +36,6 @@ export const ContentEditor = ({ id, section }) => {
43
36
44
37
const { data : schema , loading : loadingSchema } = useQuery ( 'db:schema' )
45
38
46
- // console.log(data, '🐸', userData)
47
-
48
39
const route = useRoute ( '[section][id]' )
49
40
50
41
// filter out some system fields
@@ -58,8 +49,6 @@ export const ContentEditor = ({ id, section }) => {
58
49
}
59
50
}
60
51
61
- // console.log('schema fields', schemaFields)
62
-
63
52
return (
64
53
< styled . div
65
54
style = { {
@@ -69,7 +58,7 @@ export const ContentEditor = ({ id, section }) => {
69
58
} }
70
59
>
71
60
< ScrollArea style = { { padding : '24px 48px' , width : '100%' } } >
72
- < Row
61
+ < Stack
73
62
style = { {
74
63
cursor : 'pointer' ,
75
64
marginBottom : 6 ,
@@ -84,24 +73,40 @@ export const ContentEditor = ({ id, section }) => {
84
73
setSomeThingChanged ( false )
85
74
} }
86
75
>
87
- < IconArrowLeft style = { { marginRight : 8 } } />
88
- < Text weight = "medium" > Back</ Text >
89
- </ Row >
90
- < Row style = { { marginBottom : 32 } } >
91
- < Text weight = "strong" size = { 24 } style = { { marginRight : 12 } } >
76
+ < IconArrowLeft />
77
+ < Text variant = "bodyBold" > Back</ Text >
78
+ </ Stack >
79
+ < Stack style = { { marginBottom : 32 } } >
80
+ < Text
81
+ variant = "bodyStrong"
82
+ as = "h3"
83
+ style = { { marginRight : 12 , fontSize : 24 } }
84
+ >
92
85
{ section }
93
86
</ Text >
94
- < Badge light > { id } </ Badge >
95
- </ Row >
87
+ < Badge color = "auto-muted" copyValue = { id } >
88
+ { id }
89
+ </ Badge >
90
+ </ Stack >
96
91
{ schema && (
97
- < FormGroup
98
- alwaysAccept
99
- config = { filteredSchemaFields }
92
+ // <FormGroup
93
+ // alwaysAccept
94
+ // config={filteredSchemaFields}
95
+ // onChange={(v) => {
96
+ // setSomeThingChanged(true)
97
+ // setFormFieldChanges({ ...formFieldChanges, ...v })
98
+ // }}
99
+ // values={{ ...data, ...formFieldChanges }}
100
+ // />
101
+
102
+ < Form
103
+ values = { { ...data , ...formFieldChanges } }
104
+ fields = { schemaFields }
100
105
onChange = { ( v ) => {
106
+ console . log ( v , '🐋' )
101
107
setSomeThingChanged ( true )
102
108
setFormFieldChanges ( { ...formFieldChanges , ...v } )
103
109
} }
104
- values = { { ...data , ...formFieldChanges } }
105
110
/>
106
111
) }
107
112
</ ScrollArea >
@@ -116,6 +121,9 @@ export const ContentEditor = ({ id, section }) => {
116
121
// ...formFieldChanges,
117
122
// updatedBy: userData.name,
118
123
// })
124
+
125
+ // TODO updatedBy can be meta data from updatedAt @yves
126
+
119
127
if ( Object . keys ( schemaFields ) . includes ( 'updatedBy' ) ) {
120
128
await client
121
129
. call ( 'db:set' , {
0 commit comments