Skip to content

Commit

Permalink
fix(studio): content picker broken (#283)
Browse files Browse the repository at this point in the history
* fix(studio): content picker broken

* add missing types + formatting

Co-authored-by: Laurent Leclerc-Poulin <laurentleclercpoulin@gmail.com>
  • Loading branch information
allardy and laurentlp committed Feb 8, 2022
1 parent 4ded334 commit 3a39ebf
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import { nanoid } from 'nanoid'
import React, { Component } from 'react'
import Select from './index'
import nanoId from 'nanoid'

class SelectContentManager extends Component {
state = {
interface State {
selects: {
id: string
callback: () => void
contentType: string
rootEl: any
}[]
}

class SelectContentManager extends Component<{}, State> {
state: State = {
selects: []
}

constructor(props) {
constructor(props: {}) {
super(props)

window.botpress = window.botpress || {}
window.botpress.pickContent = ({ contentType = null } = {}, callback) => {
const id = nanoId()
window.botpress.pickContent = ({ contentType = null } = {}, callback: () => void) => {
const id = nanoid()
const rootEl = document.createElement('DIV')
rootEl.setAttribute('data-select-content-container', id)
document.getElementById('app').appendChild(rootEl)
Expand All @@ -26,7 +35,7 @@ class SelectContentManager extends Component {
delete window.botpress.pickContent
}

onClose = i => () => {
onClose = (i: number) => () => {
const { rootEl } = this.state.selects[i]
this.setState(
({ selects }) => ({
Expand Down

0 comments on commit 3a39ebf

Please sign in to comment.