From ef4c9af7dcac21f7c0e96353f9a171b413df2471 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Thu, 27 Apr 2023 09:12:35 +0500 Subject: [PATCH] web: rename setters from `onXYZ` to `xyz` --- .../src/components/dialogs/buy-dialog/buy-dialog.tsx | 10 +++++----- apps/web/src/components/dialogs/buy-dialog/store.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx b/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx index c19e8410d..baf7b7e56 100644 --- a/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx +++ b/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx @@ -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(null); const applyCoupon = useCallback(() => { diff --git a/apps/web/src/components/dialogs/buy-dialog/store.ts b/apps/web/src/components/dialogs/buy-dialog/store.ts index 7f683845d..1efdc9c91 100644 --- a/apps/web/src/components/dialogs/buy-dialog/store.ts +++ b/apps/web/src/components/dialogs/buy-dialog/store.ts @@ -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((set) => ({ @@ -37,20 +37,20 @@ export const useCheckoutStore = create((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;