mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat: handle transactions locking request error.
This commit is contained in:
@@ -47,14 +47,14 @@ const AlertRoot = styled.div`
|
|||||||
`}
|
`}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const AlertTitle = styled.h3`
|
export const AlertTitle = styled.h3`
|
||||||
color: rgb(17, 24, 28);
|
color: rgb(17, 24, 28);
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const AlertDesc = styled.p`
|
export const AlertDesc = styled.p`
|
||||||
color: rgb(104, 112, 118);
|
color: rgb(104, 112, 118);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function MoneyInForm({
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setSubmitting(true);
|
setSubmitting(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function MoneyOutForm({
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setSubmitting(true);
|
setSubmitting(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -53,9 +53,11 @@ function GlobalErrors({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (globalErrors.transactionsLocked) {
|
if (globalErrors.transactionsLocked) {
|
||||||
|
const lockedToDate =
|
||||||
|
globalErrors.transactionsLocked.formatted_locked_to_date;
|
||||||
|
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message:
|
message: `Transactions before ${lockedToDate} has been locked. Hence action cannot be performed.`,
|
||||||
'Transactions before 13 Dec 2021 has been locked. Hence action cannot be performed.',
|
|
||||||
intent: Intent.DANGER,
|
intent: Intent.DANGER,
|
||||||
onDismiss: () => {
|
onDismiss: () => {
|
||||||
globalErrorsSet({ transactionsLocked: false });
|
globalErrorsSet({ transactionsLocked: false });
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
@@ -11,6 +10,7 @@ import {
|
|||||||
Join,
|
Join,
|
||||||
Paragraph,
|
Paragraph,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
|
AlertDesc
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import { TransactionsLockingProvider } from './TransactionsLockingProvider';
|
import { TransactionsLockingProvider } from './TransactionsLockingProvider';
|
||||||
import {
|
import {
|
||||||
@@ -258,4 +258,8 @@ const LockAllAlert = styled(Alert)`
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
||||||
|
${AlertDesc} {
|
||||||
|
color: #1f3255;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ const TransactionLockingWrapp = styled.div`
|
|||||||
${(props) =>
|
${(props) =>
|
||||||
props.isEnabled &&
|
props.isEnabled &&
|
||||||
`
|
`
|
||||||
border-color: #fe9f9e;
|
border-color: #fc8483;
|
||||||
|
|
||||||
${TransLockingIcon} {
|
${TransLockingIcon} {
|
||||||
color: #ff8282;
|
color: #ff8282;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function useApiRequest() {
|
|||||||
const setGlobalErrors = useSetGlobalErrors();
|
const setGlobalErrors = useSetGlobalErrors();
|
||||||
const { setLogout } = useAuthActions();
|
const { setLogout } = useAuthActions();
|
||||||
const currentLocale = getCookie('locale');
|
const currentLocale = getCookie('locale');
|
||||||
|
|
||||||
// Authentication token.
|
// Authentication token.
|
||||||
const token = useAuthToken();
|
const token = useAuthToken();
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ export default function useApiRequest() {
|
|||||||
instance.interceptors.response.use(
|
instance.interceptors.response.use(
|
||||||
(response) => response,
|
(response) => response,
|
||||||
(error) => {
|
(error) => {
|
||||||
const { status } = error.response;
|
const { status, data } = error.response;
|
||||||
|
|
||||||
if (status >= 500) {
|
if (status >= 500) {
|
||||||
setGlobalErrors({ something_wrong: true });
|
setGlobalErrors({ something_wrong: true });
|
||||||
@@ -57,7 +57,15 @@ export default function useApiRequest() {
|
|||||||
setLogout();
|
setLogout();
|
||||||
}
|
}
|
||||||
if (status === 403) {
|
if (status === 403) {
|
||||||
setGlobalErrors({ access_denied: true })
|
setGlobalErrors({ access_denied: true });
|
||||||
|
}
|
||||||
|
if (status === 400) {
|
||||||
|
const lockedError = data.errors.find(
|
||||||
|
(error) => error.type === 'TRANSACTIONS_DATE_LOCKED',
|
||||||
|
);
|
||||||
|
if (lockedError) {
|
||||||
|
setGlobalErrors({ transactionsLocked: { ...lockedError.data } });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
},
|
},
|
||||||
@@ -65,27 +73,30 @@ export default function useApiRequest() {
|
|||||||
return instance;
|
return instance;
|
||||||
}, [token, organizationId, setGlobalErrors, setLogout]);
|
}, [token, organizationId, setGlobalErrors, setLogout]);
|
||||||
|
|
||||||
return React.useMemo(() => ({
|
return React.useMemo(
|
||||||
http,
|
() => ({
|
||||||
|
http,
|
||||||
|
|
||||||
get(resource, params) {
|
get(resource, params) {
|
||||||
return http.get(`/api/${resource}`, params);
|
return http.get(`/api/${resource}`, params);
|
||||||
},
|
},
|
||||||
|
|
||||||
post(resource, params, config) {
|
post(resource, params, config) {
|
||||||
return http.post(`/api/${resource}`, params, config);
|
return http.post(`/api/${resource}`, params, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
update(resource, slug, params) {
|
update(resource, slug, params) {
|
||||||
return http.put(`/api/${resource}/${slug}`, params);
|
return http.put(`/api/${resource}/${slug}`, params);
|
||||||
},
|
},
|
||||||
|
|
||||||
put(resource, params) {
|
put(resource, params) {
|
||||||
return http.put(`/api/${resource}`, params);
|
return http.put(`/api/${resource}`, params);
|
||||||
},
|
},
|
||||||
|
|
||||||
delete(resource, params) {
|
delete(resource, params) {
|
||||||
return http.delete(`/api/${resource}`, params);
|
return http.delete(`/api/${resource}`, params);
|
||||||
},
|
},
|
||||||
}), [http]);
|
}),
|
||||||
|
[http],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1630,7 +1630,7 @@
|
|||||||
"transactions_locking.paetial_unlock": "Partial Unlock",
|
"transactions_locking.paetial_unlock": "Partial Unlock",
|
||||||
"transactions_locking.cancel_partial_unlock": "Cancel Partial Unlock",
|
"transactions_locking.cancel_partial_unlock": "Cancel Partial Unlock",
|
||||||
"transactions_locking.of_the_module_locked_to": "Transactions of the module locked to <strong>{value}</strong>.",
|
"transactions_locking.of_the_module_locked_to": "Transactions of the module locked to <strong>{value}</strong>.",
|
||||||
"transactions_locking.lock_reason": "Lock Reason: <strong>{value}</strong>.",
|
"transactions_locking.lock_reason": "<strong>Lock Reason</strong>: {value}.",
|
||||||
"transactions_locking.partial_unlocked_from": "Partial unlocked from <strong>{fromDate}</strong> to <strong>{toDate}</strong>.",
|
"transactions_locking.partial_unlocked_from": "Partial unlocked from <strong>{fromDate}</strong> to <strong>{toDate}</strong>.",
|
||||||
"transactions_locking.unlock_reason":"<strong>Unlock Reason:</strong> {value}.",
|
"transactions_locking.unlock_reason":"<strong>Unlock Reason:</strong> {value}.",
|
||||||
"payment_transactions":"Payment transactions"
|
"payment_transactions":"Payment transactions"
|
||||||
|
|||||||
Reference in New Issue
Block a user