web: rename setters from onXYZ to xyz

This commit is contained in:
Abdullah Atta
2023-04-27 09:12:35 +05:00
committed by Abdullah Atta
parent 8ba3cf172e
commit ef4c9af7dc
2 changed files with 11 additions and 11 deletions

View File

@@ -52,7 +52,7 @@ export function BuyDialog(props: BuyDialogProps) {
const { onClose, couponCode, plan } = props;
const theme = useTheme() as Theme;
const onApplyCoupon = useCheckoutStore((store) => store.onApplyCoupon);
const onApplyCoupon = useCheckoutStore((store) => store.applyCoupon);
useEffect(() => {
return () => {
useCheckoutStore.getState().reset();
@@ -157,12 +157,12 @@ type SideBarProps = {
function SideBar(props: SideBarProps) {
const { initialPlan, onClose } = props;
const [showPlans, setShowPlans] = useState(!!initialPlan);
const onPlanSelected = useCheckoutStore((state) => state.onPlanSelected);
const onPlanSelected = useCheckoutStore((state) => state.selectPlan);
const selectedPlan = useCheckoutStore((state) => state.selectedPlan);
const pricingInfo = useCheckoutStore((state) => state.pricingInfo);
const user = useUserStore((store) => store.user);
const couponCode = useCheckoutStore((store) => store.couponCode);
const onApplyCoupon = useCheckoutStore((store) => store.onApplyCoupon);
const onApplyCoupon = useCheckoutStore((store) => store.applyCoupon);
if (user && selectedPlan)
return (
@@ -221,7 +221,7 @@ function SideBar(props: SideBarProps) {
function Details() {
const user = useUserStore((store) => store.user);
const selectedPlan = useCheckoutStore((state) => state.selectedPlan);
const onPriceUpdated = useCheckoutStore((state) => state.onPriceUpdated);
const onPriceUpdated = useCheckoutStore((state) => state.updatePrice);
const couponCode = useCheckoutStore((store) => store.couponCode);
const setIsApplyingCoupon = useCheckoutStore(
(store) => store.setIsApplyingCoupon
@@ -360,7 +360,7 @@ function SelectedPlan(props: SelectedPlanProps) {
store.setIsApplyingCoupon
]);
const onApplyCoupon = useCheckoutStore((store) => store.onApplyCoupon);
const onApplyCoupon = useCheckoutStore((store) => store.applyCoupon);
const couponInputRef = useRef<HTMLInputElement>(null);
const applyCoupon = useCallback(() => {

View File

@@ -23,13 +23,13 @@ import produce from "immer";
interface ICheckoutStore {
selectedPlan?: Plan;
onPlanSelected: (plan?: Plan) => void;
selectPlan: (plan?: Plan) => void;
pricingInfo?: PricingInfo;
onPriceUpdated: (pricingInfo?: PricingInfo) => void;
updatePrice: (pricingInfo?: PricingInfo) => void;
isApplyingCoupon: boolean;
setIsApplyingCoupon: (isApplyingCoupon: boolean) => void;
couponCode?: string;
onApplyCoupon: (couponCode?: string) => void;
applyCoupon: (couponCode?: string) => void;
reset: () => void;
}
export const useCheckoutStore = create<ICheckoutStore>((set) => ({
@@ -37,20 +37,20 @@ export const useCheckoutStore = create<ICheckoutStore>((set) => ({
pricingInfo: undefined,
couponCode: undefined,
isApplyingCoupon: false,
onPlanSelected: (plan) =>
selectPlan: (plan) =>
set(
produce((state: ICheckoutStore) => {
state.selectedPlan = plan;
state.pricingInfo = undefined;
})
),
onPriceUpdated: (pricingInfo) =>
updatePrice: (pricingInfo) =>
set(
produce((state: ICheckoutStore) => {
state.pricingInfo = pricingInfo;
})
),
onApplyCoupon: (couponCode) =>
applyCoupon: (couponCode) =>
set(
produce((state: ICheckoutStore) => {
state.couponCode = couponCode;