-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cross section parameter section to edit form
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-FileCopyrightText: LXCat team | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
import { MaybePromise } from "@/app/api/util"; | ||
import { ScientificInput } from "@/shared/scientific-input"; | ||
import { type CrossSectionParameters } from "@lxcat/schema/process"; | ||
import { Fieldset, Stack } from "@mantine/core"; | ||
|
||
export type ParameterProps = { | ||
parameters: CrossSectionParameters | undefined; | ||
setParameters: ( | ||
parameters: CrossSectionParameters | undefined, | ||
) => MaybePromise<void>; | ||
}; | ||
|
||
export const ParameterSection = ( | ||
{ parameters, setParameters }: ParameterProps, | ||
) => { | ||
return ( | ||
<Fieldset legend="Parameters"> | ||
<Stack> | ||
<ScientificInput | ||
label="Mass ratio" | ||
value={parameters && parameters.massRatio} | ||
onChange={(massRatio) => { | ||
if (massRatio === undefined) { | ||
if (parameters?.statisticalWeightRatio) { | ||
const { massRatio, ...params } = parameters; | ||
return setParameters(params); | ||
} else { | ||
return setParameters(undefined); | ||
} | ||
} else if (parameters) { | ||
return setParameters({ ...parameters, massRatio }); | ||
} else { | ||
return setParameters({ massRatio }); | ||
} | ||
}} | ||
/> | ||
<ScientificInput | ||
label="Statistical weight ratio" | ||
value={parameters && parameters.statisticalWeightRatio} | ||
onChange={(statisticalWeightRatio) => { | ||
if (statisticalWeightRatio === undefined) { | ||
if (parameters?.massRatio) { | ||
const { statisticalWeightRatio, ...params } = parameters; | ||
return setParameters(params); | ||
} else { | ||
return setParameters(undefined); | ||
} | ||
} else if (parameters) { | ||
return setParameters({ ...parameters, statisticalWeightRatio }); | ||
} else { | ||
return setParameters({ statisticalWeightRatio }); | ||
} | ||
}} | ||
/> | ||
</Stack> | ||
</Fieldset> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters