feat(ratecard-drawer): add confirmation popover for role deletion and improve button styling

This commit is contained in:
shancds
2025-05-26 10:26:51 +05:30
parent 1969fbd1dc
commit f68c72a92a

View File

@@ -1,4 +1,4 @@
import { Drawer, Select, Typography, Flex, Button, Input, Table } from 'antd'; import { Drawer, Select, Typography, Flex, Button, Input, Table, Popconfirm, Tooltip } from 'antd';
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAppSelector } from '../../../hooks/useAppSelector'; import { useAppSelector } from '../../../hooks/useAppSelector';
@@ -7,7 +7,8 @@ import { deleteRateCard, fetchRateCardById, fetchRateCards, toggleRatecardDrawer
import { RatecardType, IJobType } from '@/types/project/ratecard.types'; import { RatecardType, IJobType } from '@/types/project/ratecard.types';
import { IJobTitlesViewModel } from '@/types/job.types'; import { IJobTitlesViewModel } from '@/types/job.types';
import { jobTitlesApiService } from '@/api/settings/job-titles/job-titles.api.service'; import { jobTitlesApiService } from '@/api/settings/job-titles/job-titles.api.service';
import { DeleteOutlined } from '@ant-design/icons'; import { DeleteOutlined, ExclamationCircleFilled } from '@ant-design/icons';
import { colors } from '@/styles/colors';
interface PaginationType { interface PaginationType {
current: number; current: number;
@@ -220,7 +221,7 @@ const RatecardDrawer = ({
setAddingRowIndex(null); setAddingRowIndex(null);
}} }}
onBlur={() => { onBlur={() => {
if (roles[index].job_title_id === ""){ if (roles[index].job_title_id === "") {
handleDeleteRole(index); handleDeleteRole(index);
} }
setEditingRowIndex(null); setEditingRowIndex(null);
@@ -244,7 +245,7 @@ const RatecardDrawer = ({
return ( return (
<span <span
style={{ cursor: 'pointer' }} style={{ cursor: 'pointer' }}
// onClick={() => setEditingRowIndex(index)} // onClick={() => setEditingRowIndex(index)}
> >
{record.jobtitle} {record.jobtitle}
</span> </span>
@@ -280,11 +281,25 @@ const RatecardDrawer = ({
title: t('actionsColumn') || 'Actions', title: t('actionsColumn') || 'Actions',
dataIndex: 'actions', dataIndex: 'actions',
render: (_: any, __: any, index: number) => ( render: (_: any, __: any, index: number) => (
<Button <Popconfirm
size="small" title={t('deleteConfirmationTitle')}
icon={<DeleteOutlined />} icon={<ExclamationCircleFilled style={{ color: colors.vibrantOrange }} />}
onClick={() => handleDeleteRole(index)} okText={t('deleteConfirmationOk')}
/> cancelText={t('deleteConfirmationCancel')}
onConfirm={async () => {
if (index) {
handleDeleteRole(index);
}
}}
>
<Tooltip title="Delete">
<Button
size="small"
icon={<DeleteOutlined />}
/>
</Tooltip>
</Popconfirm>
), ),
}, },
]; ];
@@ -344,7 +359,7 @@ const RatecardDrawer = ({
width={700} width={700}
footer={ footer={
<Flex justify="end" gap={16} style={{ marginTop: 16 }}> <Flex justify="end" gap={16} style={{ marginTop: 16 }}>
<Button style={{ marginBottom: 24 }} onClick={handleSave} type="primary" disabled={name === '' || name === 'Untitled Rate Card' && roles.length ===0}>{t('saveButton')}</Button> <Button style={{ marginBottom: 24 }} onClick={handleSave} type="primary" disabled={name === '' || name === 'Untitled Rate Card' && roles.length === 0}>{t('saveButton')}</Button>
</Flex> </Flex>
} }
> >
@@ -356,13 +371,13 @@ const RatecardDrawer = ({
pagination={false} pagination={false}
footer={() => ( footer={() => (
<Button <Button
type="dashed" type="dashed"
onClick={handleAddRole} onClick={handleAddRole}
block block
style={{ margin: 0, padding: 0 }} style={{ margin: 0, padding: 0 }}
> >
{t('addRoleButton')} {t('addRoleButton')}
</Button> </Button>
)} )}
/> />
</Drawer> </Drawer>