mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 22:29:11 +03:00
* First round of wrapping RQ errors with handleError * Remove the throw before the handleError usage. * Make the handling of an API error more versatile. Add logging in Sentry if the error is of unknown type. * Remove throwing of the handleError function. * Add return type to the handleError function to be never so that we're sure it always throws. * Second round of wrapping RQ errors with handleError * Temp fix in delete credential mutation, and fix loading state --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import { get, handleError } from 'data/fetchers'
|
|
import type { AuditLog } from 'data/organizations/organization-audit-logs-query'
|
|
import type { ResponseError } from 'types'
|
|
import { profileKeys } from './keys'
|
|
|
|
export type ProfileAuditLogsVariables = {
|
|
iso_timestamp_start: string
|
|
iso_timestamp_end: string
|
|
}
|
|
|
|
export async function getProfileAuditLogs(
|
|
{ iso_timestamp_start, iso_timestamp_end }: ProfileAuditLogsVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
const { data, error } = await get('/platform/profile/audit', {
|
|
params: {
|
|
query: {
|
|
iso_timestamp_start,
|
|
iso_timestamp_end,
|
|
},
|
|
},
|
|
signal,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data as unknown as ProfileAuditLogsData
|
|
}
|
|
|
|
export type ProfileAuditLogsError = ResponseError
|
|
export type ProfileAuditLogsData = {
|
|
result: AuditLog[]
|
|
retention_period: number
|
|
}
|
|
|
|
export const useProfileAuditLogsQuery = <TData = ProfileAuditLogsData>(
|
|
vars: ProfileAuditLogsVariables,
|
|
options: UseQueryOptions<ProfileAuditLogsData, ProfileAuditLogsError, TData> = {}
|
|
) => {
|
|
const { iso_timestamp_start, iso_timestamp_end } = vars
|
|
return useQuery<ProfileAuditLogsData, ProfileAuditLogsError, TData>(
|
|
profileKeys.auditLogs({ date_start: iso_timestamp_start, date_end: iso_timestamp_end }),
|
|
({ signal }) => getProfileAuditLogs(vars, signal),
|
|
{
|
|
...options,
|
|
}
|
|
)
|
|
}
|