Skip to main content

Company Details & Settings

This page covers the APIs used on the company profile and settings pages.


1. Get Company Details

  • API Endpoint: POST /api/companies/get-by-id
  • Page Route: /admin/companies/:id
  • Component File: src/features/companies/components/CompanyProfileView.tsx
  • Used For: Loads company profile information, associated departments, employee bands, and booking statistics when an admin views a specific company profile.
const { data: company, isLoading } = useQuery({
queryKey: ['companies', companyId],
queryFn: () => apiClient.post('/api/companies/get-by-id', { id: companyId }),
});

2. Update Company Settings

  • API Endpoint: POST /api/companies/update
  • Page Route: /admin/companies/:id/settings
  • Component File: src/features/companies/components/CompanySettingsForm.tsx
  • Used For: Triggered when the admin updates credit limits, payment credit days, or company display name in the settings tab.
const updateCompany = useMutation({
mutationFn: (payload: { id: string; creditLimit?: number; creditDays?: number }) =>
apiClient.post('/api/companies/update', payload),
onSuccess: () => toast.success('Settings saved'),
});

3. Delete / Deactivate Company

  • API Endpoint: POST /api/companies/delete
  • Page Route: /admin/companies/:id/settings (Danger Zone)
  • Component File: src/features/companies/components/DeleteCompanyModal.tsx
  • Used For: Soft-deletes the company profile when an admin confirms deactivation in the danger zone popup modal.
const deleteCompany = useMutation({
mutationFn: (id: string) => apiClient.post('/api/companies/delete', { id }),
onSuccess: () => {
toast.success('Company deactivated');
navigate('/admin/companies');
},
});