2
0

♻️ (builder) Change to features-centric folder structure

This commit is contained in:
Baptiste Arnaud
2022-11-15 09:35:48 +01:00
committed by Baptiste Arnaud
parent 3686465a85
commit 643571fe7d
683 changed files with 3907 additions and 3643 deletions

View File

@ -0,0 +1,22 @@
import { fetcher } from '@/utils/helpers'
import useSWR from 'swr'
import { Collaborator } from '../types'
export const useCollaborators = ({
typebotId,
onError,
}: {
typebotId?: string
onError: (error: Error) => void
}) => {
const { data, error, mutate } = useSWR<
{ collaborators: Collaborator[] },
Error
>(typebotId ? `/api/typebots/${typebotId}/collaborators` : null, fetcher)
if (error) onError(error)
return {
collaborators: data?.collaborators,
isLoading: !error && !data,
mutate,
}
}

View File

@ -0,0 +1,26 @@
import { fetcher } from '@/utils/helpers'
import { Invitation } from 'db'
import useSWR from 'swr'
import { env } from 'utils'
export const useInvitations = ({
typebotId,
onError,
}: {
typebotId?: string
onError: (error: Error) => void
}) => {
const { data, error, mutate } = useSWR<{ invitations: Invitation[] }, Error>(
typebotId ? `/api/typebots/${typebotId}/invitations` : null,
fetcher,
{
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
}
)
if (error) onError(error)
return {
invitations: data?.invitations,
isLoading: !error && !data,
mutate,
}
}