Skip to content

Commit

Permalink
add code of honor alert
Browse files Browse the repository at this point in the history
  • Loading branch information
Markusplay committed Jan 28, 2025
1 parent f738b4d commit 87c27bc
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/components/code-of-honor-alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useTranslations } from 'next-intl';
import { useServerErrorToast } from '@/hooks/use-server-error-toast';
import React, { useState } from 'react';
import React from 'react';
import { useLocalStorage } from '@/hooks/use-storage';
import { User } from '@/types/user';
import { acceptCodeOfHonor } from '@/actions/profile.actions';
Expand All @@ -24,14 +24,10 @@ export default function CodeOfHonorAlert() {

const { errorToast } = useServerErrorToast();

const [loading, setLoading] = useState(false);

const [, setUser] = useLocalStorage<User>('user');

const handleAcceptCodeOfHonor = async () => {
setLoading(true);
const res = await acceptCodeOfHonor();
setLoading(false);

if (!res) {
errorToast();
Expand All @@ -56,9 +52,7 @@ export default function CodeOfHonorAlert() {
<Link href="/">
<AlertDialogCancel>На головну</AlertDialogCancel>
</Link>
<AlertDialogAction onClick={handleAcceptCodeOfHonor} disabled={loading}>
{t('button.agree')}
</AlertDialogAction>
<AlertDialogAction onClick={handleAcceptCodeOfHonor}>{t('button.agree')}</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
Expand Down

0 comments on commit 87c27bc

Please sign in to comment.