more button remove + remove all logs

This commit is contained in:
hamid zarghami
2025-07-30 09:47:21 +03:30
parent ef26c63e33
commit e35634a0c2
17 changed files with 71 additions and 51 deletions
+2 -4
View File
@@ -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"
+49 -3
View File
@@ -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':
+1 -2
View File
@@ -35,8 +35,7 @@ const NajvaToken: FC = () => {
} else {
return false
}
} catch (error) {
console.log(error);
} catch {
return false
}
}
+1 -1
View File
@@ -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>
+1 -2
View File
@@ -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}
-1
View File
@@ -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)
}