Skip to content

Commit

Permalink
fixied the bug and set the defult value of useNonEqi and `use_simul…
Browse files Browse the repository at this point in the history
…ate_slit` to false
  • Loading branch information
arunavabasucom committed Aug 8, 2022
1 parent 5588d11 commit 9b895b5
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions frontend/src/components/CalcSpectrum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export const CalcSpectrum: React.FC = () => {
);
const [isNonEquilibrium, setIsNonEquilibrium] = useState(false);
const [useGesia, setUseGesia] = useState(false);
const [useSlit, setUseSlit] = useState(false);
const [useSimulateSlitFunction, setUseSimulateSlitFunction] = useState(false);
const [useSlit, setUseSlit] = useState(false); // checking that user wants to apply the slit function or not in available modes
const [useSimulateSlitFunction, setUseSimulateSlitFunction] = useState(false); // checking the mode and enable or disable slit feature
const Schema = yup.object().shape({
useNonEqi: yup.boolean(),
useSlitSwitch: yup.boolean(), //bool
use_simulate_slit: yup.boolean(),
path_length: yup
.number()
.required("Path length must be defined")
Expand Down Expand Up @@ -136,7 +136,9 @@ export const CalcSpectrum: React.FC = () => {
}

setLoading(true);
console.log(data);
setError(undefined);

setPlotData({
max_wavenumber_range: data.max_wavenumber_range,
min_wavenumber_range: data.min_wavenumber_range,
Expand Down Expand Up @@ -188,16 +190,18 @@ export const CalcSpectrum: React.FC = () => {
const UseNonEquilibriumCalculations = () => (
<Controller
name="useNonEqi"
defaultValue={false}
control={control}
render={() => (
render={({ field }) => (
<FormControlLabel
label="Use non-equilibrium calculations"
control={
<Switch
checked={isNonEquilibrium}
onChange={(e) => {
setIsNonEquilibrium(e.target.checked);
if (e.target.checked) {
onChange={(event, value) => {
setIsNonEquilibrium(event.target.checked);
field.onChange(value);
if (event.target.checked) {
setValue("tvib", 300);
setValue("trot", 300);
} else {
Expand All @@ -214,16 +218,18 @@ export const CalcSpectrum: React.FC = () => {
const UseSimulateSlit = () => (
<Controller
name="use_simulate_slit"
defaultValue={false}
control={control}
render={() => (
render={({ field }) => (
<FormControlLabel
label="Apply Instrumental Slit Function"
control={
<Switch
checked={useSlit}
onChange={(e) => {
setUseSlit(e.target.checked);
if (e.target.checked) {
onChange={(event, value) => {
setUseSlit(event.target.checked);
field.onChange(value);
if (event.target.checked) {
setValue("simulate_slit", 5);
} else {
setValue("simulate_slit", undefined);
Expand Down

0 comments on commit 9b895b5

Please sign in to comment.