Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/components/application/application_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export default function ApplicationForm(props: ApplicationFormProperties) {

const validateFormState = useCallback(() => {
// console.log("validateFormState");
if (formState.touchedFields.protectedAmount === undefined) {
console.log("amount not touched, not calculating premium...");
if (getValues().protectedAmount === undefined || getValues().protectedAmount === "") {
console.log("amount empty, not calculating premium...");
return false;
}

Expand Down Expand Up @@ -372,11 +372,24 @@ export default function ApplicationForm(props: ApplicationFormProperties) {
textField: {
variant: INPUT_VARIANT,
fullWidth: true,
error: errors.coverageEndDate !== undefined || field.value?.isBefore(coverageUntilMin, 'day') || field.value?.isAfter(coverageUntilMax, 'day'),
helperText: errors.coverageEndDate !== undefined
? t('error.field.required', { ns: 'common' })
: (field.value?.isBefore(coverageUntilMin, 'day')
? t('error.field.min', { ns: 'common', minValue: coverageUntilMin.format('DD.MM.YYYY') })
: (field.value?.isAfter(coverageUntilMax, 'day')
? t('error.field.max', { ns: 'common', maxValue: coverageUntilMax.format('DD.MM.YYYY') })
: ""
)
)
}
}}
onAccept={async (date) => {
setValue("coverageDuration", dayjs(date).startOf('day').diff(dayjs().startOf('day'), 'days').toString());
await calculatePremium();
onChange={async (date) => {
field.onChange(date);
if (date && date.isValid()) {
setValue("coverageDuration", dayjs(date).startOf('day').diff(dayjs().startOf('day'), 'days').toString(), { shouldValidate: true });
await calculatePremium();
}
}}
disablePast={true}
minDate={coverageUntilMin}
Expand Down
14 changes: 12 additions & 2 deletions src/components/show_bundle/bundle_extend_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DatePicker } from "@mui/x-date-pickers";
import dayjs, { Dayjs } from "dayjs";
import { BigNumber } from "ethers";
import { useTranslation } from "next-i18next";
import { useState } from "react";
import { useMemo, useState } from "react";
import { Controller, SubmitHandler, useForm } from "react-hook-form";
import { BundleData } from "../../backend/bundle_data";
import { INPUT_VARIANT } from "../../config/theme";
Expand Down Expand Up @@ -44,7 +44,7 @@ export default function BundleExtendForm(props: BundleExtendFormProps) {
}
});

// const errors = useMemo(() => formState.errors, [formState]);
const errors = useMemo(() => formState.errors, [formState]);

const onSubmit: SubmitHandler<IFundFormValues> = async data => {
console.log("submit clicked", data);
Expand Down Expand Up @@ -83,6 +83,16 @@ export default function BundleExtendForm(props: BundleExtendFormProps) {
textField: {
variant: INPUT_VARIANT,
fullWidth: true,
error: errors.extensionEndDate !== undefined || field.value?.isBefore(minExtensionDate, 'day') || field.value?.isAfter(maxExtensionDate, 'day'),
helperText: errors.extensionEndDate !== undefined
? t('error.field.required', { ns: 'common' })
: (field.value?.isBefore(minExtensionDate, 'day')
? t('error.field.min', { ns: 'common', minValue: minExtensionDate.format('DD.MM.YYYY') })
: (field.value?.isAfter(maxExtensionDate, 'day')
? t('error.field.max', { ns: 'common', maxValue: maxExtensionDate.format('DD.MM.YYYY') })
: ""
)
)
}
}}
disablePast={true}
Expand Down
10 changes: 10 additions & 0 deletions src/components/stake/staking_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ export default function StakingForm(props: StakingFormProperties) {
textField: {
variant: INPUT_VARIANT,
fullWidth: true,
error: errors.lifetimeEndDate !== undefined || field.value?.isBefore(minLifetimeEndDate, 'day') || field.value?.isAfter(maxLifetimeEndDate, 'day'),
helperText: errors.lifetimeEndDate !== undefined
? t('error.field.required', { ns: 'common' })
: (field.value?.isBefore(minLifetimeEndDate, 'day')
? t('error.field.min', { ns: 'common', minValue: minLifetimeEndDate.format('DD.MM.YYYY') })
: (field.value?.isAfter(maxLifetimeEndDate, 'day')
? t('error.field.max', { ns: 'common', maxValue: maxLifetimeEndDate.format('DD.MM.YYYY') })
: ""
)
)
}
}}
disablePast={true}
Expand Down
2 changes: 1 addition & 1 deletion src/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name": "depeg-interface", "version": "1.2.7", "date": "2023-12-27" }
{"name": "depeg-interface", "version": "1.2.14", "date": "2026-07-11" }
Loading