This commit is contained in:
smanylov
2025-12-27 11:54:54 +07:00
parent ab6e385984
commit aaa95091d2
10 changed files with 134 additions and 187 deletions
+1 -18
View File
@@ -1,7 +1,6 @@
"use client"
import { useState, useRef } from 'react';
import { fetchFruits } from '@/app/actions/action';
import { useClickOutside } from '@/app/hooks/useClickOutside';
import { useTranslations } from 'next-intl';
import Link from 'next/link';
@@ -10,7 +9,6 @@ import {IconNotification} from '@/app/ui/icons/icons';
export default function NotificationsButton() {
const [isOpen, setIsOpen] = useState(false);
const [data, setData] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const menuRef = useRef<HTMLDivElement | null>(null);
const t = useTranslations('Global');
@@ -19,24 +17,9 @@ export default function NotificationsButton() {
setIsOpen(false);
});
const fetchData = async () => {
setLoading(true);
setError(null);
try {
const result = await fetchFruits();
setData("result");
setIsOpen(true);
} catch (err) {
setError('error message');
} finally {
setLoading(false);
}
};
const handleButtonClick = () => {
if (!isOpen) {
fetchData();
setIsOpen(true);
} else {
setIsOpen(false);
}