|
| 1 | +import { fetchCustomBackendError } from '@/service/api'; |
| 2 | + |
| 3 | +const Request = () => { |
| 4 | + const { t } = useTranslation(); |
| 5 | + async function logout() { |
| 6 | + await fetchCustomBackendError('8888', t('request.logoutMsg')); |
| 7 | + } |
| 8 | + |
| 9 | + async function logoutWithModal() { |
| 10 | + await fetchCustomBackendError('7777', t('request.logoutWithModalMsg')); |
| 11 | + } |
| 12 | + |
| 13 | + async function refreshToken() { |
| 14 | + await fetchCustomBackendError('9999', t('request.tokenExpired')); |
| 15 | + } |
| 16 | + |
| 17 | + async function handleRepeatedMessageError() { |
| 18 | + await Promise.all([ |
| 19 | + fetchCustomBackendError('2222', t('page.function.request.repeatedErrorMsg1')), |
| 20 | + fetchCustomBackendError('2222', t('page.function.request.repeatedErrorMsg1')), |
| 21 | + fetchCustomBackendError('2222', t('page.function.request.repeatedErrorMsg1')), |
| 22 | + fetchCustomBackendError('3333', t('page.function.request.repeatedErrorMsg2')), |
| 23 | + fetchCustomBackendError('3333', t('page.function.request.repeatedErrorMsg2')), |
| 24 | + fetchCustomBackendError('3333', t('page.function.request.repeatedErrorMsg2')) |
| 25 | + ]); |
| 26 | + } |
| 27 | + async function handleRepeatedModalError() { |
| 28 | + await Promise.all([ |
| 29 | + fetchCustomBackendError('7777', t('request.logoutWithModalMsg')), |
| 30 | + fetchCustomBackendError('7777', t('request.logoutWithModalMsg')), |
| 31 | + fetchCustomBackendError('7777', t('request.logoutWithModalMsg')) |
| 32 | + ]); |
| 33 | + } |
| 34 | + |
| 35 | + return ( |
| 36 | + <ASpace |
| 37 | + className="w-full" |
| 38 | + direction="vertical" |
| 39 | + size={16} |
| 40 | + > |
| 41 | + <ACard |
| 42 | + className="card-wrapper" |
| 43 | + size="small" |
| 44 | + title={t('request.logout')} |
| 45 | + variant="borderless" |
| 46 | + > |
| 47 | + <AButton onClick={logout}>{t('common.trigger')}</AButton> |
| 48 | + </ACard> |
| 49 | + |
| 50 | + <ACard |
| 51 | + className="card-wrapper" |
| 52 | + size="small" |
| 53 | + title={t('request.logoutWithModal')} |
| 54 | + variant="borderless" |
| 55 | + > |
| 56 | + <AButton onClick={logoutWithModal}>{t('common.trigger')}</AButton> |
| 57 | + </ACard> |
| 58 | + |
| 59 | + <ACard |
| 60 | + className="card-wrapper" |
| 61 | + size="small" |
| 62 | + title={t('request.refreshToken')} |
| 63 | + variant="borderless" |
| 64 | + > |
| 65 | + <AButton onClick={refreshToken}>{t('common.trigger')}</AButton> |
| 66 | + </ACard> |
| 67 | + |
| 68 | + <ACard |
| 69 | + className="card-wrapper" |
| 70 | + size="small" |
| 71 | + title={t('page.function.request.repeatedErrorOccurOnce')} |
| 72 | + variant="borderless" |
| 73 | + > |
| 74 | + <AButton onClick={handleRepeatedMessageError}>{t('page.function.request.repeatedError')} (Message)</AButton> |
| 75 | + <AButton |
| 76 | + className="ml-12px" |
| 77 | + onClick={handleRepeatedModalError} |
| 78 | + > |
| 79 | + {t('page.function.request.repeatedError')}(Modal) |
| 80 | + </AButton> |
| 81 | + </ACard> |
| 82 | + </ASpace> |
| 83 | + ); |
| 84 | +}; |
| 85 | + |
| 86 | +export const handle = { |
| 87 | + i18nKey: 'route.function_request', |
| 88 | + icon: 'carbon:network-overlay', |
| 89 | + order: 3, |
| 90 | + title: 'function_request' |
| 91 | +}; |
| 92 | + |
| 93 | +export default Request; |
0 commit comments