This repository has been archived on 2026-08-11. You can view files and clone it, but cannot push or open issues or pull requests.
Gishen-Mob/lib/stores/prefsStore.ts
kirukib d40cb22ff4 Finalize profile, prescription, and checkout with shared UI modules.
Add payment/notification prefs, assisted pharmacist codes, Rx status journey, and mock payment intents so demo flows match the storefront brief.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 14:53:34 +03:00

41 lines
999 B
TypeScript

import AsyncStorage from "@react-native-async-storage/async-storage";
import { create } from "zustand";
import { createJSONStorage, persist } from "zustand/middleware";
export type NotificationPrefs = {
sms: boolean;
email: boolean;
push: boolean;
orderUpdates: boolean;
refillReminders: boolean;
marketing: boolean;
};
type PrefsState = NotificationPrefs & {
setPref: <K extends keyof NotificationPrefs>(key: K, value: NotificationPrefs[K]) => void;
setMany: (patch: Partial<NotificationPrefs>) => void;
};
const defaults: NotificationPrefs = {
sms: true,
email: true,
push: true,
orderUpdates: true,
refillReminders: true,
marketing: false,
};
export const usePrefsStore = create<PrefsState>()(
persist(
(set) => ({
...defaults,
setPref: (key, value) => set({ [key]: value } as Partial<PrefsState>),
setMany: (patch) => set(patch),
}),
{
name: "gishen-prefs",
storage: createJSONStorage(() => AsyncStorage),
}
)
);