more button remove + remove all logs
This commit is contained in:
@@ -19,8 +19,8 @@ export const EmailNotifications: React.FC<EmailNotificationsProps> = ({
|
||||
|
||||
const { socket, isConnected } = useEmailWebSocket({
|
||||
token: userToken,
|
||||
onConnect: () => console.log('نوتیفیکیشنهای ایمیل متصل شد'),
|
||||
onError: (error) => console.error('خطای WebSocket:', error),
|
||||
onConnect: () => null,
|
||||
onError: () => null,
|
||||
});
|
||||
|
||||
// Sound settings state
|
||||
@@ -47,7 +47,6 @@ export const EmailNotifications: React.FC<EmailNotificationsProps> = ({
|
||||
});
|
||||
|
||||
const handleNewEmail = useCallback((email: EmailPayload) => {
|
||||
console.log('📧 ایمیل جدید دریافت شد:', email);
|
||||
|
||||
// Add to notifications list
|
||||
setNotifications(prev => [email, ...prev.slice(0, 9)]); // Keep only 10 latest
|
||||
@@ -97,7 +96,6 @@ export const EmailNotifications: React.FC<EmailNotificationsProps> = ({
|
||||
{/* Test Sound Button */}
|
||||
<button
|
||||
onClick={() => {
|
||||
console.log("کلیک روی دکمه تست صدا");
|
||||
playSound();
|
||||
}}
|
||||
className="p-2 rounded-full hover:bg-gray-100 transition-colors"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FC, useEffect, useState, ChangeEvent } from 'react';
|
||||
import { FC, useEffect, useState, ChangeEvent, useRef } from 'react';
|
||||
import { Filter } from 'iconsax-react';
|
||||
import DatePicker from './DatePicker';
|
||||
import Input from './Input';
|
||||
@@ -54,27 +54,72 @@ const Filters: FC<FiltersProps> = ({
|
||||
}) => {
|
||||
const [filters, setFilters] = useState<FilterValues>({});
|
||||
const [isFiltersOpen, setIsFiltersOpen] = useState(false);
|
||||
const [inputValues, setInputValues] = useState<Record<string, string>>({});
|
||||
const onChangeRef = useRef(onChange);
|
||||
|
||||
// آپدیت کردن ref وقتی onChange تغییر میکند
|
||||
useEffect(() => {
|
||||
onChangeRef.current = onChange;
|
||||
}, [onChange]);
|
||||
|
||||
// تنظیم مقادیر اولیه
|
||||
useEffect(() => {
|
||||
if (Object.keys(initialValues).length > 0) {
|
||||
setFilters(initialValues);
|
||||
// تنظیم مقادیر input برای فیلدهای نوع input
|
||||
const inputFields: Record<string, string> = {};
|
||||
fields.forEach(field => {
|
||||
if (field.type === 'input' && initialValues[field.name]) {
|
||||
inputFields[field.name] = initialValues[field.name] as string;
|
||||
}
|
||||
});
|
||||
setInputValues(inputFields);
|
||||
} else {
|
||||
// تنظیم مقادیر پیشفرض از فیلدها
|
||||
const defaultValues: FilterValues = {};
|
||||
const defaultInputs: Record<string, string> = {};
|
||||
fields.forEach(field => {
|
||||
if ('defaultValue' in field && field.defaultValue !== undefined) {
|
||||
defaultValues[field.name] = field.defaultValue;
|
||||
if (field.type === 'input') {
|
||||
defaultInputs[field.name] = field.defaultValue;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Object.keys(defaultValues).length > 0) {
|
||||
setFilters(defaultValues);
|
||||
setInputValues(defaultInputs);
|
||||
onChange(defaultValues);
|
||||
}
|
||||
}
|
||||
}, [fields, initialValues, onChange]);
|
||||
|
||||
// Debounce برای فیلدهای input
|
||||
useEffect(() => {
|
||||
const timeouts: Record<string, number> = {};
|
||||
|
||||
Object.keys(inputValues).forEach(fieldName => {
|
||||
timeouts[fieldName] = setTimeout(() => {
|
||||
setFilters(currentFilters => {
|
||||
const currentFilter = currentFilters[fieldName];
|
||||
const newValue = inputValues[fieldName];
|
||||
|
||||
if (currentFilter !== newValue) {
|
||||
const newFilters = { ...currentFilters, [fieldName]: newValue || null };
|
||||
onChangeRef.current(newFilters);
|
||||
return newFilters;
|
||||
}
|
||||
return currentFilters;
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
return () => {
|
||||
Object.values(timeouts).forEach(timeout => clearTimeout(timeout));
|
||||
};
|
||||
}, [inputValues]);
|
||||
|
||||
const handleChange = (name: string, value: string | null) => {
|
||||
const newFilters = { ...filters, [name]: value };
|
||||
setFilters(newFilters);
|
||||
@@ -82,11 +127,12 @@ const Filters: FC<FiltersProps> = ({
|
||||
};
|
||||
|
||||
const handleInputChange = (name: string, event: ChangeEvent<HTMLInputElement>) => {
|
||||
handleChange(name, event.target.value);
|
||||
const value = event.target.value;
|
||||
setInputValues(prev => ({ ...prev, [name]: value }));
|
||||
};
|
||||
|
||||
const renderField = (field: FieldType) => {
|
||||
const currentValue = filters[field.name];
|
||||
const currentValue = field.type === 'input' ? inputValues[field.name] : filters[field.name];
|
||||
|
||||
switch (field.type) {
|
||||
case 'date':
|
||||
|
||||
@@ -35,8 +35,7 @@ const NajvaToken: FC = () => {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ const RowActionsDropdown: React.FC<RowActionsDropdownProps> = ({ actions, classN
|
||||
<button
|
||||
ref={buttonRef}
|
||||
onClick={handleToggle}
|
||||
className="p-1 hover:bg-gray-100 rounded-full transition-colors"
|
||||
className="mt-2 hover:bg-gray-100 rounded-full transition-colors"
|
||||
>
|
||||
<More size={14} color="black" className="rotate-90" />
|
||||
</button>
|
||||
|
||||
@@ -370,7 +370,7 @@ const Table = <T extends RowDataType>({
|
||||
|
||||
return (
|
||||
<div className="h-[64px] rounded-t-2xl md:rounded-t-3xl md:h-[74px] bg-white flex items-center px-3 md:px-6">
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
{actions}
|
||||
{selectable && selectedRows.length > 0 && selectedActions && selectedActions}
|
||||
</div>
|
||||
@@ -471,7 +471,6 @@ const Table = <T extends RowDataType>({
|
||||
</div>
|
||||
|
||||
{pagination && (() => {
|
||||
console.log('Table component rendering pagination:', pagination);
|
||||
return (
|
||||
<Pagination
|
||||
hasNext={pagination.hasNext}
|
||||
|
||||
@@ -57,7 +57,6 @@ const UploadBoxDraggble: FC<Props> = (props: Props) => {
|
||||
|
||||
if (props.preview && props.preview.length > 0 && !isFill) {
|
||||
setPerviews(props.preview)
|
||||
console.log('preview', props.preview);
|
||||
|
||||
setIsFill(true)
|
||||
}
|
||||
|
||||
@@ -28,23 +28,18 @@ export const useEmailWebSocket = ({
|
||||
|
||||
// Connection events
|
||||
newSocket.on("connect", () => {
|
||||
console.log("✅ اتصال به WebSocket ایمیل برقرار شد");
|
||||
setIsConnected(true);
|
||||
onConnect?.();
|
||||
});
|
||||
|
||||
newSocket.on("disconnect", () => {
|
||||
console.log("❌ اتصال به WebSocket ایمیل قطع شد");
|
||||
setIsConnected(false);
|
||||
onDisconnect?.();
|
||||
});
|
||||
|
||||
newSocket.on("connection_established", (data) => {
|
||||
console.log("🎉 اتصال We bSocket ایمیل تأیید شد:", data);
|
||||
});
|
||||
newSocket.on("connection_established", () => {});
|
||||
|
||||
newSocket.on("connection_error", (error) => {
|
||||
console.error("💥 خطای اتصال WebSocket ایمیل:", error);
|
||||
onError?.(error.error);
|
||||
});
|
||||
|
||||
|
||||
@@ -15,13 +15,11 @@ export const useNotificationSound = ({
|
||||
|
||||
const playSound = useCallback(async () => {
|
||||
if (!enabled || isPlaying) {
|
||||
console.log("صدا غیرفعال است یا در حال پخش");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setIsPlaying(true);
|
||||
console.log("شروع پخش صدا...", { soundUrl, volume, enabled });
|
||||
|
||||
const audio = new Audio();
|
||||
audio.preload = "auto";
|
||||
@@ -30,32 +28,26 @@ export const useNotificationSound = ({
|
||||
|
||||
// Add event listeners
|
||||
audio.addEventListener("ended", () => {
|
||||
console.log("پخش صدا تمام شد");
|
||||
setIsPlaying(false);
|
||||
});
|
||||
|
||||
audio.addEventListener("error", (e) => {
|
||||
console.error("خطا در پخش صدا:", e);
|
||||
audio.addEventListener("error", () => {
|
||||
setIsPlaying(false);
|
||||
});
|
||||
|
||||
// Wait for audio to be ready
|
||||
if (audio.readyState >= 2) {
|
||||
await audio.play();
|
||||
console.log("🔊 صدای نوتیفیکیشن پخش شد");
|
||||
} else {
|
||||
audio.addEventListener("canplay", async () => {
|
||||
try {
|
||||
await audio.play();
|
||||
console.log("🔊 صدای نوتیفیکیشن پخش شد");
|
||||
} catch (playError) {
|
||||
console.error("خطا در پخش بعد از آماده شدن:", playError);
|
||||
} catch {
|
||||
setIsPlaying(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("خطا در ایجاد audio element:", error);
|
||||
} catch {
|
||||
setIsPlaying(false);
|
||||
}
|
||||
}, [enabled, isPlaying, soundUrl, volume]);
|
||||
|
||||
@@ -131,7 +131,7 @@ const List: FC = () => {
|
||||
};
|
||||
|
||||
const tableActions = (
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={selectAll}
|
||||
|
||||
@@ -2,7 +2,7 @@ import Filters, { FilterValues } from '../../components/Filters';
|
||||
import { FC, useState } from 'react'
|
||||
import Table from '../../components/Table';
|
||||
import { ColumnType } from '../../components/types/TableTypes';
|
||||
import { InfoCircle, More, Refresh2, Trash, ArchiveSlash } from 'iconsax-react';
|
||||
import { InfoCircle, Refresh2, Trash, ArchiveSlash } from 'iconsax-react';
|
||||
import { RowActionItem } from '../../components/RowActionsDropdown';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useGetArchiveMessages } from './hooks/useArchiveData';
|
||||
@@ -127,7 +127,7 @@ const List: FC = () => {
|
||||
};
|
||||
|
||||
const tableActions = (
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={selectAll}
|
||||
@@ -141,7 +141,6 @@ const List: FC = () => {
|
||||
className={`cursor-pointer ${isFetching ? 'animate-spin-reverse' : ''}`}
|
||||
onClick={() => refetch()}
|
||||
/>
|
||||
<More size={18} color='black' className='rotate-90 cursor-pointer' />
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { FC, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Table from '../../components/Table';
|
||||
import { ColumnType } from '../../components/types/TableTypes';
|
||||
import { InfoCircle, More, Refresh2, Trash, Edit, Send } from 'iconsax-react';
|
||||
import { InfoCircle, Refresh2, Trash, Edit, Send } from 'iconsax-react';
|
||||
import { RowActionItem } from '../../components/RowActionsDropdown';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useGetDrafts } from './hooks/useDraftData';
|
||||
@@ -145,7 +145,7 @@ const List: FC = () => {
|
||||
};
|
||||
|
||||
const tableActions = (
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={selectAll}
|
||||
@@ -159,7 +159,6 @@ const List: FC = () => {
|
||||
className={`cursor-pointer ${isFetching ? 'animate-spin-reverse' : ''}`}
|
||||
onClick={() => refetch()}
|
||||
/>
|
||||
<More size={18} color='black' className='rotate-90 cursor-pointer' />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -218,8 +217,6 @@ const List: FC = () => {
|
||||
const handleEditSelected = () => {
|
||||
if (selectedMessages.length === 1) {
|
||||
navigate(`/draft/edit/${selectedMessages[0].id}`);
|
||||
} else {
|
||||
console.log('ویرایش چندین پیشنویس انتخاب شده:', selectedMessages.map(m => m.id));
|
||||
}
|
||||
setSelectedMessages([]);
|
||||
setSelectAll(false);
|
||||
|
||||
@@ -2,7 +2,7 @@ import Filters, { FilterValues } from '../../components/Filters';
|
||||
import { FC, useState } from 'react'
|
||||
import Table from '../../components/Table';
|
||||
import { ColumnType } from '../../components/types/TableTypes';
|
||||
import { InfoCircle, More, Refresh2, Trash, Archive, Star1 } from 'iconsax-react';
|
||||
import { InfoCircle, Refresh2, Trash, Archive, Star1 } from 'iconsax-react';
|
||||
import { RowActionItem } from '../../components/RowActionsDropdown';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useGetFavoriteMessages } from './hooks/useFavoriteData';
|
||||
@@ -128,7 +128,7 @@ const List: FC = () => {
|
||||
};
|
||||
|
||||
const tableActions = (
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={selectAll}
|
||||
@@ -142,7 +142,6 @@ const List: FC = () => {
|
||||
className={`cursor-pointer ${isFetching ? 'animate-spin-reverse' : ''}`}
|
||||
onClick={() => refetch()}
|
||||
/>
|
||||
<More size={18} color='black' className='rotate-90 cursor-pointer' />
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ const DetailEmail: FC = () => {
|
||||
// Mark message as seen when it's loaded and not already seen
|
||||
useEffect(() => {
|
||||
if (messageDetail && !messageDetail.seen && id) {
|
||||
console.log('Marking message as seen:', id, 'Current seen status:', messageDetail.seen)
|
||||
emailActions.markAsSeen({ messageId: Number(id), mailbox: mailbox || '' })
|
||||
}
|
||||
}, [messageDetail, emailActions, id])
|
||||
|
||||
@@ -149,7 +149,7 @@ const List: FC = () => {
|
||||
};
|
||||
|
||||
const tableActions = (
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={selectAll}
|
||||
|
||||
@@ -137,7 +137,7 @@ const List: FC = () => {
|
||||
};
|
||||
|
||||
const tableActions = (
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={selectAll}
|
||||
|
||||
@@ -2,7 +2,7 @@ import Filters, { FilterValues } from '../../components/Filters';
|
||||
import { FC, useState } from 'react'
|
||||
import Table from '../../components/Table';
|
||||
import { ColumnType } from '../../components/types/TableTypes';
|
||||
import { InfoCircle, More, Refresh2, AttachSquare, Trash, Archive, Star } from 'iconsax-react';
|
||||
import { InfoCircle, Refresh2, AttachSquare, Trash, Archive, Star } from 'iconsax-react';
|
||||
import { useGetSentMessages } from './hooks/useSentData';
|
||||
import { InboxMessage } from './types/SentTypes';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
@@ -142,7 +142,7 @@ const List: FC = () => {
|
||||
};
|
||||
|
||||
const tableActions = (
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={selectAll}
|
||||
@@ -156,7 +156,6 @@ const List: FC = () => {
|
||||
className={`cursor-pointer ${isFetching ? 'animate-spin-reverse' : ''}`}
|
||||
onClick={() => refetch()}
|
||||
/>
|
||||
<More size={18} color='black' className='rotate-90 cursor-pointer' />
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ const List: FC = () => {
|
||||
};
|
||||
|
||||
const tableActions = (
|
||||
<div className='flex items-center gap-2 md:gap-4'>
|
||||
<div className='flex items-center gap-4 md:gap-4'>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={selectAll}
|
||||
@@ -179,7 +179,6 @@ const List: FC = () => {
|
||||
|
||||
const handleNotSpamSelected = () => {
|
||||
// TODO: پیادهسازی علامتگذاری به عنوان غیر اسپم - نیاز به API endpoint جداگانه
|
||||
console.log('علامتگذاری به عنوان غیر اسپم:', selectedMessages.map(m => m.id));
|
||||
setSelectedMessages([]);
|
||||
setSelectAll(false);
|
||||
};
|
||||
@@ -200,7 +199,7 @@ const List: FC = () => {
|
||||
{
|
||||
label: 'غیر اسپم',
|
||||
icon: <RecoveryConvert size={16} color="black" />,
|
||||
onClick: () => console.log('علامتگذاری به عنوان غیر اسپم', message.id),
|
||||
onClick: () => null,
|
||||
},
|
||||
{
|
||||
label: 'حذف',
|
||||
|
||||
Reference in New Issue
Block a user