Skip to content

Commit

Permalink
[#152] change continue on register/ reset store data agreement when b…
Browse files Browse the repository at this point in the history
…ack to previous step
  • Loading branch information
Sworzen1 committed Feb 28, 2024
1 parent fc27fbd commit 63fc880
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ export const RegisterAsdRepStepThree = ({
}) => {
const { t } = useTranslation();
const { isMobile } = useScreenDimension();
const { control, errors, submitForm, isRegistrationAsDRepLoading, watch } =
useRegisterAsdRepFormContext();
const {
control,
errors,
isRegistrationAsDRepLoading,
resetField,
submitForm,
watch,
} = useRegisterAsdRepFormContext();

const onClickBackButton = () => setStep(2);
const onClickBackButton = () => {
setStep(2);
resetField("storeData");
};

const isContinueDisabled = !watch("storeData");

Expand All @@ -30,7 +39,7 @@ export const RegisterAsdRepStepThree = ({

return (
<BgCard
actionButtonLabel={t("continue")}
actionButtonLabel={t("register")}
isActionButtonDisabled={isContinueDisabled}
isLoadingActionButton={isRegistrationAsDRepLoading}
onClickActionButton={submitForm}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ interface Props {
export const RegisterAsdRepStepTwo = ({ setStep }: Props) => {
const { t } = useTranslation();
const { isMobile } = useScreenDimension();
const { control, errors,isContinueButtonDisabled, isSkipButton } = useRegisterAsdRepFormContext();
const { control, errors, isContinueButtonDisabled, isSkipButton } =
useRegisterAsdRepFormContext();

const onClickContinue = useCallback(() => setStep(3), []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ export const useRegisterAsdRepFormContext = () => {
control,
handleSubmit,
formState: { errors, isValid },
resetField,
watch,
} = useFormContext<UrlAndHashFormValues>();

const isSkipButton = !watch('hash')?.trim() && !watch("url")?.trim()
const isSkipButton = !watch("hash")?.trim() && !watch("url")?.trim();

const isContinueButtonDisabled = !!Object.keys(errors).length
const isContinueButtonDisabled = !!Object.keys(errors).length;

const onSubmit = useCallback(
async (values: UrlAndHashFormValues) => {
Expand Down Expand Up @@ -92,13 +93,14 @@ export const useRegisterAsdRepFormContext = () => {
);

return {
isRegistrationAsDRepLoading: isLoading,
control,
errors,
isValid,
isContinueButtonDisabled,
isRegistrationAsDRepLoading: isLoading,
isSkipButton,
watch,
isValid,
resetField,
submitForm: handleSubmit(onSubmit),
watch,
};
};
5 changes: 3 additions & 2 deletions govtool/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,12 @@ export const en = {
nextStep: "Next step",
no: "No",
ok: "Ok",
select: "Select",
register:"Register",
seeTransaction: "See transaction",
submit: "Submit",
select: "Select",
skip: "Skip",
sortBy: "Sort by",
submit: "Submit",
thisLink: "this link",
votingPower: "Voting power:",
yes: "Yes",
Expand Down

0 comments on commit 63fc880

Please sign in to comment.