Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMS-2151 fix: make it possible to accept defaults #11

Merged
Merged
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
24 changes: 16 additions & 8 deletions src/Routes/WizardPage/WizardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@

/** Event triggered when Back button is clicked. */
const onPreviousPage = (
_newStep: { id?: string | number; name: React.ReactNode },

Check warning on line 73 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_newStep' is defined but never used
_prevStep: { prevId?: string | number; prevName: React.ReactNode }

Check warning on line 74 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_prevStep' is defined but never used
) => {
// TODO If not needed at the end clean-up onPreviousPage
console.log('onPreviousPage fired');
Expand All @@ -80,8 +80,8 @@

/** Event triggered when a specific page is clicked. */
const onGoToStep = (
_newStep: { id?: string | number; name: React.ReactNode },

Check warning on line 83 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_newStep' is defined but never used
_prevStep: { prevId?: string | number; prevName: React.ReactNode }

Check warning on line 84 in src/Routes/WizardPage/WizardPage.tsx

View workflow job for this annotation

GitHub Actions / validate

'_prevStep' is defined but never used
) => {
// TODO If not needed at the end clean-up onPreviousPage
console.log('onGoToStep fired');
Expand Down Expand Up @@ -122,21 +122,29 @@

const onVerify = (value: VerifyState, data?: Domain) => {
appContext.wizard.setRegisteredStatus(value);
if (value === 'completed') {
data && appContext.wizard.setDomain(data);
if (value === 'completed' && data !== undefined) {
appContext.wizard.setDomain(data);
setCanJumpPage3(true);
// Check whether initial values for user-configurable fields
// are valid. They should be, which will enable the user to
// accept the defaults as-is.
onUserInputChange(data);
} else {
setCanJumpPage3(false);
}
};

// User changed an input that could affect data validity.
// Check validity and set "Next" button state accordingly.
const onUserInputChange = (domain: Domain): void => {
const good = domain.title ? domain.title.length > 0 : false;
setCanJumpPage4(good);
};

const onChangeTitle = (value: string) => {
appContext.wizard.setDomain({ ...domain, title: value });
if (value.length > 0) {
setCanJumpPage4(true);
} else {
setCanJumpPage4(false);
}
const newDomain: Domain = { ...domain, title: value };
appContext.wizard.setDomain(newDomain);
onUserInputChange(newDomain);
};

const onChangeDescription = (value: string) => {
Expand Down
Loading