@@ -3,15 +3,15 @@ import {
3
3
Button ,
4
4
Divider ,
5
5
H5 ,
6
+ H6 ,
6
7
InputGroup ,
7
8
Intent ,
8
9
} from '@blueprintjs/core'
9
10
10
11
import { useAtom } from 'jotai'
11
12
import { isEqual , omit } from 'lodash-es'
12
- import { useMemo , useState } from 'react'
13
- import { UseFieldArrayRemove , UseFormSetError } from 'react-hook-form'
14
- import { useEvent } from 'react-use'
13
+ import { FC , useMemo , useState } from 'react'
14
+ import { UseFieldArrayRemove } from 'react-hook-form'
15
15
16
16
import { AppToaster } from 'components/Toaster'
17
17
import { CopilotDocV1 } from 'models/copilot.schema'
@@ -106,10 +106,7 @@ const SheetGroup = ({
106
106
}
107
107
const checkSamePinned = ( target : string ) =>
108
108
! ! favGroups . find ( ( { name } ) => name === target )
109
- const changeOperatorOfOtherGroups = (
110
- target : Operator [ ] | undefined ,
111
- errHandle : UseFormSetError < Group > ,
112
- ) => {
109
+ const changeOperatorOfOtherGroups = ( target : Operator [ ] | undefined ) => {
113
110
target ?. forEach ( ( item ) => {
114
111
existedGroups . forEach ( ( groupItem ) => {
115
112
const oldLength = groupItem . opers ?. length || 0
@@ -118,7 +115,7 @@ const SheetGroup = ({
118
115
( operItem ) => operItem . name !== item . name ,
119
116
)
120
117
if ( groupItem . opers ?. length !== oldLength )
121
- submitGroup ( groupItem , errHandle , true )
118
+ submitGroup ( groupItem , undefined , true )
122
119
}
123
120
} )
124
121
} )
@@ -129,12 +126,7 @@ const SheetGroup = ({
129
126
{ ...value } ,
130
127
] )
131
128
132
- const eventHandleProxy = (
133
- type : EventType ,
134
- value : Group ,
135
- setError ?: UseFormSetError < Group > ,
136
- ) => {
137
- const errHandle = setError || function ( ) { }
129
+ const eventHandleProxy = ( type : EventType , value : Group ) => {
138
130
switch ( type ) {
139
131
case 'add' : {
140
132
if ( checkGroupExisted ( value . name ) ) {
@@ -143,9 +135,8 @@ const SheetGroup = ({
143
135
intent : Intent . DANGER ,
144
136
} )
145
137
} else {
146
- if ( checkGroupPinned ( value ) )
147
- changeOperatorOfOtherGroups ( value . opers , errHandle )
148
- submitGroup ( value , errHandle )
138
+ if ( checkGroupPinned ( value ) ) changeOperatorOfOtherGroups ( value . opers )
139
+ submitGroup ( value )
149
140
}
150
141
break
151
142
}
@@ -163,16 +154,16 @@ const SheetGroup = ({
163
154
break
164
155
}
165
156
case 'rename' : {
166
- submitGroup ( value , errHandle , true )
157
+ submitGroup ( value , undefined , true )
167
158
break
168
159
}
169
160
case 'opers' : {
170
- changeOperatorOfOtherGroups ( value . opers , errHandle )
171
- submitGroup ( value , errHandle , true )
161
+ changeOperatorOfOtherGroups ( value . opers )
162
+ submitGroup ( value , undefined , true )
172
163
break
173
164
}
174
165
case 'update' : {
175
- submitGroup ( value , errHandle , true )
166
+ submitGroup ( value , undefined , true )
176
167
break
177
168
}
178
169
}
@@ -200,16 +191,34 @@ const SheetGroup = ({
200
191
[ coverGroup ?. name ] ,
201
192
)
202
193
194
+ const GroupCount = useMemo (
195
+ ( ) => (
196
+ < H6 className = "my-2 text-center" >
197
+ 已显示全部 { existedGroups . length } 个干员组
198
+ </ H6 >
199
+ ) ,
200
+ [ existedGroups . length ] ,
201
+ )
202
+
203
203
return (
204
204
< >
205
205
{ FavCoverAlert }
206
206
< div className = "flex px-1" >
207
- < div className = "flex-1 sticky top-0 max-h-screen flex flex-col" >
208
- < div className = "grow h-full overflow-y-auto py-1" >
209
- < SheetContainerSkeleton title = "已设置的分组" icon = "cog" mini >
207
+ < div className = "flex-1 sticky top-0 h-screen flex flex-col" >
208
+ < div className = "grow overflow-y-auto" >
209
+ < SheetContainerSkeleton
210
+ title = "添加干员组"
211
+ icon = "add"
212
+ mini
213
+ className = "sticky top-0 z-10 backdrop-blur-lg py-1"
214
+ >
215
+ < EditorGroupName { ...{ eventHandleProxy } } />
216
+ </ SheetContainerSkeleton >
217
+ < SheetContainerSkeleton title = "已设置的干员组" icon = "cog" mini >
210
218
< div >
211
- { existedGroups . length
212
- ? existedGroups . map ( ( item ) => (
219
+ { existedGroups . length ? (
220
+ < >
221
+ { existedGroups . map ( ( item ) => (
213
222
< GroupItem
214
223
key = { item . name }
215
224
existedGroup = { existedGroups }
@@ -220,14 +229,15 @@ const SheetGroup = ({
220
229
pinned = { checkGroupPinned ( item ) }
221
230
eventHandleProxy = { eventHandleProxy }
222
231
/>
223
- ) )
224
- : GroupNoData }
232
+ ) ) }
233
+ { GroupCount }
234
+ </ >
235
+ ) : (
236
+ GroupNoData
237
+ ) }
225
238
</ div >
226
239
</ SheetContainerSkeleton >
227
240
</ div >
228
- < SheetContainerSkeleton title = "添加干员组" icon = "add" mini >
229
- < EditorGroupName { ...{ eventHandleProxy } } />
230
- </ SheetContainerSkeleton >
231
241
</ div >
232
242
< Divider />
233
243
< div className = "flex-1" >
@@ -272,11 +282,7 @@ const SheetGroup = ({
272
282
const EditorGroupName = ( {
273
283
eventHandleProxy,
274
284
} : {
275
- eventHandleProxy : (
276
- type : EventType ,
277
- value : Group ,
278
- setError ?: UseFormSetError < Group > | undefined ,
279
- ) => void
285
+ eventHandleProxy : ( type : EventType , value : Group ) => void
280
286
} ) => {
281
287
const [ groupName , setGroupName ] = useState ( '' )
282
288
@@ -327,7 +333,7 @@ const EditorGroupName = ({
327
333
)
328
334
}
329
335
330
- export const SheetGroupContainer = ( sheetGroupProps : SheetGroupProps ) => (
336
+ export const SheetGroupContainer : FC < SheetGroupProps > = ( sheetGroupProps ) => (
331
337
< SheetContainerSkeleton title = "设置干员组" icon = "people" >
332
338
< SheetGroup { ...sheetGroupProps } />
333
339
</ SheetContainerSkeleton >
0 commit comments