diff --git a/website/src/components/FlaggableElement.tsx b/website/src/components/FlaggableElement.tsx index 82b7c8a4..556df44e 100644 --- a/website/src/components/FlaggableElement.tsx +++ b/website/src/components/FlaggableElement.tsx @@ -19,18 +19,18 @@ import { } from "@chakra-ui/react"; import useSWRMutation from "swr/mutation"; import { QuestionMarkCircleIcon, FlagIcon } from "@heroicons/react/20/solid"; -import {useState } from "react"; -import { SubmitButton } from "./Buttons/Submit"; +import { useState } from "react"; export type TextFlagProps = { - text: string;label_map - post_id:string; + text: string; + label_map; + post_id: string; }; -type FlagRefs={ +type FlagRefs = { label: string; - value:number; + value: number; setValue; - isChecked:boolean; + isChecked: boolean; setChecked; }; @@ -42,34 +42,45 @@ export const FlaggableElement = (props) => { setIsEditing.off; }, }); - + const submitResponse = (label_data) => { trigger(label_data); }; - const label_refs:FlagRefs[] = TEXT_LABEL_FLAGS.map((flag) =>{ + const label_refs: FlagRefs[] = TEXT_LABEL_FLAGS.map((flag) => { const [isChecked, setChecked] = useState(false); const [value, setValue] = useState(1); - return({label:flag.attributeName, value:value, setValue:setValue, isChecked:isChecked, setChecked:setChecked}); - + return { + label: flag.attributeName, + value: value, + setValue: setValue, + isChecked: isChecked, + setChecked: setChecked, + }; }); - const fetchData = () =>{ - let label_map:Map =new Map(); - label_refs.filter((flagRef) => (flagRef.isChecked)).map((refs) =>{ - label_map.set(refs.label, refs.value) - }); + const fetchData = () => { + let label_map: Map = new Map(); + label_refs + .filter((flagRef) => flagRef.isChecked) + .map((refs) => { + label_map.set(refs.label, refs.value); + }); console.log(label_map); - return {post_id:props.post_id, label_map:Object.fromEntries(label_map), text:props.text} - - } + return { post_id: props.post_id, label_map: Object.fromEntries(label_map), text: props.text }; + }; return ( - -
- - {props.children} - + +
+ {props.children} - @@ -79,35 +90,35 @@ export const FlaggableElement = (props) => {
- -
    + +
      {TEXT_LABEL_FLAGS.map((option, i) => { - return ( - - ); - })} -
    -
    - -
    -
    + return ; + })} +
+
+ +
+
); }; -function FlagCheckboxLi(props: { option: textFlagLabels, state:FlagRefs}): JSX.Element { +function FlagCheckboxLi(props: { option: textFlagLabels; state: FlagRefs }): JSX.Element { let AdditionalExplanation = null; if (props.option.additionalExplanation) { AdditionalExplanation = ( - ); } @@ -116,15 +127,27 @@ function FlagCheckboxLi(props: { option: textFlagLabels, state:FlagRefs}): JSX.E <>
  • - {props.state.setChecked(e.target.checked);}}/> -