move updateRole closer to profile-card

This commit is contained in:
vchikalkin 2025-01-15 17:13:22 +03:00
parent 0a49f8dc7d
commit 7652ca9bb4
3 changed files with 12 additions and 9 deletions

View File

@ -1,8 +1,7 @@
/* eslint-disable canonical/id-match */
'use server';
import { authOptions } from '@/config/auth';
import { getCustomer, updateCustomerProfile } from '@repo/graphql/api';
import { type CustomerInput, Enum_Customer_Role } from '@repo/graphql/types';
import { type CustomerInput } from '@repo/graphql/types';
import { getServerSession } from 'next-auth/next';
import { revalidatePath } from 'next/cache';
@ -36,9 +35,3 @@ export async function updateProfile(input: CustomerInput) {
revalidatePath('/profile');
}
export async function updateRole(checked: boolean) {
return updateProfile({
role: checked ? Enum_Customer_Role.Master : Enum_Customer_Role.Client,
});
}

View File

@ -0,0 +1,9 @@
/* eslint-disable canonical/id-match */
import { updateProfile } from '@/actions/profile';
import { Enum_Customer_Role } from '@repo/graphql/types';
export function updateRole(checked: boolean) {
return updateProfile({
role: checked ? Enum_Customer_Role.Master : Enum_Customer_Role.Client,
});
}

View File

@ -1,5 +1,6 @@
'use client';
import { getProfile, updateProfile, updateRole } from '@/actions/profile';
import { updateRole } from './lib/actions';
import { getProfile, updateProfile } from '@/actions/profile';
import { CheckboxWithText } from '@/components/profile/checkbox-with-text';
import { ProfileField } from '@/components/profile/profile-field';
import { Avatar, AvatarFallback, AvatarImage } from '@repo/ui/components/ui/avatar';