@@ -113,7 +113,7 @@ const changeGroup = async (body: PostValidatorDashboardValidatorsRequest, groupI
113113 },
114114 { dashboardKey: dashboardKey .value },
115115 ).then (() => {
116- loadData ()
116+ loadData (dashboardKey . value )
117117 refreshOverview (dashboardKey .value )
118118 })
119119}
@@ -137,7 +137,7 @@ const removeValidators = async (validators?: NumberOrString[]) => {
137137 { dashboardKey: dashboardKey .value },
138138 )
139139
140- loadData ()
140+ loadData (dashboardKey . value )
141141 refreshOverview (dashboardKey .value )
142142}
143143
@@ -186,13 +186,13 @@ watch(selectedGroup, (value) => {
186186 })
187187})
188188
189- const loadData = async () => {
190- if (dashboardKey . value ) {
189+ const loadData = async (dashboardKey : string ) => {
190+ if (dashboardKey ) {
191191 const testQ = JSON .stringify (query .value )
192192 const result = await fetch <GetValidatorDashboardValidatorsResponse >(
193193 ' DASHBOARD_VALIDATOR_MANAGEMENT' ,
194194 undefined ,
195- { dashboardKey: dashboardKey . value },
195+ { dashboardKey },
196196 query .value ,
197197 )
198198
@@ -212,13 +212,12 @@ const loadData = async () => {
212212
213213watch (
214214 () => [
215- dashboardKey .value ,
216215 visible .value ,
217216 query .value ,
218217 ],
219218 () => {
220219 if (visible .value ) {
221- loadData ()
220+ loadData (dashboardKey . value )
222221 }
223222 },
224223 { immediate: true },
@@ -297,7 +296,7 @@ const handleInvalidSubmit = () => {
297296const resetInput = () => {
298297 inputValidator .value = ' '
299298}
300- const handleSubmit = (item : InternalPostSearchResponse [' data' ][number ] | undefined ) => {
299+ const handleSubmit = async (item : InternalPostSearchResponse [' data' ][number ] | undefined ) => {
301300 if (! item ) return
302301 const {
303302 type,
@@ -315,21 +314,49 @@ const handleSubmit = (item: InternalPostSearchResponse['data'][number] | undefin
315314 return
316315 }
317316 if (isGuestDashboard .value ) {
317+ let hasError = false
318+ const currentValidators = decodeBase64Url (dashboardKey .value ).split (' ,' )
318319 if (item .type === ' validator' ) {
319- addEntities ([ ` ${item .value .index } ` ])
320- resetInput ()
320+ const newValidators = [
321+ ... currentValidators ,
322+ item .value .index ,
323+ ]
324+ await loadData (encodeBase64Url (newValidators .join (' ,' )))
325+ .then (() => addEntities ([ ` ${item .value .index } ` ]))
326+ .then (() => resetInput ())
327+ .catch ((error ) => {
328+ hasError = true
329+ if (error .statusCode === 400 ) {
330+ dialog .open (BcPremiumModal , {
331+ data: {
332+ description: $t (' dashboard.validator.management.validators_limit_exceeded' ),
333+ },
334+ })
335+ }
336+ })
321337 return
322338 }
323339 if (item .type === ' validator_list' ) {
324- addEntities (
325- item .value .validators
326- .map (validator => ` ${validator } ` ),
327- )
328- resetInput ()
329- return
340+ const validatorList = item .value .validators .map (validator => ` ${validator } ` )
341+ const newValidators = [
342+ ... currentValidators ,
343+ ... validatorList ,
344+ ]
345+ await loadData (encodeBase64Url (newValidators .join (' ,' )))
346+ .then (() => addEntities (validatorList ))
347+ .then (() => resetInput ())
348+ .catch ((error ) => {
349+ hasError = true
350+ if (error .statusCode === 400 ) {
351+ dialog .open (BcPremiumModal , {
352+ data: {
353+ description: $t (' dashboard.validator.management.validators_limit_exceeded' ),
354+ },
355+ })
356+ }
357+ })
330358 }
331- handleInvalidSubmit ()
332- return
359+ if (hasError ) return
333360 }
334361 changeGroup ({
335362 ... (type === ' validator' && { validators: [ value .index ] }),
0 commit comments