import { redirect } from 'next/navigation';

import pathsConfig from '@/config/paths.config';

import { getSupabaseServerClient } from '@kit/supabase/server-client';

import { withI18n } from '~/lib/i18n/with-i18n';

import MembershipConfirmationNotification from './_components/membership-confirmation-notification';

async function UpdateAccountSuccess() {
  const client = getSupabaseServerClient();

  const {
    data: { user },
  } = await client.auth.getUser();

  if (!user?.id) {
    redirect(pathsConfig.app.home);
  }

  return <MembershipConfirmationNotification userId={user.id} />;
}

export default withI18n(UpdateAccountSuccess);
