init project portal web
This commit is contained in:
41
lib/price-plan-detail/view-model/index.ts
Normal file
41
lib/price-plan-detail/view-model/index.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { OptionProps } from "@/lib/helper/type";
|
||||
import { toOptionProps } from "@/lib/helper/option";
|
||||
import { useUsageEventQuery } from "../queries";
|
||||
import { useCreatePricePlanMutation } from "@/lib/price-plan/mutations";
|
||||
import { RatePlanPayload } from "../data/repository";
|
||||
import PricePlanDetailState from "../state/price-plan-detail-state";
|
||||
import RatePlanFormState from "../state/rate-plan-form-state";
|
||||
import { makeAutoObservable } from "mobx";
|
||||
import PriceVersionFormState from "../state/price-version-form-state";
|
||||
|
||||
export default class PricePlanDetailViewModel {
|
||||
private pricePlanDetailState = new PricePlanDetailState();
|
||||
private ratePlanFormState = new RatePlanFormState();
|
||||
private priceVersionFormState = new PriceVersionFormState()
|
||||
|
||||
// query + mutation results
|
||||
private usageEventsQuery = useUsageEventQuery();
|
||||
private createRatePlanMutate = useCreatePricePlanMutation(() => {
|
||||
console.log("Rate plan created");
|
||||
});
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this)
|
||||
}
|
||||
|
||||
getMainState = () => this.pricePlanDetailState;
|
||||
|
||||
getRatePlanFormState = () => this.ratePlanFormState;
|
||||
|
||||
getPriceVersionFormState = () => this.priceVersionFormState
|
||||
|
||||
getUsageEventOptions = (): OptionProps[] => {
|
||||
const data: any = this.usageEventsQuery.data;
|
||||
return toOptionProps(data);
|
||||
};
|
||||
|
||||
// --- MUTATIONS ---
|
||||
createRatePlan = (payload: RatePlanPayload) => {
|
||||
this.createRatePlanMutate.mutate(payload);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user