Skip to content

Commit

Permalink
Improve ItemCreator
Browse files Browse the repository at this point in the history
  • Loading branch information
mhauru committed Apr 13, 2022
1 parent 5d056ae commit b609719
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions frontend/src/components/ItemCreator.js
Expand Up @@ -4,13 +4,6 @@ import { Box, Button, Form, FormField, Heading, TextInput } from "grommet";
import React, { useState } from "react";
import configData from "../config.json";

const TYPE_NAME_TO_DB_TYPE_NAME = {
AssuranceCase: "assurance_case_id",
TopLevelNormativeGoal: "goal_id",
PropertyClaim: "property_claim_id",
EvidentialClaim: "evidential_claim_id",
};

function ItemCreator(props) {
const [parentId, setParentId] = useState(1);
const [name, setName] = useState("Name");
Expand Down Expand Up @@ -51,13 +44,12 @@ function ItemCreator(props) {
if (
configData.navigation[props.type]["parent_relation"] === "many-to-many"
) {
request_body[TYPE_NAME_TO_DB_TYPE_NAME[props.parentType]] = [
request_body[configData.navigation[props.parentType]["id_name"]] = [
parseInt(props.parentId),
];
} else {
request_body[TYPE_NAME_TO_DB_TYPE_NAME[props.parentType]] = parseInt(
props.parentId
);
request_body[configData.navigation[props.parentType]["id_name"]] =
parseInt(props.parentId);
}
const requestOptions = {
method: "POST",
Expand Down

0 comments on commit b609719

Please sign in to comment.