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>
41 lines
999 B
TypeScript
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),
|
|
}
|
|
)
|
|
);
|