MCPcopy Index your code
hub / github.com/simstudioai/sim / useScheduleInfo

Function useScheduleInfo

apps/sim/hooks/queries/schedules.ts:138–177  ·  view source on GitHub ↗
(
  workflowId: string | undefined,
  blockId: string | undefined,
  blockType: string,
  options?: { timezone?: string }
)

Source from the content-addressed store, hash-verified

136 * Hook to get processed schedule info with human-readable timing
137 */
138export function useScheduleInfo(
139 workflowId: string | undefined,
140 blockId: string | undefined,
141 blockType: string,
142 options?: { timezone?: string }
143): {
144 scheduleInfo: ScheduleInfo | null
145 isLoading: boolean
146 refetch: () => void
147} {
148 const isScheduleBlock = blockType === 'schedule'
149
150 const { data, isLoading, refetch } = useScheduleQuery(workflowId, blockId, {
151 enabled: isScheduleBlock,
152 })
153
154 if (!data) {
155 return { scheduleInfo: null, isLoading, refetch }
156 }
157
158 const timezone = options?.timezone || data.timezone || 'UTC'
159 const scheduleTiming = data.cronExpression
160 ? parseCronToHumanReadable(data.cronExpression, timezone)
161 : 'Unknown schedule'
162
163 return {
164 scheduleInfo: {
165 id: data.id,
166 status: data.status,
167 scheduleTiming,
168 nextRunAt: data.nextRunAt,
169 lastRanAt: data.lastRanAt,
170 timezone,
171 isDisabled: data.status === 'disabled',
172 failedCount: data.failedCount || 0,
173 },
174 isLoading,
175 refetch,
176 }
177}
178
179/**
180 * Mutation to reactivate a disabled schedule

Callers 1

workflow-block.tsxFile · 0.90

Calls 2

parseCronToHumanReadableFunction · 0.90
useScheduleQueryFunction · 0.85

Tested by

no test coverage detected