add health benefit form
fix super admin
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { UpdateHealthBenefitData } from '@/packages/features/team-accounts/src/server/types';
|
||||
|
||||
import { enhanceAction } from '@kit/next/actions';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
@@ -63,3 +65,13 @@ export const createBillingPortalSession = enhanceAction(
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
export const updateHealthBenefit = enhanceAction(
|
||||
async (data: UpdateHealthBenefitData) => {
|
||||
const client = getSupabaseServerClient();
|
||||
const service = createTeamBillingService(client);
|
||||
|
||||
await service.updateHealthBenefit(data);
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'server-only';
|
||||
|
||||
import { SupabaseClient } from '@supabase/supabase-js';
|
||||
|
||||
import { UpdateHealthBenefitData } from '@/packages/features/team-accounts/src/server/types';
|
||||
import { Database } from '@/packages/supabase/src/database.types';
|
||||
import { z } from 'zod';
|
||||
|
||||
@@ -292,6 +293,25 @@ class TeamBillingService {
|
||||
return Promise.reject(error as Error);
|
||||
}
|
||||
}
|
||||
|
||||
async updateHealthBenefit(data: UpdateHealthBenefitData): Promise<void> {
|
||||
const api = createTeamAccountsApi(this.client);
|
||||
const logger = await getLogger();
|
||||
try {
|
||||
await api.updateHealthBenefit(data);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{
|
||||
accountId: data.accountId,
|
||||
error,
|
||||
name: `billing.updateHealthBenefit`,
|
||||
},
|
||||
`Encountered an error while updating the company health benefit`,
|
||||
);
|
||||
|
||||
return Promise.reject(error as Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCheckoutSessionReturnUrl(accountSlug: string) {
|
||||
|
||||
Reference in New Issue
Block a user