feat(ratecard): enhance project rate card functionality with job title retrieval and bulk save feature

This commit is contained in:
shancds
2025-05-21 18:59:04 +05:30
parent c3bec74897
commit 3ce81272b2
5 changed files with 207 additions and 63 deletions

View File

@@ -10,7 +10,7 @@ import { useParams } from 'react-router-dom';
const ImportRatecardsDrawer: React.FC = () => {
const dispatch = useAppDispatch();
const { projectId } = useParams();
const { projectId } = useParams();
const { t } = useTranslation('project-view-finance');
const drawerRatecard = useAppSelector(
@@ -26,6 +26,8 @@ const { projectId } = useParams();
(state) => state.financeReducer.currency
).toUpperCase();
const rolesRedux = useAppSelector((state) => state.projectFinanceRateCard.rateCardRoles) || [];
// Loading states
const isRatecardsLoading = useAppSelector(
(state) => state.financeReducer.isRatecardsLoading
@@ -83,31 +85,32 @@ const { projectId } = useParams();
}
footer={
<div style={{ textAlign: 'right' }}>
<Button
type="primary"
onClick={() => {
if (!projectId) {
// Handle missing project id (show error, etc.)
return;
}
if (drawerRatecard?.jobRolesList?.length) {
dispatch(
insertProjectRateCardRoles({
project_id: projectId,
roles: drawerRatecard.jobRolesList
.filter((role) => typeof role.rate !== 'undefined')
.map((role) => ({
...role,
rate: Number(role.rate),
})),
})
);
}
dispatch(toggleImportRatecardsDrawer());
}}
>
{t('import')}
</Button>
<Button
type="primary"
disabled={rolesRedux.length !== 0}
onClick={() => {
if (!projectId) {
// Handle missing project id (show error, etc.)
return;
}
if (drawerRatecard?.jobRolesList?.length) {
dispatch(
insertProjectRateCardRoles({
project_id: projectId,
roles: drawerRatecard.jobRolesList
.filter((role) => typeof role.rate !== 'undefined')
.map((role) => ({
...role,
rate: Number(role.rate),
})),
})
);
}
dispatch(toggleImportRatecardsDrawer());
}}
>
{t('import')}
</Button>
</div>
}
open={isDrawerOpen}