actually save value
This commit is contained in:
parent
fd4d72eb21
commit
4b28045d60
@ -28,6 +28,7 @@
|
||||
"warn",
|
||||
"allman"
|
||||
],
|
||||
"indent": "warn"
|
||||
"indent": "warn",
|
||||
"semi": "error"
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import React, { Children, useRef, useState } from "react";
|
||||
import React, { useRef, useState } from "react";
|
||||
import ClickDetector from "../util/ClickDetector";
|
||||
import { DropdownBaseProps, DropdownItemProps } from "../@types/Components";
|
||||
import '../css/components/InputElements.css';
|
||||
|
@ -21,19 +21,20 @@ const Flag = ({ flag: incoming }: { flag: APIFlag }) =>
|
||||
const save = async () =>
|
||||
{
|
||||
const response = await patch(`/api/flags/${flag.id}`, flag);
|
||||
console.log(flag);
|
||||
if (response.success)
|
||||
setUnsaved(false);
|
||||
else
|
||||
setError(response.message)
|
||||
setError(response.message);
|
||||
};
|
||||
|
||||
let Input = <p>Loading...</p>;
|
||||
if (flag.type === 'string')
|
||||
Input = <StringInput onChange={() => setUnsaved(true)} inputRef={valueRef} value={flag.value as string} />;
|
||||
Input = <StringInput onChange={({target}) => updateFlag({...flag, value: target.value })} inputRef={valueRef} value={flag.value as string} />;
|
||||
else if (flag.type === 'number')
|
||||
Input = <NumberInput onChange={() => setUnsaved(true)} inputRef={valueRef} value={flag.value as number} type='float' />;
|
||||
Input = <NumberInput onChange={({target}) => updateFlag({...flag, value: parseFloat(target.value)})} inputRef={valueRef} value={flag.value as number} type='float' />;
|
||||
else if (flag.type === 'boolean')
|
||||
Input = <ToggleSwitch onChange={() => setUnsaved(true)} inputRef={valueRef} value={flag.value as boolean} />;
|
||||
Input = <ToggleSwitch onChange={({target}) => updateFlag({...flag, value: target.value })} inputRef={valueRef} value={flag.value as boolean} />;
|
||||
|
||||
return <div className='flag mt-0 mb-1'>
|
||||
{/* TODO: Improve these*/}
|
||||
|
Loading…
Reference in New Issue
Block a user