✨ Allow user to share a flow publicly and make it duplicatable
Closes #360
This commit is contained in:
@@ -10,7 +10,7 @@ export const deleteResults = authenticatedProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'DELETE',
|
||||
path: '/typebots/{typebotId}/results',
|
||||
path: '/v1/typebots/{typebotId}/results',
|
||||
protect: true,
|
||||
summary: 'Delete results',
|
||||
tags: ['Results'],
|
||||
|
||||
@@ -9,7 +9,7 @@ export const getResult = authenticatedProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'GET',
|
||||
path: '/typebots/{typebotId}/results/{resultId}',
|
||||
path: '/v1/typebots/{typebotId}/results/{resultId}',
|
||||
protect: true,
|
||||
summary: 'Get result by id',
|
||||
tags: ['Results'],
|
||||
|
||||
@@ -8,7 +8,7 @@ export const getResultLogs = authenticatedProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'GET',
|
||||
path: '/typebots/{typebotId}/results/{resultId}/logs',
|
||||
path: '/v1/typebots/{typebotId}/results/{resultId}/logs',
|
||||
protect: true,
|
||||
summary: 'List result logs',
|
||||
tags: ['Results'],
|
||||
|
||||
@@ -11,7 +11,7 @@ export const getResults = authenticatedProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'GET',
|
||||
path: '/typebots/{typebotId}/results',
|
||||
path: '/v1/typebots/{typebotId}/results',
|
||||
protect: true,
|
||||
summary: 'List results ordered by descending creation date',
|
||||
tags: ['Results'],
|
||||
|
||||
@@ -18,15 +18,20 @@ import { useMemo } from 'react'
|
||||
import { useStats } from '../hooks/useStats'
|
||||
import { ResultsProvider } from '../ResultsProvider'
|
||||
import { ResultsTableContainer } from './ResultsTableContainer'
|
||||
import { TypebotNotFoundPage } from '@/features/editor/components/TypebotNotFoundPage'
|
||||
|
||||
export const ResultsPage = () => {
|
||||
const router = useRouter()
|
||||
const { workspace } = useWorkspace()
|
||||
const { typebot, publishedTypebot } = useTypebot()
|
||||
const { typebot, publishedTypebot, is404 } = useTypebot()
|
||||
const isAnalytics = useMemo(
|
||||
() => router.pathname.endsWith('analytics'),
|
||||
[router.pathname]
|
||||
)
|
||||
const bgColor = useColorModeValue(
|
||||
router.pathname.endsWith('analytics') ? '#f4f5f8' : 'white',
|
||||
router.pathname.endsWith('analytics') ? 'gray.850' : 'gray.900'
|
||||
)
|
||||
const { showToast } = useToast()
|
||||
|
||||
const { stats, mutate } = useStats({
|
||||
@@ -41,6 +46,7 @@ export const ResultsPage = () => {
|
||||
})
|
||||
}
|
||||
|
||||
if (is404) return <TypebotNotFoundPage />
|
||||
return (
|
||||
<Flex overflow="hidden" h="100vh" flexDir="column">
|
||||
<Seo
|
||||
@@ -55,14 +61,7 @@ export const ResultsPage = () => {
|
||||
}
|
||||
/>
|
||||
<TypebotHeader />
|
||||
<Flex
|
||||
h="full"
|
||||
w="full"
|
||||
bgColor={useColorModeValue(
|
||||
router.pathname.endsWith('analytics') ? '#f4f5f8' : 'white',
|
||||
router.pathname.endsWith('analytics') ? 'gray.850' : 'gray.900'
|
||||
)}
|
||||
>
|
||||
<Flex h="full" w="full" bgColor={bgColor}>
|
||||
<Flex
|
||||
pos="absolute"
|
||||
zIndex={2}
|
||||
|
||||
@@ -48,7 +48,7 @@ export const ResultsTable = ({
|
||||
onResultExpandIndex,
|
||||
}: ResultsTableProps) => {
|
||||
const background = useColorModeValue('white', colors.gray[900])
|
||||
const { updateTypebot, isReadOnly } = useTypebot()
|
||||
const { updateTypebot, currentUserMode } = useTypebot()
|
||||
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({})
|
||||
const [isTableScrolled, setIsTableScrolled] = useState(false)
|
||||
const bottomElement = useRef<HTMLDivElement | null>(null)
|
||||
@@ -212,7 +212,7 @@ export const ResultsTable = ({
|
||||
return (
|
||||
<Stack maxW="1600px" px="4" overflowY="hidden" spacing={6}>
|
||||
<HStack w="full" justifyContent="flex-end">
|
||||
{isReadOnly ? null : (
|
||||
{currentUserMode === 'write' && (
|
||||
<SelectionToolbar
|
||||
selectedResultsId={Object.keys(rowSelection)}
|
||||
onClearSelection={() => setRowSelection({})}
|
||||
|
||||
Reference in New Issue
Block a user