From c97b6b5dbb44f5f6321af999a83bd0fb089f76fe Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 25 Apr 2019 14:07:44 +0200 Subject: [PATCH] fix category array handling --- client/src/routes/Details/AssetDetails.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/client/src/routes/Details/AssetDetails.tsx b/client/src/routes/Details/AssetDetails.tsx index 16d51f7..16ced8d 100644 --- a/client/src/routes/Details/AssetDetails.tsx +++ b/client/src/routes/Details/AssetDetails.tsx @@ -24,7 +24,7 @@ interface AssetDetailsState { dateCreated?: string description?: string copyrightHolder?: string - categories?: string + categories?: string[] } export default class AssetDetails extends PureComponent< @@ -49,6 +49,14 @@ export default class AssetDetails extends PureComponent< }) } + private inputToArrayChange = ( + event: ChangeEvent | ChangeEvent + ) => { + this.setState({ + [event.currentTarget.name]: [event.currentTarget.value] + }) + } + private toggleEditMode = () => { this.setState({ isEditMode: !this.state.isEditMode }) } @@ -166,15 +174,15 @@ export default class AssetDetails extends PureComponent< placeholder={steps[1].fields.categories.placeholder} required={steps[1].fields.categories.required} type={steps[1].fields.categories.type} - onChange={this.inputChange} + onChange={this.inputToArrayChange} options={steps[1].fields.categories.options} - value={value} + value={value[0]} disabled={this.state.isLoading} small /> ) : ( // TODO: Make this link to search for respective category - {value} + {value[0]} ) private Description = ({ value }: { value: string }) =>