2
0

feat(editor): Team workspaces

This commit is contained in:
Baptiste Arnaud
2022-05-13 15:22:44 -07:00
parent 6c2986590b
commit f0fdf08b00
132 changed files with 3354 additions and 1228 deletions

View File

@ -12,10 +12,10 @@ import {
} from '@chakra-ui/react'
import { ChevronLeftIcon, PlusIcon, TrashIcon } from 'assets/icons'
import React, { useEffect, useMemo, useState } from 'react'
import { useUser } from 'contexts/UserContext'
import { useRouter } from 'next/router'
import { CredentialsType } from 'models'
import { deleteCredentials, useCredentials } from 'services/user'
import { useWorkspace } from 'contexts/WorkspaceContext'
type Props = Omit<MenuButtonProps, 'type'> & {
type: CredentialsType
@ -36,13 +36,13 @@ export const CredentialsDropdown = ({
...props
}: Props) => {
const router = useRouter()
const { user } = useUser()
const { workspace } = useWorkspace()
const toast = useToast({
position: 'top-right',
status: 'error',
})
const { credentials, mutate } = useCredentials({
userId: user?.id,
workspaceId: workspace?.id,
})
const [isDeleting, setIsDeleting] = useState<string>()
@ -84,9 +84,9 @@ export const CredentialsDropdown = ({
const handleDeleteDomainClick =
(credentialsId: string) => async (e: React.MouseEvent) => {
e.stopPropagation()
if (!user?.id) return
if (!workspace?.id) return
setIsDeleting(credentialsId)
const { error } = await deleteCredentials(user?.id, credentialsId)
const { error } = await deleteCredentials(workspace.id, credentialsId)
setIsDeleting(undefined)
if (error) return toast({ title: error.name, description: error.message })
onCredentialsSelect(undefined)