From 2d66888ed35d2ebadc71b378e72cc6f087d71501 Mon Sep 17 00:00:00 2001 From: Teddy Cornaut Date: Mon, 31 Aug 2020 12:55:33 +0200 Subject: [PATCH] Modification des options OK --- .../DecisionSupportFilePage/OptionsSection.tsx | 10 ++++++---- client/src/gql/queries/dsf.tsx | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/client/src/components/DecisionSupportFilePage/OptionsSection.tsx b/client/src/components/DecisionSupportFilePage/OptionsSection.tsx index 80bd5ed..766eb0f 100644 --- a/client/src/components/DecisionSupportFilePage/OptionsSection.tsx +++ b/client/src/components/DecisionSupportFilePage/OptionsSection.tsx @@ -51,16 +51,18 @@ export const OptionsSection: FunctionComponent = ({ dsf, up } const onAddOptionClick = (evt: MouseEvent) => { - const option = newOption("Décision", "", ""); - setState(state => ({ ...state, changed: true, section: { ...state.section, options: [ ...state.section.options, option ] }})); + var options = JSON.parse(JSON.stringify(state.section.options)) + var option = newOption("Décision", "", ""); + options.push(option); + setState(state => ({ ...state, changed: true, section: { ...state.section, options }})); }; const onOptionChange = (id: string, attrName: string, evt: ChangeEvent) => { const target = evt.currentTarget; const value = target.hasOwnProperty('checked') ? target.checked : target.value; - var options = state.section.options; + var options = JSON.parse(JSON.stringify(state.section.options)) options[id][attrName] = value; - setState(state => ({ ...state, changed: true, section: { ...state.section, options: options }})); + setState(state => ({ ...state, changed: true, section: { ...state.section, options }})); }; return ( diff --git a/client/src/gql/queries/dsf.tsx b/client/src/gql/queries/dsf.tsx index 2155aa6..e41b5fc 100644 --- a/client/src/gql/queries/dsf.tsx +++ b/client/src/gql/queries/dsf.tsx @@ -7,7 +7,7 @@ export const QUERY_DECISION_SUPPORT_FILES = gql` decisionSupportFiles(filter: $filter) { id, title, - sections + sections, createdAt, closedAt, votedAt, @@ -18,7 +18,7 @@ export const QUERY_DECISION_SUPPORT_FILES = gql` members { id } - } + }, } } `;