mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 22:59:11 +03:00
* Add NL input * Add chart to sidebar * Better loading animation * Redo api route to not use edge * Remove edge stuff * Allow sheet to close * Cleanup * Adjust loading state * Add timezone * CR comments * Replace query with useCompletion * Set the form value * Tiny clean up * Tinyyyyy tweaks * Fix missing syntax * Smol refactor * Fixy * Remove console log --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import { executeSql } from 'data/sql/execute-sql-query'
|
|
import { ResponseError } from 'types'
|
|
import { databaseCronJobsKeys } from './keys'
|
|
|
|
export type DatabaseCronJobsVariables = {
|
|
projectRef?: string
|
|
connectionString?: string
|
|
}
|
|
|
|
export async function getDatabaseCronTimezone({
|
|
projectRef,
|
|
connectionString,
|
|
}: DatabaseCronJobsVariables) {
|
|
if (!projectRef) throw new Error('Project ref is required')
|
|
|
|
const { result } = await executeSql({
|
|
projectRef,
|
|
connectionString,
|
|
sql: `select setting from pg_settings where name = 'cron.timezone';`,
|
|
})
|
|
return result[0].setting
|
|
}
|
|
|
|
export type DatabaseCronJobError = ResponseError
|
|
|
|
export const useCronTimezoneQuery = <TData = string>(
|
|
{ projectRef, connectionString }: DatabaseCronJobsVariables,
|
|
{ enabled = true, ...options }: UseQueryOptions<string, DatabaseCronJobError, TData> = {}
|
|
) =>
|
|
useQuery<string, DatabaseCronJobError, TData>(
|
|
databaseCronJobsKeys.timezone(projectRef),
|
|
() => getDatabaseCronTimezone({ projectRef, connectionString }),
|
|
{
|
|
enabled: enabled && typeof projectRef !== 'undefined',
|
|
...options,
|
|
}
|
|
)
|