feat(project-finance): add action to update project-specific currency
- Introduced a new action `updateProjectFinanceCurrency` in the project finance slice to allow updating the currency for individual projects. - Updated the ProjectViewFinance component to dispatch the new action when the project currency is changed, ensuring the state reflects the selected currency.
This commit is contained in:
@@ -164,6 +164,11 @@ export const projectFinancesSlice = createSlice({
|
|||||||
task.show_sub_tasks = !task.show_sub_tasks;
|
task.show_sub_tasks = !task.show_sub_tasks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updateProjectFinanceCurrency: (state, action: PayloadAction<string>) => {
|
||||||
|
if (state.project) {
|
||||||
|
state.project.currency = action.payload;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
@@ -222,7 +227,8 @@ export const {
|
|||||||
updateTaskFixedCost,
|
updateTaskFixedCost,
|
||||||
updateTaskEstimatedCost,
|
updateTaskEstimatedCost,
|
||||||
updateTaskTimeLogged,
|
updateTaskTimeLogged,
|
||||||
toggleTaskExpansion
|
toggleTaskExpansion,
|
||||||
|
updateProjectFinanceCurrency
|
||||||
} = projectFinancesSlice.actions;
|
} = projectFinancesSlice.actions;
|
||||||
|
|
||||||
export default projectFinancesSlice.reducer;
|
export default projectFinancesSlice.reducer;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { CaretDownFilled, DownOutlined } from '@ant-design/icons';
|
import { CaretDownFilled, DownOutlined } from '@ant-design/icons';
|
||||||
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
||||||
import { useAppSelector } from '@/hooks/useAppSelector';
|
import { useAppSelector } from '@/hooks/useAppSelector';
|
||||||
import { fetchProjectFinances, setActiveTab, setActiveGroup } from '@/features/projects/finance/project-finance.slice';
|
import { fetchProjectFinances, setActiveTab, setActiveGroup, updateProjectFinanceCurrency } from '@/features/projects/finance/project-finance.slice';
|
||||||
import { changeCurrency, toggleImportRatecardsDrawer } from '@/features/finance/finance-slice';
|
import { changeCurrency, toggleImportRatecardsDrawer } from '@/features/finance/finance-slice';
|
||||||
import { updateProjectCurrency } from '@/features/project/project.slice';
|
import { updateProjectCurrency } from '@/features/project/project.slice';
|
||||||
import { projectFinanceApiService } from '@/api/project-finance-ratecard/project-finance.api.service';
|
import { projectFinanceApiService } from '@/api/project-finance-ratecard/project-finance.api.service';
|
||||||
@@ -94,6 +94,7 @@ const ProjectViewFinance = () => {
|
|||||||
// Update both global currency state and project-specific currency
|
// Update both global currency state and project-specific currency
|
||||||
dispatch(changeCurrency(currency));
|
dispatch(changeCurrency(currency));
|
||||||
dispatch(updateProjectCurrency(upperCaseCurrency));
|
dispatch(updateProjectCurrency(upperCaseCurrency));
|
||||||
|
dispatch(updateProjectFinanceCurrency(upperCaseCurrency));
|
||||||
|
|
||||||
message.success('Project currency updated successfully');
|
message.success('Project currency updated successfully');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user