Skip to content

Commit

Permalink
fix unwanted error
Browse files Browse the repository at this point in the history
  • Loading branch information
salahlalami committed Sep 29, 2024
1 parent e20a768 commit e9fedc2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 29 deletions.
8 changes: 2 additions & 6 deletions frontend/src/components/SelectTag/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Select, Tag } from 'antd';
import { generate as uniqueId } from 'shortid';
import { tagColor } from '@/utils/statusTagColor';

export default function SelectTag({ options, defaultValue }) {
return (
Expand All @@ -11,19 +10,16 @@ export default function SelectTag({ options, defaultValue }) {
}}
>
{options?.map((value) => {
const option = tagColor(value);
if (option)
return (
<Select.Option key={`${uniqueId()}`} value={option.value}>
<Tag bordered={false} color={option.color}>
{translate(option.label)}
</Tag>
{translate(option.label)}
</Select.Option>
);
else
return (
<Select.Option key={`${uniqueId()}`} value={value}>
<Tag bordered={false}>{value}</Tag>
{value}
</Select.Option>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useMoney } from '@/settings';

import RecordPayment from './RecordPayment';
import useLanguage from '@/locale/useLanguage';
import { tagColor } from '@/utils/statusTagColor';

import { useNavigate } from 'react-router-dom';

export default function Payment({ config, currentItem }) {
Expand Down Expand Up @@ -57,11 +57,7 @@ export default function Payment({ config, currentItem }) {
currentErp.year || ''
}`}
ghost={false}
tags={
<Tag color={tagColor(currentErp.paymentStatus)?.color}>
{currentErp.paymentStatus && translate(currentErp.paymentStatus)}
</Tag>
}
tags={<span>{currentErp.paymentStatus && translate(currentErp.paymentStatus)}</span>}
// subTitle="This is cuurent erp page"
extra={[
<Button
Expand Down Expand Up @@ -102,9 +98,7 @@ export default function Payment({ config, currentItem }) {
<Descriptions.Item label={translate('phone')}>{client.phone}</Descriptions.Item>
<Divider dashed />
<Descriptions.Item label={translate('payment status')}>
<Tag color={tagColor(currentErp.paymentStatus)?.color}>
{currentErp.paymentStatus && translate(currentErp.paymentStatus)}
</Tag>
<span>{currentErp.paymentStatus && translate(currentErp.paymentStatus)}</span>
</Descriptions.Item>
<Descriptions.Item label={translate('sub total')}>
{money.moneyFormatter({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { selectCurrentItem } from '@/redux/erp/selectors';

import { DOWNLOAD_BASE_URL } from '@/config/serverApiConfig';
import { useMoney } from '@/settings';
import { tagColor } from '@/utils/statusTagColor';

import useMail from '@/hooks/useMail';
import { useNavigate } from 'react-router-dom';

Expand Down Expand Up @@ -78,9 +78,7 @@ export default function ReadItem({ config, selectedItem }) {
}}
title={`${ENTITY_NAME} # ${currentErp.number}/${currentErp.year || ''}`}
ghost={false}
tags={
<Tag color={tagColor(currentErp.paymentStatus)?.color}>{currentErp.paymentStatus}</Tag>
}
tags={<span>{currentErp.paymentStatus}</span>}
extra={[
<Button
key={`${uniqueId()}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ export default function Payment({ config, currentItem }) {
onBack={() => navigate(`/${entity.toLowerCase()}`)}
title={`Update ${ENTITY_NAME} # ${currentErp.number}/${currentErp.year || ''}`}
ghost={false}
tags={
<Tag color={tagColor(currentErp.paymentStatus)?.color}>
{currentErp.paymentStatus}
</Tag>
}
tags={<span>{currentErp.paymentStatus}</span>}
// subTitle="This is cuurent erp page"
extra={[
<Button
Expand Down Expand Up @@ -95,9 +91,7 @@ export default function Payment({ config, currentItem }) {
<Descriptions.Item label={translate('Phone')}>{client.phone}</Descriptions.Item>
<Divider dashed />
<Descriptions.Item label={translate('Payment Status')}>
<Tag color={tagColor(currentErp.paymentStatus)?.color}>
{currentErp.paymentStatus}
</Tag>
<span>{currentErp.paymentStatus}</span>
</Descriptions.Item>
<Descriptions.Item label={translate('SubTotal')}>
{money.moneyFormatter({
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/request/errorHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const errorHandler = (error) => {
const message = response.data && response.data.message;

const errorText = message || codeMessage[response.status];
const { status } = response;
const { status, error } = response;
notification.config({
duration: 20,
maxCount: 2,
Expand All @@ -62,7 +62,12 @@ const errorHandler = (error) => {
message: `Request error ${status}`,
description: errorText,
});
return response.data;

if (response?.data?.error?.name === 'JsonWebTokenError') {
window.localStorage.removeItem('auth');
window.localStorage.removeItem('isLogout');
window.location.href = '/logout';
} else return response.data;
} else {
notification.config({
duration: 15,
Expand Down

0 comments on commit e9fedc2

Please sign in to comment.