feat(admin-center): implement admin center settings retrieval and enhance holiday population logic

- Added a new API endpoint in AdminCenterController to fetch admin center settings, including organization details.
- Updated the admin center API router to include the new settings route.
- Enhanced the holiday controller to check for recent holiday population before attempting to repopulate, preventing duplicate entries.
- Improved the holiday calendar component to manage holiday population attempts and display loading states.
- Updated localization files to support new messages related to calculation methods and holiday settings.
This commit is contained in:
chamikaJ
2025-07-30 11:35:12 +05:30
parent 069ae6ccb1
commit 9dfc1fa375
19 changed files with 340 additions and 226 deletions

View File

@@ -17,6 +17,7 @@ import { PageHeader } from '@ant-design/pro-components';
import { useTranslation } from 'react-i18next';
import logger from '@/utils/errorLogger';
import { scheduleAPIService } from '@/api/schedule/schedule.api.service';
import { adminCenterApiService } from '@/api/admin-center/admin-center.api.service';
import { Settings } from '@/types/schedule/schedule-v2.types';
import OrganizationCalculationMethod from '@/components/admin-center/overview/organization-calculation-method/organization-calculation-method';
import HolidayCalendar from '@/components/admin-center/overview/holiday-calendar/holiday-calendar';
@@ -25,6 +26,7 @@ import { useAppSelector } from '@/hooks/useAppSelector';
import { RootState } from '@/app/store';
import {
fetchOrganizationDetails,
fetchAdminCenterSettings,
fetchOrganizationAdmins,
fetchHolidaySettings,
updateHolidaySettings,
@@ -49,11 +51,11 @@ const SettingsPage: React.FC = () => {
const { t } = useTranslation('admin-center/settings');
const getOrganizationDetails = async () => {
const getAdminCenterSettings = async () => {
try {
await dispatch(fetchOrganizationDetails()).unwrap();
await dispatch(fetchAdminCenterSettings()).unwrap();
} catch (error) {
logger.error('Error getting organization details', error);
logger.error('Error getting admin center settings', error);
}
};
@@ -111,7 +113,7 @@ const SettingsPage: React.FC = () => {
};
useEffect(() => {
getOrganizationDetails();
getAdminCenterSettings();
getOrganizationAdmins();
getOrgWorkingSettings();
dispatch(fetchHolidaySettings());
@@ -202,10 +204,12 @@ const SettingsPage: React.FC = () => {
</Form>
</Card>
<OrganizationCalculationMethod
organization={organization}
refetch={getOrganizationDetails}
/>
{organization && (
<OrganizationCalculationMethod
organization={organization}
refetch={getAdminCenterSettings}
/>
)}
<Card>
<Typography.Title level={5} style={{ margin: 0 }}>