Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: rename setters from `onXYZ` to `xyz`

Abdullah Attaef4c9af7dcac
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<HTMLInputElement>(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<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;