@@ -13,62 +13,51 @@ import {
13
13
CreateTeamForm ,
14
14
FormSwitch ,
15
15
} from "@thunderstore/cyberstorm-forms" ;
16
- import { TextInput , Dialog , Button } from "@thunderstore/cyberstorm" ;
16
+ import { Dialog , Button } from "@thunderstore/cyberstorm" ;
17
17
import { SettingItem } from "@thunderstore/cyberstorm/src/components/SettingItem/SettingItem" ;
18
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
19
- import { faPlus } from "@fortawesome/free-solid-svg-icons" ;
20
18
import { packageUpload } from "@thunderstore/thunderstore-api" ;
19
+ import { usePromise } from "@thunderstore/use-promise" ;
20
+ import { useDapper } from "@thunderstore/dapper" ;
21
21
22
22
const options = [
23
- { label : "Asd" , value : "asd" } ,
24
- { label : "Asd2" , value : "asd2" } ,
25
- { label : "Asd3" , value : "asd3" } ,
26
- { label : "Asd4" , value : "asd4" } ,
27
- { label : "Asd5" , value : "asd5" } ,
28
- { label : "Asd6" , value : "asd6" } ,
29
- { label : "Asd7" , value : "asd7" } ,
30
- { label : "Asd8" , value : "asd8" } ,
31
- { label : "Asd9" , value : "asd9" } ,
32
- { label : "Asd10" , value : "asd10" } ,
33
- { label : "Asd11" , value : "asd11" } ,
34
- { label : "Asd12" , value : "asd12" } ,
35
- { label : "Asd13" , value : "asd13" } ,
36
- { label : "Asd14" , value : "asd14" } ,
23
+ { label : "Asd" , value : "asd asd" } ,
24
+ { label : "Asd2" , value : "asd2 asd2" } ,
25
+ { label : "Asd3" , value : "asd3 asd3" } ,
26
+ { label : "Asd4" , value : "asd4 asd4" } ,
27
+ { label : "Asd5" , value : "asd5 asd5" } ,
28
+ { label : "Asd6" , value : "asd6 asd6" } ,
37
29
] ;
38
30
39
- interface UploadPackageFormProps {
40
- teams : {
41
- name : string ;
42
- } [ ] ;
43
- }
31
+ export function UploadPackageForm ( ) {
32
+ const dapper = useDapper ( ) ;
33
+ const user = usePromise ( dapper . getCurrentUser , [ ] ) ;
34
+ const communities = usePromise ( dapper . getCommunities , [ ] ) ;
44
35
45
- export function UploadPackageForm ( props : UploadPackageFormProps ) {
46
36
const toaster = useFormToaster ( {
47
37
successMessage : "Package submitted" ,
48
38
} ) ;
49
39
50
- // Parse categories to the right format for form
51
- function communityCategoriesParse (
40
+ function communitiesParse (
52
41
selected : {
53
42
label : string ;
54
43
value : string ;
55
- } [ ] ,
56
- onChange : ( selected : { [ key : string ] : string [ ] } ) => void
44
+ } [ ]
57
45
) {
58
- const communityCategories : { [ key : string ] : string [ ] } = { } ;
59
- selected . map ( ( x ) => ( communityCategories [ x . value ] = [ x . value ] ) ) ;
60
- onChange ( communityCategories ) ;
46
+ return selected . map ( ( x ) => x . value ) ;
61
47
}
62
48
63
- // Parse communities to the right format for form
64
- function communitiesParse (
49
+ function communityCategoriesParse (
65
50
selected : {
66
51
label : string ;
67
52
value : string ;
68
- } [ ] ,
69
- onChange : ( selected : string [ ] ) => void
53
+ } [ ]
70
54
) {
71
- onChange ( selected . map ( ( x ) => x . value ) ) ;
55
+ const communityCategories : { [ key : string ] : string [ ] } = { } ;
56
+ // TODO: Instead of getting the value from splitting a string, have it be passed in an object
57
+ selected . map (
58
+ ( x ) => ( communityCategories [ "community_identifier" ] = [ x . value ] )
59
+ ) ;
60
+ return communityCategories ;
72
61
}
73
62
74
63
return (
@@ -82,46 +71,48 @@ export function UploadPackageForm(props: UploadPackageFormProps) {
82
71
< SettingItem
83
72
title = "Upload file"
84
73
description = "Upload your package as a ZIP file."
85
- content = { < TextInput /> }
74
+ content = { < > upload block here < /> }
86
75
/>
87
76
< div className = { styles . line } />
88
77
< SettingItem
89
78
title = "Team"
90
- description = "No teams available?"
91
- additionalLeftColumnContent = {
92
- < Dialog . Root
93
- title = "Create Team"
94
- trigger = {
95
- < Button . Root colorScheme = "primary" paddingSize = "large" >
96
- < Button . ButtonLabel > Create team</ Button . ButtonLabel >
97
- < Button . ButtonIcon >
98
- < FontAwesomeIcon icon = { faPlus } />
99
- </ Button . ButtonIcon >
100
- </ Button . Root >
101
- }
102
- >
103
- < CreateTeamForm />
104
- </ Dialog . Root >
105
- }
79
+ description = "Select the team you want your package to be associated with."
106
80
content = {
107
- < FormSelectSearch
108
- name = "team"
109
- schema = { uploadPackageFormSchema }
110
- options = { props . teams . map ( ( t ) => t . name ) }
111
- placeholder = "Choose a team..."
112
- />
81
+ < div className = { styles . teamContentWrapper } >
82
+ < FormSelectSearch
83
+ name = "team"
84
+ schema = { uploadPackageFormSchema }
85
+ options = { user . teams . map ( ( t ) => t . name ) }
86
+ placeholder = "Choose a team..."
87
+ />
88
+ < div className = { styles . createTeamSentence } >
89
+ < span > No teams available?</ span >
90
+ < Dialog . Root
91
+ title = "Create Team"
92
+ trigger = {
93
+ < button className = { styles . createTeamModalLink } >
94
+ Create Team
95
+ </ button >
96
+ }
97
+ >
98
+ < CreateTeamForm />
99
+ </ Dialog . Root >
100
+ </ div >
101
+ </ div >
113
102
}
114
103
/>
115
104
< SettingItem
116
105
title = "Communities"
117
- description = "Select communities you want your package to be listed under. Current community is selected by default. "
106
+ description = "Select communities you want your package to be listed under."
118
107
content = {
119
108
< FormMultiSelectSearch
120
109
name = "communities"
121
110
schema = { uploadPackageFormSchema }
122
- options = { options }
111
+ options = { communities . results . map ( ( c ) => {
112
+ return { label : c . name , value : c . identifier } ;
113
+ } ) }
123
114
placeholder = "Choose community..."
124
- onChangeParse = { communitiesParse }
115
+ fieldFormFormatParser = { communitiesParse }
125
116
/>
126
117
}
127
118
/>
@@ -134,7 +125,7 @@ export function UploadPackageForm(props: UploadPackageFormProps) {
134
125
schema = { uploadPackageFormSchema }
135
126
options = { options }
136
127
placeholder = "Choose categories..."
137
- onChangeParse = { communityCategoriesParse }
128
+ fieldFormFormatParser = { communityCategoriesParse }
138
129
/>
139
130
}
140
131
/>
0 commit comments