@@ -6,7 +6,18 @@ import {Form, useForm} from "@mantine/form";
6
6
import { CommitModel , DataProductPostParam } from "@/server/types" ;
7
7
import { RepoApi } from "@/server/RepoApi" ;
8
8
import { AppWrite } from "@/server/Client" ;
9
- import { Box , Button , Divider , Input , InputLabel , LoadingOverlay , Select } from "@mantine/core" ;
9
+ import {
10
+ Box ,
11
+ Button ,
12
+ Divider ,
13
+ Input ,
14
+ InputLabel ,
15
+ LoadingOverlay ,
16
+ Pill ,
17
+ PillGroup , PillsInput ,
18
+ PillsInputField ,
19
+ Select
20
+ } from "@mantine/core" ;
10
21
import { notifications } from "@mantine/notifications" ;
11
22
import { ProductApi } from "@/server/ProductApi" ;
12
23
@@ -76,22 +87,19 @@ export default function ProductPostPage(){
76
87
}
77
88
return null ;
78
89
} ,
79
- type : ( value ) => {
80
- if ( ! value ) {
81
- return "Type is required" ;
82
- }
83
- return null ;
84
- } ,
85
90
price : ( value ) => {
86
- if ( ! value ) {
87
- return "Price is required " ;
91
+ if ( value % 1 !== 0 && value !== 0 ) {
92
+ return "Price is invalid, it is integer " ;
88
93
}
89
94
if ( value < 0 ) {
90
95
return "Price is invalid, it is eqt 0" ;
91
96
}
92
97
} ,
93
98
}
94
99
} ) ;
100
+
101
+ const [ Topics , setTopics ] = useState < string [ ] > ( [ ] ) ;
102
+ const [ Topic , setTopic ] = useState < string > ( "" ) ;
95
103
const onSubmit = ( ) => {
96
104
if ( Publishing ) return ;
97
105
setPublishing ( true ) ;
@@ -109,18 +117,19 @@ export default function ProductPostPage(){
109
117
name : form . getValues ( ) . name ,
110
118
description : form . getValues ( ) . description ,
111
119
license : form . getValues ( ) . license ,
112
- price : form . getValues ( ) . price ,
120
+ price : Number ( form . getValues ( ) . price ) ,
113
121
hash : form . getValues ( ) . hash ,
114
- type : form . getValues ( ) . type ,
122
+ type : Topics . join ( "," ) ,
115
123
}
124
+ console . log ( param ) ;
116
125
product_api . Post ( Parma ! . owner , Parma ! . repo , param )
117
126
. then ( ( res ) => {
118
127
if ( res . status === 200 ) {
119
128
const json :AppWrite < string > = JSON . parse ( res . data ) ;
120
- if ( json . code === 200 && json . data ) {
129
+ if ( json . code === 200 ) {
121
130
notifications . show ( {
122
131
title : "Success" ,
123
- message : "Post success"
132
+ message : "Post Jobs Submit success, Please You wait "
124
133
} )
125
134
setTimeout ( ( ) => {
126
135
window . location . href = "/r/" + Parma ! . owner + "/" + Parma ! . repo ;
@@ -139,7 +148,7 @@ export default function ProductPostPage(){
139
148
POST
140
149
</ h1 >
141
150
< Box pos = "relative" >
142
- < LoadingOverlay visible = { Publishing } loaderProps = { { children : 'Forking ...' } } />
151
+ < LoadingOverlay visible = { Publishing } loaderProps = { { children : 'Publish ...' } } />
143
152
< Form
144
153
form = { form }
145
154
id = "LayoutModelRepositoryPOST"
@@ -158,7 +167,7 @@ export default function ProductPostPage(){
158
167
}
159
168
} )
160
169
}
161
- { ...form . getInputProps ( "owner " ) }
170
+ { ...form . getInputProps ( "hash " ) }
162
171
/>
163
172
< InputLabel className = "w-full" >
164
173
name< a style = { { color : 'red' } } > *</ a >
@@ -208,14 +217,39 @@ export default function ProductPostPage(){
208
217
</ InputLabel >
209
218
< InputLabel className = "w-full" >
210
219
type< a style = { { color : 'red' } } > *</ a >
211
- < Input
212
- name = "type"
213
- placeholder = "Enter product type"
214
- type = "tel"
215
- aria-autocomplete = { "none" }
216
- key = { form . key ( "type" ) }
217
- { ...form . getInputProps ( "type" ) }
218
- />
220
+ < PillsInput >
221
+ < PillGroup >
222
+ { Topics . map ( ( item , index ) => (
223
+ < Pill key = { index } > { item } </ Pill >
224
+ ) ) }
225
+ < PillsInputField
226
+ value = { Topic }
227
+ placeholder = "Add a Type"
228
+ onChange = { ( e ) => {
229
+ setTopic ( e . target . value )
230
+ } }
231
+ onKeyDown = { ( e ) => {
232
+ if ( e . key === "Enter" ) {
233
+ if ( Topic . length > 0 ) {
234
+ setTopics ( [ ...Topics , Topic ] )
235
+ setTopic ( "" )
236
+ }
237
+ }
238
+ if ( e . key === "Backspace" ) {
239
+ if ( Topic . length === 0 ) {
240
+ setTopics ( Topics . slice ( 0 , - 1 ) )
241
+ }
242
+ }
243
+ if ( e . key === "Tab" ) {
244
+ if ( Topic . length > 0 ) {
245
+ setTopics ( [ ...Topics , Topic ] )
246
+ setTopic ( "" )
247
+ }
248
+ }
249
+ } }
250
+ />
251
+ </ PillGroup >
252
+ </ PillsInput >
219
253
</ InputLabel >
220
254
< Divider />
221
255
< div style = { {
0 commit comments