use useProfileMutation hook for update role

This commit is contained in:
vchikalkin 2025-02-08 21:34:07 +03:00
parent d73879d0a6
commit 8407a4e4c4
2 changed files with 2 additions and 11 deletions

View File

@ -1,8 +1,8 @@
'use client';
import { type ProfileProps } from '../types';
import { CheckboxWithText, DataField, ProfileCardHeader } from './components';
import { updateRole } from './lib/actions';
import { useProfile, useProfileMutation } from '@/hooks/profile';
import { Enum_Customer_Role as Role } from '@repo/graphql/types';
import { Button } from '@repo/ui/components/ui/button';
import { Card } from '@repo/ui/components/ui/card';
import Link from 'next/link';
@ -49,7 +49,7 @@ export function ProfileDataCard() {
<CheckboxWithText
checked={customer.role !== 'client'}
description="Разрешить другим пользователям записываться к вам"
onChange={updateRole}
onChange={(checked) => updateProfile({ role: checked ? Role.Master : Role.Client })}
text="Быть мастером"
/>
</div>

View File

@ -1,9 +0,0 @@
/* 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,
});
}