import React from "react" import { Icons, createIconRender } from "components/Icons" import { Button, Empty, Input, Select } from "antd" import userLinksDecorators from "schemas/userLinksDecorators" import "./index.less" export default class ProfileEditor extends React.Component { state = { fields: this.props.ctx.currentValue ?? [] } onDebounceSave = (value) => { this.setState({ fields: value }) } add = () => { this.setState({ fields: [ ...this.state.fields, { key: undefined, value: undefined } ] }, () => { this.props.ctx.onUpdateItem(this.state.fields) }) } remove = (index) => { let fields = this.state.fields fields.splice(index, 1) this.setState({ fields }, () => { this.props.ctx.onUpdateItem(this.state.fields) }) } handleFieldChange = (index, key, value) => { let fields = this.state.fields fields[index][key] = value this.setState({ fields }, () => { this.props.ctx.onUpdateItem(this.state.fields) }) } render() { return
{ this.state.fields.length === 0 && } { this.state.fields.length > 0 && this.state.fields.map((field, index) => { return

Key

Value

this.handleFieldChange(index, "value", e.target.value)} placeholder="Link or Value e.g. https://twitter.com/username" />
}) }
} }