portal-www
Version:
Nova Portal Website. Based on Next starter by Ueno
44 lines (35 loc) • 814 B
text/typescript
import { extendObservable, observable, action, makeObservable } from 'mobx';
export default class Checkout {
constructor({ checkout = {} }: any) {
makeObservable(this, {
step: observable,
highestStep: observable,
lastStep: observable,
next: action,
manuallySetStep: action,
reset: action,
});
extendObservable(this, checkout);
}
step = 1;
highestStep = 1;
lastStep = 1;
next() {
this.lastStep = this.step;
this.step += 1;
if (this.highestStep < this.step) {
this.highestStep = this.step;
}
}
manuallySetStep(newStep: number) {
this.lastStep = this.step;
if (newStep <= this.highestStep) {
this.step = newStep;
}
}
reset() {
this.step = 1;
this.highestStep = 1;
this.lastStep = 1;
}
}