feat(import-ratecards-drawer): add alert for already imported rate cards and update button logic
This commit is contained in:
@@ -35,7 +35,8 @@
|
|||||||
"ratecardsPluralText": "Rate Card Templates",
|
"ratecardsPluralText": "Rate Card Templates",
|
||||||
"deleteConfirm": "Are you sure ?",
|
"deleteConfirm": "Are you sure ?",
|
||||||
"yes": "Yes",
|
"yes": "Yes",
|
||||||
"no": "No"
|
"no": "No",
|
||||||
|
"alreadyImportedRateCardMessage": "A rate card has already been imported. Clear all imported rate cards to add a new one."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Drawer, Typography, Button, Table, Menu, Flex, Spin } from 'antd';
|
import { Drawer, Typography, Button, Table, Menu, Flex, Spin, Alert } from 'antd';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAppSelector } from '../../../hooks/useAppSelector';
|
import { useAppSelector } from '../../../hooks/useAppSelector';
|
||||||
@@ -85,32 +85,45 @@ const ImportRatecardsDrawer: React.FC = () => {
|
|||||||
}
|
}
|
||||||
footer={
|
footer={
|
||||||
<div style={{ textAlign: 'right' }}>
|
<div style={{ textAlign: 'right' }}>
|
||||||
<Button
|
{/* Alert message */}
|
||||||
type="primary"
|
{rolesRedux.length !== 0 ? (
|
||||||
disabled={rolesRedux.length !== 0}
|
<div style={{ textAlign: 'right' }}>
|
||||||
onClick={() => {
|
<Alert
|
||||||
if (!projectId) {
|
message={t('alreadyImportedRateCardMessage') || 'A rate card has already been imported. Clear all imported rate cards to add a new one.'}
|
||||||
// Handle missing project id (show error, etc.)
|
type="warning"
|
||||||
return;
|
showIcon
|
||||||
}
|
style={{ marginBottom: 16 }}
|
||||||
if (drawerRatecard?.jobRolesList?.length) {
|
/>
|
||||||
dispatch(
|
</div>
|
||||||
insertProjectRateCardRoles({
|
) : (
|
||||||
project_id: projectId,
|
<div style={{ textAlign: 'right' }}>
|
||||||
roles: drawerRatecard.jobRolesList
|
<Button
|
||||||
.filter((role) => typeof role.rate !== 'undefined')
|
type="primary"
|
||||||
.map((role) => ({
|
onClick={() => {
|
||||||
...role,
|
if (!projectId) {
|
||||||
rate: Number(role.rate),
|
// Handle missing project id (show error, etc.)
|
||||||
})),
|
return;
|
||||||
})
|
}
|
||||||
);
|
if (drawerRatecard?.jobRolesList?.length) {
|
||||||
}
|
dispatch(
|
||||||
dispatch(toggleImportRatecardsDrawer());
|
insertProjectRateCardRoles({
|
||||||
}}
|
project_id: projectId,
|
||||||
>
|
roles: drawerRatecard.jobRolesList
|
||||||
{t('import')}
|
.filter((role) => typeof role.rate !== 'undefined')
|
||||||
</Button>
|
.map((role) => ({
|
||||||
|
...role,
|
||||||
|
rate: Number(role.rate),
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
dispatch(toggleImportRatecardsDrawer());
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('import')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
open={isDrawerOpen}
|
open={isDrawerOpen}
|
||||||
|
|||||||
Reference in New Issue
Block a user