Skip to content

Commit

Permalink
refactor: use nextVariant button
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaHungDinh committed Apr 8, 2024
1 parent b3a8ecb commit 532890d
Showing 1 changed file with 45 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,79 @@ const withButtons = (steps) => {
const previous = {
classes: 'shepherd-button-secondary',
text: 'Previous',
type: 'back'
type: 'back',
};

const next = {
classes: 'shepherd-button-primary',
text: 'Next',
type: 'next'
}
type: 'next',
};

const nextVariant = {
classes: 'shepherd-button-primary',
text: 'Got it',
type: 'next',
};

const complete = {
classes: 'shepherd-button-primary',
text: 'Got it',
type: 'complete'
}
type: 'complete',
};

const Okay = {
const okay = {
classes: 'shepherd-button-primary shepherd-button-primary--tools',
text: 'Okay',
type: 'complete',
};

const hasToolSteps = steps.some(({id}) => id === 'schema-find-tour');

return steps.map((step, index) => {
if(index === 0) {
return {...step, ...{
buttons: [next]
}}
if (index === 0) {
return {
...step,
...{
buttons: [next],
},
};
}

if (step.id === 'schema-find-tour') {
return {
...step,
...{
buttons: [Okay],
buttons: [okay],
},
};
}

if (hasToolSteps && step.id === 'schema-edit-block') {
return {
...step,
...{
buttons: [previous, nextVariant],
},
};
}

if(index === steps.length - 1) {
return {...step, ...{
buttons: [previous, complete]
}}
if (index === steps.length - 1) {
return {
...step,
...{
buttons: [previous, complete],
},
};
}

return {...step, ...{
buttons: [previous, next]
}}
return {
...step,
...{
buttons: [previous, next],
},
};
});
}
};

export default withButtons
export default withButtons;

0 comments on commit 532890d

Please sign in to comment.