actually save value
This commit is contained in:
parent
fd4d72eb21
commit
4b28045d60
@ -28,6 +28,7 @@
|
|||||||
"warn",
|
"warn",
|
||||||
"allman"
|
"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 ClickDetector from "../util/ClickDetector";
|
||||||
import { DropdownBaseProps, DropdownItemProps } from "../@types/Components";
|
import { DropdownBaseProps, DropdownItemProps } from "../@types/Components";
|
||||||
import '../css/components/InputElements.css';
|
import '../css/components/InputElements.css';
|
||||||
|
@ -21,19 +21,20 @@ const Flag = ({ flag: incoming }: { flag: APIFlag }) =>
|
|||||||
const save = async () =>
|
const save = async () =>
|
||||||
{
|
{
|
||||||
const response = await patch(`/api/flags/${flag.id}`, flag);
|
const response = await patch(`/api/flags/${flag.id}`, flag);
|
||||||
|
console.log(flag);
|
||||||
if (response.success)
|
if (response.success)
|
||||||
setUnsaved(false);
|
setUnsaved(false);
|
||||||
else
|
else
|
||||||
setError(response.message)
|
setError(response.message);
|
||||||
};
|
};
|
||||||
|
|
||||||
let Input = <p>Loading...</p>;
|
let Input = <p>Loading...</p>;
|
||||||
if (flag.type === 'string')
|
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')
|
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')
|
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'>
|
return <div className='flag mt-0 mb-1'>
|
||||||
{/* TODO: Improve these*/}
|
{/* TODO: Improve these*/}
|
||||||
|
Loading…
Reference in New Issue
Block a user