fix(webapp): handle the too many requests error

This commit is contained in:
Ahmed Bouhuolia
2023-07-16 21:19:06 +02:00
parent 92f929152f
commit 8b0feb9022
5 changed files with 26 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ import { compose } from '@/utils';
let toastKeySessionExpired; let toastKeySessionExpired;
let toastKeySomethingWrong; let toastKeySomethingWrong;
let toastTooManyRequests;
function GlobalErrors({ function GlobalErrors({
// #withGlobalErrors // #withGlobalErrors
@@ -41,6 +42,18 @@ function GlobalErrors({
toastKeySomethingWrong, toastKeySomethingWrong,
); );
} }
if (globalErrors.too_many_requests) {
toastTooManyRequests = AppToaster.show(
{
message: intl.get('global_error.too_many_requests'),
intent: Intent.DANGER,
onDismiss: () => {
globalErrorsSet({ too_many_requests: false });
},
},
toastTooManyRequests,
);
}
if (globalErrors.access_denied) { if (globalErrors.access_denied) {
toastKeySomethingWrong = AppToaster.show( toastKeySomethingWrong = AppToaster.show(
{ {

View File

@@ -60,6 +60,9 @@ export default function useApiRequest() {
if (status === 403) { if (status === 403) {
setGlobalErrors({ access_denied: true }); setGlobalErrors({ access_denied: true });
} }
if (status === 429) {
setGlobalErrors({ too_many_requests: true });
}
if (status === 400) { if (status === 400) {
const lockedError = data.errors.find( const lockedError = data.errors.find(
(error) => error.type === 'TRANSACTIONS_DATE_LOCKED', (error) => error.type === 'TRANSACTIONS_DATE_LOCKED',

View File

@@ -2292,5 +2292,6 @@
"sidebar.projects": "Projects", "sidebar.projects": "Projects",
"sidebar.new_project": "New Project", "sidebar.new_project": "New Project",
"sidebar.new_time_entry": "New Time Entry", "sidebar.new_time_entry": "New Time Entry",
"sidebar.project_profitability_summary": "Project Profitability Summary" "sidebar.project_profitability_summary": "Project Profitability Summary",
"global_error.too_many_requests": "Too many requests"
} }

View File

@@ -1,10 +1,12 @@
@import '@/style/variables.scss';
.bigcapital-loading { .bigcapital-loading {
height: 100%; height: 100%;
width: 100%; width: 100%;
position: fixed; position: fixed;
display: flex; display: flex;
background: #fff; background: #fff;
z-index: 999999; z-index: $zindex-dashboard-splash-screen;
.center { .center {
width: auto; width: auto;

View File

@@ -45,3 +45,7 @@ $form-check-input-checked-color: #fff;
$form-check-input-checked-bg-color: $blue1; $form-check-input-checked-bg-color: $blue1;
$form-check-input-checked-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 16 16' enable-background='new 0 0 16 16' xml:space='preserve'><g id='small_tick_1_'><g><path fill='#{$form-check-input-checked-color}' fill-rule='evenodd' clip-rule='evenodd' d='M12,5c-0.28,0-0.53,0.11-0.71,0.29L7,9.59L4.71,7.29C4.53,7.11,4.28,7,4,7C3.45,7,3,7.45,3,8c0,0.28,0.11,0.53,0.29,0.71l3,3C6.47,11.89,6.72,12,7,12s0.53-0.11,0.71-0.29l5-5C12.89,6.53,13,6.28,13,6C13,5.45,12.55,5,12,5z'/></g></g></svg>") !default; $form-check-input-checked-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 16 16' enable-background='new 0 0 16 16' xml:space='preserve'><g id='small_tick_1_'><g><path fill='#{$form-check-input-checked-color}' fill-rule='evenodd' clip-rule='evenodd' d='M12,5c-0.28,0-0.53,0.11-0.71,0.29L7,9.59L4.71,7.29C4.53,7.11,4.28,7,4,7C3.45,7,3,7.45,3,8c0,0.28,0.11,0.53,0.29,0.71l3,3C6.47,11.89,6.72,12,7,12s0.53-0.11,0.71-0.29l5-5C12.89,6.53,13,6.28,13,6C13,5.45,12.55,5,12,5z'/></g></g></svg>") !default;
$form-check-input-indeterminate-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 16 16' enable-background='new 0 0 16 16' xml:space='preserve'><g id='small_tick_1_'><g><path fill='#{$form-check-input-checked-color}' fill-rule='evenodd' clip-rule='evenodd' d='M11,7H5C4.45,7,4,7.45,4,8c0,0.55,0.45,1,1,1h6c0.55,0,1-0.45,1-1C12,7.45,11.55,7,11,7z'/></g></g></svg>") !default; $form-check-input-indeterminate-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 16 16' enable-background='new 0 0 16 16' xml:space='preserve'><g id='small_tick_1_'><g><path fill='#{$form-check-input-checked-color}' fill-rule='evenodd' clip-rule='evenodd' d='M11,7H5C4.45,7,4,7.45,4,8c0,0.55,0.45,1,1,1h6c0.55,0,1-0.45,1-1C12,7.45,11.55,7,11,7z'/></g></g></svg>") !default;
// z-indexs
$zindex-dashboard-splash-screen: 39;
$zindex-toast: 40;