Disable the debug console logs for production
This commit is contained in:
@@ -22,12 +22,12 @@ export const ScheduleIncidentContent = () => {
|
||||
|
||||
// Initialize maintenance notifications when the component mounts
|
||||
useEffect(() => {
|
||||
console.log("Initializing maintenance notifications");
|
||||
// console.log("Initializing maintenance notifications");
|
||||
initMaintenanceNotifications();
|
||||
|
||||
// Clean up when the component unmounts
|
||||
return () => {
|
||||
console.log("Cleaning up maintenance notifications");
|
||||
// console.log("Cleaning up maintenance notifications");
|
||||
stopMaintenanceNotifications();
|
||||
};
|
||||
}, []);
|
||||
@@ -43,7 +43,7 @@ export const ScheduleIncidentContent = () => {
|
||||
const handleMaintenanceCreated = () => {
|
||||
// Refresh data by incrementing the refresh trigger
|
||||
const newTriggerValue = refreshTrigger + 1;
|
||||
console.log("Maintenance created, refreshing data with new trigger value:", newTriggerValue);
|
||||
// console.log("Maintenance created, refreshing data with new trigger value:", newTriggerValue);
|
||||
setRefreshTrigger(newTriggerValue);
|
||||
|
||||
// Show success toast
|
||||
@@ -56,7 +56,7 @@ export const ScheduleIncidentContent = () => {
|
||||
const handleIncidentCreated = () => {
|
||||
// Refresh data by incrementing the refresh trigger
|
||||
const newTriggerValue = incidentRefreshTrigger + 1;
|
||||
console.log("Incident created, refreshing data with new trigger value:", newTriggerValue);
|
||||
// console.log("Incident created, refreshing data with new trigger value:", newTriggerValue);
|
||||
setIncidentRefreshTrigger(newTriggerValue);
|
||||
|
||||
// Show success toast
|
||||
|
||||
@@ -22,13 +22,13 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) =>
|
||||
const fetchIncidentData = useCallback(async (force = false) => {
|
||||
// Skip if already fetching
|
||||
if (isFetchingRef.current) {
|
||||
console.log('Already fetching data, skipping additional request');
|
||||
// console.log('Already fetching data, skipping additional request');
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip if not forced and already initialized
|
||||
if (initialized && !force) {
|
||||
console.log('Data already initialized and no force refresh, skipping fetch');
|
||||
// console.log('Data already initialized and no force refresh, skipping fetch');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,22 +46,22 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) =>
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
console.log(`Fetching incident data (force=${force})`);
|
||||
// console.log(`Fetching incident data (force=${force})`);
|
||||
const allIncidents = await incidentService.getAllIncidents(force);
|
||||
|
||||
if (Array.isArray(allIncidents)) {
|
||||
setIncidents(allIncidents);
|
||||
console.log(`Successfully set ${allIncidents.length} incidents to state`);
|
||||
// console.log(`Successfully set ${allIncidents.length} incidents to state`);
|
||||
} else {
|
||||
setIncidents([]);
|
||||
console.warn('No incidents returned from service');
|
||||
// console.warn('No incidents returned from service');
|
||||
}
|
||||
|
||||
setInitialized(true);
|
||||
setLoading(false);
|
||||
setIsRefreshing(false);
|
||||
} catch (error) {
|
||||
console.error('Error fetching incident data:', error);
|
||||
// console.error('Error fetching incident data:', error);
|
||||
setError('Failed to load incident data. Please try again later.');
|
||||
setIncidents([]);
|
||||
setInitialized(true);
|
||||
@@ -79,7 +79,7 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) =>
|
||||
useEffect(() => {
|
||||
// Skip if the refresh trigger hasn't changed (prevents duplicate effect calls)
|
||||
if (refreshTrigger === lastRefreshTriggerRef.current && initialized) {
|
||||
console.log('Refresh trigger unchanged, skipping fetch');
|
||||
// console.log('Refresh trigger unchanged, skipping fetch');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) =>
|
||||
const abortController = new AbortController();
|
||||
let isMounted = true;
|
||||
|
||||
console.log(`useIncidentData effect running, refreshTrigger: ${refreshTrigger}`);
|
||||
// console.log(`useIncidentData effect running, refreshTrigger: ${refreshTrigger}`);
|
||||
|
||||
// Use a longer delay to ensure we don't trigger too many API calls
|
||||
const fetchTimer = setTimeout(() => {
|
||||
@@ -101,7 +101,7 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) =>
|
||||
|
||||
// Cleanup function to abort any in-flight requests and clear timers
|
||||
return () => {
|
||||
console.log('Cleaning up incident data fetch effect');
|
||||
// console.log('Cleaning up incident data fetch effect');
|
||||
isMounted = false;
|
||||
clearTimeout(fetchTimer);
|
||||
abortController.abort();
|
||||
@@ -112,7 +112,7 @@ export const useIncidentData = ({ refreshTrigger = 0 }: UseIncidentDataProps) =>
|
||||
const incidentData = useMemo(() => {
|
||||
if (!initialized || incidents.length === 0) return [];
|
||||
|
||||
console.log(`Filtering incidents by: ${filter}`);
|
||||
// console.log(`Filtering incidents by: ${filter}`);
|
||||
|
||||
if (filter === "unresolved") {
|
||||
return incidents.filter(item => {
|
||||
|
||||
+20
-20
@@ -27,7 +27,7 @@ export const MaintenanceNotificationSettingsField = () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const channels = await alertConfigService.getAlertConfigurations();
|
||||
console.log("Fetched notification channels for form:", channels);
|
||||
// console.log("Fetched notification channels for form:", channels);
|
||||
|
||||
// Only show enabled channels
|
||||
const enabledChannels = channels.filter(channel => channel.enabled);
|
||||
@@ -38,18 +38,18 @@ export const MaintenanceNotificationSettingsField = () => {
|
||||
const currentChannel = getValues('notification_channel_id');
|
||||
const shouldNotify = getValues('notify_subscribers');
|
||||
|
||||
console.log("Current notification values:", {
|
||||
currentChannel,
|
||||
shouldNotify,
|
||||
availableChannels: enabledChannels.length
|
||||
});
|
||||
// console.log("Current notification values:", {
|
||||
// currentChannel,
|
||||
// shouldNotify,
|
||||
// availableChannels: enabledChannels.length
|
||||
// });
|
||||
|
||||
if (shouldNotify && (!currentChannel || currentChannel === 'none') && enabledChannels.length > 0) {
|
||||
console.log("Setting default notification channel:", enabledChannels[0].id);
|
||||
// console.log("Setting default notification channel:", enabledChannels[0].id);
|
||||
setValue('notification_channel_id', enabledChannels[0].id);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching notification channels:', error);
|
||||
// console.error('Error fetching notification channels:', error);
|
||||
toast({
|
||||
title: t('error'),
|
||||
description: t('errorFetchingNotificationChannels'),
|
||||
@@ -64,12 +64,12 @@ export const MaintenanceNotificationSettingsField = () => {
|
||||
}, [t, toast, setValue, getValues]);
|
||||
|
||||
// Log value changes for debugging
|
||||
useEffect(() => {
|
||||
console.log("Current notification settings:", {
|
||||
channel_id: getValues('notification_channel_id'),
|
||||
notify: notifySubscribers
|
||||
});
|
||||
}, [notifySubscribers, notificationChannelId, getValues]);
|
||||
// useEffect(() => {
|
||||
// console.log("Current notification settings:", {
|
||||
// channel_id: getValues('notification_channel_id'),
|
||||
// notify: notifySubscribers
|
||||
// });
|
||||
// }, [notifySubscribers, notificationChannelId, getValues]);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -98,7 +98,7 @@ export const MaintenanceNotificationSettingsField = () => {
|
||||
checked={field.value}
|
||||
onCheckedChange={(checked) => {
|
||||
field.onChange(checked);
|
||||
console.log("Notification toggle changed to:", checked);
|
||||
// console.log("Notification toggle changed to:", checked);
|
||||
// If notifications are disabled, also clear the notification channel
|
||||
if (!checked) {
|
||||
setValue('notification_channel_id', '');
|
||||
@@ -120,10 +120,10 @@ export const MaintenanceNotificationSettingsField = () => {
|
||||
// Make sure to handle both empty string and "none" as special cases
|
||||
const displayValue = field.value || "";
|
||||
|
||||
console.log("Rendering notification channel field with value:", {
|
||||
fieldValue: field.value,
|
||||
displayValue
|
||||
});
|
||||
// console.log("Rendering notification channel field with value:", {
|
||||
// fieldValue: field.value,
|
||||
// displayValue
|
||||
// });
|
||||
|
||||
return (
|
||||
<FormItem>
|
||||
@@ -135,7 +135,7 @@ export const MaintenanceNotificationSettingsField = () => {
|
||||
<Select
|
||||
value={displayValue}
|
||||
onValueChange={(value) => {
|
||||
console.log("Setting notification channel to:", value);
|
||||
// console.log("Setting notification channel to:", value);
|
||||
field.onChange(value === "none" ? "" : value);
|
||||
}}
|
||||
disabled={!notifySubscribers}
|
||||
|
||||
+10
-10
@@ -31,17 +31,17 @@ export const AssignedUsersField = () => {
|
||||
// Ensure assigned_users is initialized as an array
|
||||
useEffect(() => {
|
||||
const currentValue = form.getValues('assigned_users');
|
||||
console.log("Initial assigned_users value:", currentValue);
|
||||
// console.log("Initial assigned_users value:", currentValue);
|
||||
|
||||
// Initialize as empty array if no value or invalid value
|
||||
if (!currentValue || !Array.isArray(currentValue)) {
|
||||
console.log("Initializing assigned_users as empty array");
|
||||
// console.log("Initializing assigned_users as empty array");
|
||||
form.setValue('assigned_users', [], { shouldValidate: false, shouldDirty: true });
|
||||
}
|
||||
}, [form]);
|
||||
|
||||
console.log("Current form values:", form.getValues());
|
||||
console.log("Current assigned_users:", form.getValues('assigned_users'));
|
||||
//console.log("Current form values:", form.getValues());
|
||||
//console.log("Current assigned_users:", form.getValues('assigned_users'));
|
||||
|
||||
// Fetch users for the assignment dropdown
|
||||
const { data: users = [], isLoading } = useQuery({
|
||||
@@ -49,10 +49,10 @@ export const AssignedUsersField = () => {
|
||||
queryFn: async () => {
|
||||
try {
|
||||
const usersList = await userService.getUsers();
|
||||
console.log("Fetched users for assignment:", usersList);
|
||||
// console.log("Fetched users for assignment:", usersList);
|
||||
return Array.isArray(usersList) ? usersList : [];
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch users:", error);
|
||||
// console.error("Failed to fetch users:", error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
@@ -64,7 +64,7 @@ export const AssignedUsersField = () => {
|
||||
? form.watch('assigned_users')
|
||||
: [];
|
||||
|
||||
console.log("Selected user IDs:", selectedUserIds);
|
||||
// console.log("Selected user IDs:", selectedUserIds);
|
||||
|
||||
// Function to add a user
|
||||
const addUser = (userId: string) => {
|
||||
@@ -73,7 +73,7 @@ export const AssignedUsersField = () => {
|
||||
: [];
|
||||
|
||||
if (!currentValues.includes(userId)) {
|
||||
console.log("Adding user:", userId);
|
||||
// console.log("Adding user:", userId);
|
||||
form.setValue('assigned_users', [...currentValues, userId], { shouldValidate: true, shouldDirty: true });
|
||||
}
|
||||
};
|
||||
@@ -84,7 +84,7 @@ export const AssignedUsersField = () => {
|
||||
? [...form.getValues('assigned_users')]
|
||||
: [];
|
||||
|
||||
console.log("Removing user:", userId);
|
||||
// console.log("Removing user:", userId);
|
||||
form.setValue(
|
||||
'assigned_users',
|
||||
currentValues.filter(id => id !== userId),
|
||||
@@ -94,7 +94,7 @@ export const AssignedUsersField = () => {
|
||||
|
||||
// Get selected users data
|
||||
const selectedUsers = users.filter(user => selectedUserIds.includes(user.id));
|
||||
console.log("Matched selected users:", selectedUsers);
|
||||
// console.log("Matched selected users:", selectedUsers);
|
||||
|
||||
// Function to get user initials from name
|
||||
const getUserInitials = (user: any): string => {
|
||||
|
||||
Reference in New Issue
Block a user