2
0

fix(bot): 🐛 File upload in linked typebot

This commit is contained in:
Baptiste Arnaud
2022-06-25 11:38:25 +02:00
parent 8c936741f3
commit b9032b422c

View File

@@ -20,10 +20,7 @@ export const FileUploadForm = ({
onSubmit, onSubmit,
onSkip, onSkip,
}: Props) => { }: Props) => {
const { const { isPreview, currentTypebotId } = useTypebot()
isPreview,
typebot: { typebotId },
} = useTypebot()
const { resultId } = useAnswers() const { resultId } = useAnswers()
const [selectedFiles, setSelectedFiles] = useState<File[]>([]) const [selectedFiles, setSelectedFiles] = useState<File[]>([])
const [isUploading, setIsUploading] = useState(false) const [isUploading, setIsUploading] = useState(false)
@@ -59,7 +56,7 @@ export const FileUploadForm = ({
}) })
setIsUploading(true) setIsUploading(true)
const urls = await uploadFiles({ const urls = await uploadFiles({
basePath: `/api/typebots/${typebotId}/blocks/${id}`, basePath: `/api/typebots/${currentTypebotId}/blocks/${id}`,
files: [ files: [
{ {
file, file,
@@ -81,7 +78,7 @@ export const FileUploadForm = ({
}) })
setIsUploading(true) setIsUploading(true)
const urls = await uploadFiles({ const urls = await uploadFiles({
basePath: `/api/typebots/${typebotId}/blocks/${id}`, basePath: `/api/typebots/${currentTypebotId}/blocks/${id}`,
files: files.map((file) => ({ files: files.map((file) => ({
file: file, file: file,
path: `public/results/${resultId}/${id}/${file.name}`, path: `public/results/${resultId}/${id}/${file.name}`,