| | import apiClient from './apiClient'; |
| |
|
| | class ScheduleService { |
| | |
| | |
| | |
| | |
| | async getAll() { |
| | try { |
| | const response = await apiClient.get('/schedules'); |
| | |
| | if (import.meta.env.VITE_NODE_ENV === 'development') { |
| | console.log('π
[Schedule] Retrieved schedules:', response.data); |
| | } |
| | |
| | return response; |
| | } catch (error) { |
| | if (import.meta.env.VITE_NODE_ENV === 'development') { |
| | console.error('π
[Schedule] Get schedules error:', error.response?.data || error.message); |
| | } |
| | throw error; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | async create(scheduleData) { |
| | try { |
| | |
| | const timezone = scheduleData.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone; |
| | |
| | console.log('[DEBUG] ScheduleService.create - timezone:', timezone); |
| | console.log('[DEBUG] ScheduleService.create - scheduleData:', scheduleData); |
| | |
| | const response = await apiClient.post('/schedules', { |
| | social_network: scheduleData.social_network, |
| | schedule_time: scheduleData.schedule_time, |
| | days: scheduleData.days, |
| | timezone: timezone |
| | }); |
| | |
| | if (import.meta.env.VITE_NODE_ENV === 'development') { |
| | console.log('π
[Schedule] Schedule created:', response.data); |
| | } |
| | |
| | return response; |
| | } catch (error) { |
| | if (import.meta.env.VITE_NODE_ENV === 'development') { |
| | console.error('π
[Schedule] Create schedule error:', error.response?.data || error.message); |
| | } |
| | throw error; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async delete(scheduleId) { |
| | try { |
| | const response = await apiClient.delete(`/schedules/${scheduleId}`); |
| | |
| | if (import.meta.env.VITE_NODE_ENV === 'development') { |
| | console.log('π
[Schedule] Schedule deleted:', response.data); |
| | } |
| | |
| | return response; |
| | } catch (error) { |
| | if (import.meta.env.VITE_NODE_ENV === 'development') { |
| | console.error('π
[Schedule] Delete schedule error:', error.response?.data || error.message); |
| | } |
| | throw error; |
| | } |
| | } |
| | } |
| |
|
| | export default new ScheduleService(); |