feat(import-ratecards-drawer): add alert for already imported rate cards and update button logic

This commit is contained in:
shancds
2025-05-28 12:12:33 +05:30
parent bc652f83af
commit 5cb6548889
2 changed files with 42 additions and 28 deletions

View File

@@ -35,7 +35,8 @@
"ratecardsPluralText": "Rate Card Templates",
"deleteConfirm": "Are you sure ?",
"yes": "Yes",
"no": "No"
"no": "No",
"alreadyImportedRateCardMessage": "A rate card has already been imported. Clear all imported rate cards to add a new one."
}

View File

@@ -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 { useTranslation } from 'react-i18next';
import { useAppSelector } from '../../../hooks/useAppSelector';
@@ -84,10 +84,21 @@ const ImportRatecardsDrawer: React.FC = () => {
</Typography.Text>
}
footer={
<div style={{ textAlign: 'right' }}>
{/* Alert message */}
{rolesRedux.length !== 0 ? (
<div style={{ textAlign: 'right' }}>
<Alert
message={t('alreadyImportedRateCardMessage') || 'A rate card has already been imported. Clear all imported rate cards to add a new one.'}
type="warning"
showIcon
style={{ marginBottom: 16 }}
/>
</div>
) : (
<div style={{ textAlign: 'right' }}>
<Button
type="primary"
disabled={rolesRedux.length !== 0}
onClick={() => {
if (!projectId) {
// Handle missing project id (show error, etc.)
@@ -112,6 +123,8 @@ const ImportRatecardsDrawer: React.FC = () => {
{t('import')}
</Button>
</div>
)}
</div>
}
open={isDrawerOpen}
onClose={() => dispatch(toggleImportRatecardsDrawer())}