Skip to content

Commit

Permalink
[frontend] slightly better UI (#2859)
Browse files Browse the repository at this point in the history
  • Loading branch information
aHenryJard committed Dec 13, 2023
1 parent 984b95b commit ed5f500
Showing 1 changed file with 47 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ let graphData: GraphData = {
startDateMs:now(),
startScore:100,
decayModel: DEFAULT_DECAY_MODEL,
pointCount: 30,
pointCount: 150,
pound: 1
};

export const handleSubmit = (values: FormikValues) => {
console.log('handleSubmit of ', values);
const newStartScore: number = parseInt(values.startScore);
if (newStartScore > 0 && newStartScore <=100 ) {
graphData.startScore = newStartScore;
Expand All @@ -48,6 +47,20 @@ export const handleSubmit = (values: FormikValues) => {
if (newPound) {
graphData.pound = newPound;
}

const newLifeTime: number = parseInt(values.lifetime);
if (newLifeTime > 0) {
graphData.decayModel.decay_lifetime = newLifeTime;
}

if (values.reactionPoints) {
graphData.decayModel.decay_points = values.reactionPoints.split(';');
}

const newCutOff: number = parseInt(values.cutoff);
if (newCutOff) {
graphData.decayModel.decay_revoked_cutoff = newCutOff;
}
}
const Decay = () => {

Expand Down Expand Up @@ -79,27 +92,51 @@ const Decay = () => {
<div>
<Formik
initialValues={{
startScore: '',
pound: '',
startScore: '100',
pound: '1',
lifetime: '30',
reactionPoints:'80;40;20',
cutoff: 20
}}
onSubmit={async (values) => {
handleSubmit(values);
setRefreshMeNow(!refreshMeNow);
}}
>
<Form>
<label htmlFor="startScore">Start score (100-0)</label>
<Field id="startScore" name="startScore" placeholder="100" />
<div>
<label htmlFor="startScore">Start score (100-0):</label>
<Field id="startScore" name="startScore"/>
</div>

<div>
<label htmlFor="pound">Pound (ex: 0.8):</label>
<Field id="pound" name="pound" />
</div>

<div>
<label htmlFor="lifetime">Lifetime in days (ex: 30):</label>
<Field id="lifetime" name="lifetime"/>
</div>

<div>
<label htmlFor="reactionPoints">List of reaction point (ex: 80;40;20):</label>
<Field id="reactionPoints" name="reactionPoints"/>
</div>

<div>
<label htmlFor="cutoff">Cut-Off score (ex: 20):</label>
<Field id="cutoff" name="cutoff"/>
</div>

<label htmlFor="pound">Pound (ex: 1)</label>
<Field id="pound" name="pound" placeholder="1" />
<button type="submit">Submit</button>
<div>
<button type="submit">Submit</button>
</div>
</Form>
</Formik>
</div>
<div>
<div>Model is:- </div>
<div>decay_points: {graphData.decayModel.decay_points}</div>
<div>decay_factor: {graphData.decayModel.decay_factor}</div>
<div>decay_lifetime: {graphData.decayModel.decay_lifetime} day(s)</div>
<div>decay_revoked_cutoff: {graphData.decayModel.decay_revoked_cutoff} day(s)</div>
Expand Down

0 comments on commit ed5f500

Please sign in to comment.