@bzbs/react-providers
Version:
A collection of React Context Provider for Buzzebees apps
1,104 lines (1,071 loc) • 40.6 kB
text/typescript
import * as zustand from 'zustand';
import { UseBoundStore, StoreApi } from 'zustand';
import { Address, ServiceResponse, ErrorResponse, LoginResponse, Account, AppleToken, ForgetPasswordResponse, StatusResponse, OtpResponse, ValidateOtpResponse, ConfirmOtpResponse, ResumeResponse, Version, BzbsService, RedeemResponse, UseCampaignResponse, CampaignDetail, Style, CartCountResponse, Campaign, Category, Consent, CouponResponse, Dashboard, Maintenance, Notification, PointLog, Purchase, RegistrationResponse, ProfileResponse, UpdatedPoints, PointBalance, ExpiringPoints, Badge, Trace, ZipCode } from '@bzbs/react-api-client';
import MatomoTracker, { UserInfo } from 'matomo-tracker-react-native';
import * as emittery from 'emittery';
import emittery__default from 'emittery';
import { AxiosInstance } from 'axios';
type AddressState = {
addresses: Address[];
taxAddresses: Address[];
selectedAddress: Address | null;
selectedTaxAddress: Address | null;
isLoading: boolean;
error: ServiceResponse<unknown> | null;
};
type AddressActions = {
setSelectedAddress: (address: Address | null) => void;
fetchAddresses: () => Promise<ServiceResponse<Address[]>>;
addAddress: (address: AddressFormData) => Promise<ServiceResponse<Address>>;
editAddress: (address: AddressFormData) => Promise<ServiceResponse<Address>>;
deleteAddress: (rowKey: string) => Promise<ServiceResponse<unknown>>;
setSelectedTaxAddress: (address: Address | null) => void;
fetchTaxAddresses: () => Promise<ServiceResponse<Address[]>>;
addTaxAddress: (address: AddressFormData) => Promise<ServiceResponse<Address>>;
editTaxAddress: (address: AddressFormData) => Promise<ServiceResponse<Address>>;
deleteTaxAddress: (rowKey: string) => Promise<ServiceResponse<unknown>>;
clear: () => void;
};
type AddressStore = AddressState & AddressActions;
type PersonType = 'individual' | 'company';
type AddressFormData = {
addressName?: string;
firstName?: string;
lastName?: string;
address?: string;
zipcode?: string;
provinceCode?: string;
provinceName?: string;
districtCode?: string;
districtName?: string;
subDistrictCode?: string;
subDistrictName?: string;
contactNumber?: string;
email?: string;
remark?: string;
countryCode?: string;
countryName?: string;
isDefault?: boolean;
rowKey?: string;
taxId?: string;
personType?: PersonType;
companyName?: string;
};
declare const useAddressStore: zustand.UseBoundStore<zustand.StoreApi<AddressStore>>;
type AlertRequest = {
title: string;
content: string;
closeText?: string;
onClose: () => void;
};
type AlertState = {
isOpen: boolean;
alertRequest: AlertRequest;
};
type AlertActions = {
openAlert: (request: AlertRequest) => void;
closeAlert: () => void;
};
type AlertStore = AlertState & AlertActions;
declare const useAlertStore: zustand.UseBoundStore<zustand.StoreApi<AlertStore>>;
type AnalyticsEventParams = {
action: string;
name?: string;
category?: string;
value?: number;
campaign?: string;
userInfo?: UserInfo;
};
type AnalyticsPageViewParams = {
name: string;
url?: string;
userInfo?: UserInfo;
};
type AnalyticsState = {
isInitialized: boolean;
isEnabled: boolean;
siteId?: number;
urlBase?: string;
trackerUrl?: string;
userId?: string;
disabled?: boolean;
log?: boolean;
matomoInstance?: MatomoTracker;
presetUserInfo?: UserInfo;
};
type AnalyticsActions = {
initialize: (config: {
siteId: number;
urlBase: string;
trackerUrl?: string;
userId?: string;
disabled?: boolean;
log?: boolean;
}) => void;
setEnabled: (enabled: boolean) => void;
setPresetUserInfo: (userInfo: UserInfo) => void;
clearPresetUserInfo: () => void;
trackAppStart: (userInfo?: UserInfo) => Promise<void>;
trackEvent: (params: AnalyticsEventParams) => Promise<void>;
trackScreenView: (params: AnalyticsPageViewParams) => Promise<void>;
trackAction: (params: AnalyticsPageViewParams) => Promise<void>;
trackSiteSearch: (params: {
keyword: string;
category?: string;
count?: number;
userInfo?: UserInfo;
}) => Promise<void>;
trackLink: (params: {
link: string;
userInfo?: UserInfo;
}) => Promise<void>;
trackDownload: (params: {
download: string;
userInfo?: UserInfo;
}) => Promise<void>;
setUserId: (userId: string | null) => void;
setCustomDimension: (id: number, value: string) => void;
reset: () => void;
};
type AnalyticsStore = AnalyticsState & AnalyticsActions;
declare const useAnalyticsStore: zustand.UseBoundStore<zustand.StoreApi<AnalyticsStore>>;
type GoogleLoginData = {
type: 'google';
idToken: string;
};
type FacebookLoginData = {
type: 'facebook';
accessToken: string;
};
type AppleLoginData = {
type: 'apple';
idToken: string;
refreshToken: string;
};
type LineLoginData = {
type: 'line';
idToken: string;
lineAccessToken: string;
authorizationCode: string;
};
type ThirdPartyLoginData = GoogleLoginData | FacebookLoginData | AppleLoginData | LineLoginData;
type AuthState = {
isInitialized: boolean;
versionData: Version | null;
rawVersionData: unknown | null;
data: LoginResponse | ResumeResponse | null;
thirdPartyLoginData?: ThirdPartyLoginData;
isLoading: boolean;
isLoadingToken: boolean;
error: ErrorResponse | null;
token: string | null;
isLoggedIn: boolean;
isDeviceLoggedIn: boolean;
};
type AuthActions = {
setIsLoading: (isLoading: boolean) => void;
setIsLoadingToken: (isLoadingToken: boolean) => void;
setError: (error: ErrorResponse | null) => void;
setThirdPartyLoginData: (thirdPartyLoginData: ThirdPartyLoginData) => void;
checkLoggedIn: () => Promise<void>;
loginWithUsernamePassword: (username: string, password: string) => Promise<ServiceResponse<LoginResponse>>;
loginWithGoogle: (token: string) => Promise<ServiceResponse<LoginResponse>>;
loginWithFacebook: (token: string) => Promise<ServiceResponse<LoginResponse>>;
loginWithApple: (token: string, refreshToken: string) => Promise<ServiceResponse<LoginResponse>>;
loginWithLine: (idToken: string, lineAccessToken: string, authorizationCode: string) => Promise<ServiceResponse<LoginResponse>>;
loginWithUUID: () => Promise<ServiceResponse<LoginResponse>>;
loginWithOtp: (otp: string, refCode: string, contact: string) => Promise<ServiceResponse<LoginResponse>>;
connectThirdParty: (thirdPartyLoginData: ThirdPartyLoginData) => Promise<ServiceResponse<LoginResponse>>;
disconnectThirdParty: (thirdParties: {
facebook?: boolean;
google?: boolean;
apple?: boolean;
line?: boolean;
}) => Promise<ServiceResponse<Account>>;
logout: () => Promise<ServiceResponse<unknown>>;
appleToken: (authorizationCode: string, idToken: string) => Promise<ServiceResponse<AppleToken>>;
forgetPassword: (contact: string, type: 'email' | 'contact_number') => Promise<ServiceResponse<ForgetPasswordResponse>>;
resetPassword: (contact: string, otp: string, refCode: string, password: string) => Promise<ServiceResponse<StatusResponse>>;
sendOtp: (contact: string, channel: string) => Promise<ServiceResponse<OtpResponse>>;
validateOtp: (otp: string, refCode: string, contact: string, channel: string, type: 'email' | 'contact_number') => Promise<ServiceResponse<ValidateOtpResponse>>;
confirmOtp: (otp: string, refCode: string, contact: string) => Promise<ServiceResponse<ConfirmOtpResponse>>;
resume: (clientVersion: string) => Promise<ServiceResponse<ResumeResponse>>;
version: (clientVersion: string) => Promise<ServiceResponse<Version>>;
clear: () => void;
};
type AuthStore = AuthState & AuthActions;
declare const useAuthStore: zustand.UseBoundStore<zustand.StoreApi<AuthStore>>;
type AuthTokenType = 'jwt' | 'auth_token';
type getTokenFunction = () => Promise<string | null>;
type setTokenFunction = (token: string) => void;
type removeTokenFunction = () => void;
type TokenFunctions = {
getToken: getTokenFunction;
setToken: setTokenFunction;
removeToken: removeTokenFunction;
};
type BuzzebeesAppState = {
appId: string;
appName: string;
bzbsService: BzbsService | null;
uuid: string;
macAddress: string;
clientVersion: string;
os: string;
platform: string;
fcmToken: string;
deviceNotificationEnabled: boolean;
urls: {
webCallback: string;
cart: string;
};
tokenFunctions: TokenFunctions | null;
tokenType: AuthTokenType;
config: {
defaultDashboardConfig: string;
defaultDashboardMode: 'main' | 'sub';
defaultMenuConfig: string;
defaultCampaignConfig: string;
supportPointUnits: string[];
};
};
type BuzzebeesAppActions = {
setAppId: (appId: string) => void;
setAppName: (appName: string) => void;
setBzbsService: (service: BzbsService) => void;
setUuid: (uuid: string) => void;
setMacAddress: (macAddress: string) => void;
setClientVersion: (clientVersion: string) => void;
setOs: (os: string) => void;
setPlatform: (platform: string) => void;
setFcmToken: (fcmToken: string) => void;
setDeviceNotificationEnabled: (deviceNotificationEnabled: boolean) => void;
setUrls: (urls: {
webCallback: string;
cart: string;
}) => void;
setTokenType: (tokenType: AuthTokenType) => void;
setTokenFunctions: (tokenFunctions: TokenFunctions) => void;
configure: (config: {
appId: string;
appName: string;
bzbsService: BzbsService;
uuid: string;
macAddress: string;
clientVersion: string;
os: string;
platform: string;
fcmToken: string;
deviceNotificationEnabled: boolean;
urls: {
webCallback: string;
cart: string;
};
tokenFunctions: TokenFunctions;
tokenType: AuthTokenType;
defaultDashboardConfig: string;
defaultDashboardMode: 'main' | 'sub';
defaultMenuConfig: string;
defaultCampaignConfig: string;
supportPointUnits: string[];
}) => void;
};
type BuzzebeesAppStore = BuzzebeesAppState & BuzzebeesAppActions;
declare const useBuzzebeesAppStore: zustand.UseBoundStore<zustand.StoreApi<BuzzebeesAppStore>>;
type CampaignButtonType = 'redeem' | 'get_points' | 'add_to_cart' | 'survey' | 'website' | 'draw' | 'donate' | 'delivery';
type CampaignDetailButtonState = {
enabled: boolean;
type: CampaignButtonType;
display: boolean;
};
type CampaignState = 'redeemable' | 'point_not_enough' | 'expired' | 'cool_down' | 'fail_in_condition' | 'sold_out' | 'redeemed';
type AfterRedeemDestination = 'delivery' | 'draw' | 'code' | 'get_points';
type AfterRedeem = {
destination: AfterRedeemDestination;
isCodeAutoUse: boolean;
redeemData: RedeemResponse;
clear: () => void;
};
type AfterUse = {
useData: UseCampaignResponse;
clear: () => void;
};
type CampaignDetailState = {
data: CampaignDetail | null;
style: Style | null;
subStyle: Style | null;
quantity: number;
totalPrice: number;
deliveryAddress: Address | null;
afterRedeem: AfterRedeem | null;
afterUse: AfterUse | null;
buttonState: CampaignDetailButtonState;
campaignState: CampaignState;
interfaceWebsite: string | null;
isLoading: boolean;
error: ErrorResponse | null;
campaignId: string | null;
pictures: string[];
customCaption?: string;
};
type CampaignDetailActions = {
setError: (error: ErrorResponse) => void;
fetchData: (id: string) => Promise<ServiceResponse<CampaignDetail>>;
redeem: (addressOverride?: Address, pointUnit?: string, options?: {
[key: string]: unknown;
}) => Promise<ServiceResponse<RedeemResponse>>;
use: () => Promise<ServiceResponse<UseCampaignResponse>>;
addToFavorite: () => Promise<ServiceResponse<unknown>>;
removeFromFavorite: () => Promise<ServiceResponse<unknown>>;
setStyle: (style: Style) => void;
setSubStyle: (style: Style) => void;
setQuantity: (quantity: number) => void;
setDeliveryAddress: (address: Address) => void;
addToCart: () => Promise<ServiceResponse<CartCountResponse>>;
clear: () => void;
updateButtonState: () => void;
checkCondition: () => void;
calculatePrice: () => void;
};
type CampaignDetailStore = CampaignDetailState & CampaignDetailActions;
declare const createCampaignDetailStore: () => UseBoundStore<StoreApi<CampaignDetailStore>>;
interface CampaignsConfig {
itemsPerPage?: number;
defaultCampaignConfig?: string;
}
interface CampaignsOptions {
keyword?: string;
startDate?: string;
sponsorId?: string;
maxPoints?: string;
minPoints?: string;
minPrice?: string;
maxPrice?: string;
sortBy?: string;
center?: string;
hashTags?: string;
locationAgencyId?: string;
campaignservice?: boolean;
mode?: string | 'hot' | 'all' | 'bzbs' | 'sponsor' | 'draw' | 'free' | 'deal' | 'buy' | 'ads' | 'full' | 'cart';
[key: string]: unknown;
}
type CampaignsState = {
data: Campaign[];
isLoading: boolean;
hasMore: boolean;
error: ErrorResponse | null;
currentPage: number;
categoryId: string | null;
options?: CampaignsOptions;
config: CampaignsConfig;
};
type CampaignsActions = {
fetchData: (categoryId?: string, options?: CampaignsOptions) => Promise<ServiceResponse<Campaign[]>>;
loadMore: () => Promise<ServiceResponse<Campaign[]>>;
clear: () => void;
updateConfig: (config: Partial<CampaignsConfig>) => void;
};
type CampaignsStore = CampaignsState & CampaignsActions;
declare const createCampaignsStore: (initialConfig: CampaignsConfig) => zustand.UseBoundStore<zustand.StoreApi<CampaignsStore>>;
interface FavoriteCampaignsConfig {
itemsPerPage?: number;
}
type FavoriteCampaignsState = {
data: Campaign[];
isLoading: boolean;
hasMore: boolean;
error: ErrorResponse | null;
currentPage: number;
config: FavoriteCampaignsConfig;
options: {
[key: string]: unknown;
};
};
type FavoriteCampaignsActions = {
fetchData: (options?: {
[key: string]: unknown;
}) => Promise<ServiceResponse<Campaign[]>>;
loadMore: () => Promise<ServiceResponse<Campaign[]>>;
clear: () => void;
updateConfig: (config: Partial<FavoriteCampaignsConfig>) => void;
};
type FavoriteCampaignsStore = FavoriteCampaignsState & FavoriteCampaignsActions;
declare const createFavoriteCampaignsStore: (initialConfig: FavoriteCampaignsConfig) => zustand.UseBoundStore<zustand.StoreApi<FavoriteCampaignsStore>>;
type CartState = {
count: number;
isLoading: boolean;
error: ErrorResponse | null;
};
type CartActions = {
fetchCount: () => Promise<ServiceResponse<CartCountResponse>>;
clear: () => void;
};
type CartStore = CartState & CartActions;
declare const useCartStore: zustand.UseBoundStore<zustand.StoreApi<CartStore>>;
interface CategoriesConfig {
defaultMenuConfig?: string;
}
type CategoriesState = {
data: Category[];
isLoading: boolean;
error: ErrorResponse | null;
config: CategoriesConfig;
};
type CategoriesActions = {
fetchData: () => Promise<ServiceResponse<Category[]>>;
clear: () => void;
updateConfig: (config: Partial<CategoriesConfig>) => void;
};
type CategoriesStore = CategoriesState & CategoriesActions;
declare const createCategoriesStore: (initialConfig: CategoriesConfig) => zustand.UseBoundStore<zustand.StoreApi<CategoriesStore>>;
type ConfirmRequest = {
title: string;
content: string;
confirmText?: string;
cancelText?: string;
onConfirm?: () => void;
onCancel?: () => void;
};
type ConfirmState = {
isOpen: boolean;
confirmRequest: ConfirmRequest;
};
type ConfirmActions = {
openConfirm: (request: ConfirmRequest) => void;
closeConfirm: () => void;
};
type ConfirmStore = ConfirmState & ConfirmActions;
declare const useConfirmStore: zustand.UseBoundStore<zustand.StoreApi<ConfirmStore>>;
type ConsentState = {
data: Consent | null;
isLoading: boolean;
error: ErrorResponse | null;
};
type UpdateConsentParams = {
termsAndConditions?: string;
dataPrivacy?: string;
marketingOption?: string;
consentAge?: string;
email?: string;
sms?: string;
notification?: string;
line?: string;
analyticsBuzzebeesCookies?: string;
analyticsFirebaseCookies?: string;
analyticsGoogleCookies?: string;
analyticsMetaCookies?: string;
analyticsOtherCookies?: string;
functionalCookies?: string;
marketingCookies?: string;
necessaryCookies?: string;
options?: {
[key: string]: unknown;
};
};
type ConsentActions = {
fetchData: () => Promise<ServiceResponse<Consent>>;
updateConsent: (consent: UpdateConsentParams) => Promise<ServiceResponse<Consent>>;
clear: () => void;
};
type ConsentStore = ConsentState & ConsentActions;
declare const useConsentStore: zustand.UseBoundStore<zustand.StoreApi<ConsentStore>>;
type CouponState = {
data: CouponResponse | null;
isLoading: boolean;
error: ServiceResponse<unknown> | null;
};
type CouponActions = {
processCodes: (codes: string[]) => Promise<ServiceResponse<CouponResponse>>;
clear: () => void;
};
type CouponStore = CouponState & CouponActions;
declare const useCouponStore: zustand.UseBoundStore<zustand.StoreApi<CouponStore>>;
interface DashboardConfig {
defaultDashboardMode?: 'main' | 'sub';
defaultDashboardConfig?: string;
appId?: string;
}
type DashboardState = {
data: Dashboard[];
isLoading: boolean;
error: ErrorResponse | null;
config: DashboardConfig;
options?: {
[key: string]: unknown;
};
};
type DashboardActions = {
setIsLoading: (isLoading: boolean) => void;
setError: (error: ErrorResponse) => void;
fetchData: (options?: {
[key: string]: unknown;
}) => Promise<ServiceResponse<Dashboard[]>>;
clear: () => void;
updateConfig: (config: Partial<DashboardConfig>) => void;
};
type DashboardStore = DashboardState & DashboardActions;
declare const createDashboardStore: (initialConfig: DashboardConfig) => zustand.UseBoundStore<zustand.StoreApi<DashboardStore>>;
type LoadingIndicatorState = {
loading: boolean;
};
type LoadingIndicatorActions = {
show: () => void;
hide: () => void;
};
type LoadingIndicatorStore = LoadingIndicatorState & LoadingIndicatorActions;
declare const useLoadingIndicatorStore: zustand.UseBoundStore<zustand.StoreApi<LoadingIndicatorStore>>;
declare const useLoading: (isLoading: boolean) => void;
type AppLocale = {
locale: string;
localeId: number;
};
declare const EN: {
locale: string;
localeId: number;
};
declare const TH: {
locale: string;
localeId: number;
};
type LocaleState = {
appLocale: AppLocale;
locale: string;
localeId: number;
};
type LocaleActions = {
setAppLocale: (locale: AppLocale | string) => void;
};
type LocaleStore = LocaleState & LocaleActions;
declare const useLocaleStore: zustand.UseBoundStore<zustand.StoreApi<LocaleStore>>;
type MaintenanceState = {
isMaintenance: boolean | null;
maintenanceData: Maintenance | null;
};
type MaintenanceActions = {
checkMaintenance: () => Promise<void>;
};
type MaintenanceStore = MaintenanceState & MaintenanceActions;
declare const useMaintenanceStore: zustand.UseBoundStore<zustand.StoreApi<MaintenanceStore>>;
type NotificationState = {
data: Notification[];
isLoading: boolean;
error: ErrorResponse | null;
unreadCount: number;
hasMore: boolean;
currentPage: number;
pageSize: number;
};
type NotificationActions = {
fetchData: () => Promise<ServiceResponse<Notification[]>>;
loadMore: () => Promise<ServiceResponse<Notification[]>>;
markAsRead: (ids: string[]) => Promise<ServiceResponse<unknown>>;
setUnreadCount: (count: number) => void;
setPageSize: (size: number) => void;
clear: () => void;
};
type NotificationStore = NotificationState & NotificationActions;
declare const useNotificationStore: zustand.UseBoundStore<zustand.StoreApi<NotificationStore>>;
interface PointLogConfig {
defaultPageSize?: number;
type: 'earn' | 'burn';
}
type PointLogState = {
data: PointLog[];
isLoading: boolean;
hasMore: boolean;
error: ErrorResponse | null;
config: PointLogConfig;
lastRowKey?: string;
currentMonth?: string;
};
type PointLogActions = {
fetchData: (month?: string) => Promise<ServiceResponse<PointLog[]>>;
loadMore: () => Promise<ServiceResponse<PointLog[]>>;
clear: () => void;
updateConfig: (config: Partial<PointLogConfig>) => void;
};
type PointLogStore = PointLogState & PointLogActions;
declare const createPointLogStore: (initialConfig: PointLogConfig) => zustand.UseBoundStore<zustand.StoreApi<PointLogStore>>;
type PopupRequest = {
title?: string;
content: string;
closeText?: string;
onClose?: () => void;
closable?: boolean;
};
type PopupState = {
isOpen: boolean;
popupRequest: PopupRequest;
};
type PopupActions = {
openPopup: (request: PopupRequest) => void;
closePopup: () => void;
};
type PopupStore = PopupState & PopupActions;
declare const usePopupStore: zustand.UseBoundStore<zustand.StoreApi<PopupStore>>;
interface PurchaseConfig {
defaultPageSize?: number;
defaultConfig?: string;
}
type PurchaseState = {
data: Purchase[];
isLoading: boolean;
error: ErrorResponse | null;
config: PurchaseConfig & {
defaultPageSize: number;
};
currentPage: number;
hasMore: boolean;
startDate?: string;
endDate?: string;
};
type PurchaseActions = {
fetchData: (startDate?: string, endDate?: string) => Promise<ServiceResponse<Purchase[]>>;
loadMore: () => Promise<ServiceResponse<Purchase[]>>;
clear: () => void;
updateConfig: (config: Partial<PurchaseConfig>) => void;
};
type PurchaseStore = PurchaseState & PurchaseActions;
declare const createPurchaseStore: (initialConfig: PurchaseConfig) => zustand.UseBoundStore<zustand.StoreApi<PurchaseStore>>;
type RegistrationFormData = {
username: string;
password: string;
confirmPassword: string;
contactNumber: string;
firstName: string;
lastName: string;
otp: string;
refCode: string;
address?: string;
gender?: string;
birthDate?: number;
email?: string;
refUserCode?: string;
zipCode?: string;
info?: string;
termAndConditionAccepted: boolean;
dataPrivacyAccepted: boolean;
marketingAccepted: boolean;
consentAge?: number;
consentAgeAccepted: boolean;
emailMarketingAccepted: boolean;
smsMarketingAccepted: boolean;
notificationMarketingAccepted: boolean;
lineMarketingAccepted: boolean;
phoneMarketingAccepted: boolean;
additionalInfo?: {
[key: string]: unknown;
};
};
type RegistrationState = {
form: RegistrationFormData;
consentVersion: {
termAndCondition: string;
dataPrivacy: string;
marketingOptions: string;
} | null;
otpExpireInSeconds: number;
isLoading: boolean;
error: ErrorResponse | null;
};
type RegistrationActions = {
updateForm: (updates: Partial<RegistrationFormData>) => void;
setError: (value: ErrorResponse | null) => void;
clearData: () => void;
sendOtp: () => Promise<ServiceResponse<OtpResponse>>;
validateOtp: () => Promise<ServiceResponse<ValidateOtpResponse>>;
validateRegister: () => Promise<ServiceResponse<OtpResponse>>;
register: () => Promise<ServiceResponse<RegistrationResponse>>;
setConsentVersion: (termAndCondition: string, dataPrivacy: string, marketingOptions: string) => void;
clear: () => void;
};
type RegistrationStore = RegistrationState & RegistrationActions;
declare const useRegistrationStore: zustand.UseBoundStore<zustand.StoreApi<RegistrationStore>>;
type ThirdPartyConnection = {
facebook: boolean;
google: boolean;
apple: boolean;
line: boolean;
};
type UpdateProfileParams = {
profileImage?: File | {
uri: string;
name: string;
type: string;
};
firstName?: string;
lastName?: string;
contactNumber?: string;
email?: string;
notification?: boolean;
locale?: number;
title?: string;
gender?: string;
birthDate?: number;
address?: string;
subdistrictCode?: number;
subdistrictName?: string;
districtCode?: number;
districtName?: string;
provinceCode?: number;
provinceName?: string;
countryCode?: string;
countryName?: string;
zipCode?: string;
idCard?: string;
passport?: string;
maritalStatus?: string;
village?: string;
building?: string;
number?: string;
moo?: string;
room?: string;
floor?: string;
soi?: string;
city?: string;
road?: string;
landmark?: string;
alternateContactNumber?: string;
homeContactNumber?: string;
nationality?: string;
religion?: string;
location?: string;
latitude?: number;
longitude?: number;
income?: string;
interests?: string;
region?: string;
phonepurchase?: number;
highestEducation?: string;
occupation?: string;
remark?: string;
displayName?: string;
options?: {
[key: string]: any;
};
};
type UserState = {
user: ProfileResponse | null;
points: number;
pointServiceBalance: {
[key: string]: number;
};
expiringPointService: {
[key: string]: {
date: string;
points: number;
}[];
};
recentPoints: number;
expiringPoints: UpdatedPoints[];
recentBadge: Badge | null;
recentTrace: Trace | null;
cartCount: number;
isLoading: boolean;
error: ErrorResponse | null;
imageError: ErrorResponse | null;
badgeList: Badge[];
traceList: Trace[];
thirdPartyConnection: ThirdPartyConnection;
};
type UserActions = {
fetchUser: () => Promise<ServiceResponse<ProfileResponse>>;
fetchPoint: () => Promise<{
pointResponse: ServiceResponse<UpdatedPoints>;
customPointsResponse: ServiceResponse<PointBalance[]>;
}>;
fetchExpiringPoints: () => Promise<ServiceResponse<ExpiringPoints>>;
fetchCartCount: () => Promise<ServiceResponse<CartCountResponse>>;
editUser: (data: UpdateProfileParams) => Promise<ServiceResponse<ProfileResponse>>;
changePassword: (oldPassword: string, newPassword: string) => Promise<ServiceResponse<StatusResponse>>;
changeContactNumber: (contactNumber: string, otp: string, refCode: string) => Promise<ServiceResponse<ConfirmOtpResponse>>;
changeAvatar: (avatar: File) => Promise<ServiceResponse<ProfileResponse>>;
consumeRecentPoints: () => void;
consumeRecentBadge: () => void;
consumeRecentTrace: () => void;
deleteUser: () => Promise<ServiceResponse<any>>;
setError: (error: ErrorResponse | null) => void;
clear: () => void;
setupEventListeners: () => void;
cleanupEventListeners: () => void;
};
type UserStore = UserState & UserActions;
declare const useUserStore: zustand.UseBoundStore<zustand.StoreApi<UserStore>>;
type ZipCodeDropDownItem = {
name: string;
id: string;
};
type ZipCodeState = {
zipCodes: ZipCode[];
provinceDropDownItems: ZipCodeDropDownItem[];
districtDropDownItems: ZipCodeDropDownItem[];
subDistrictDropDownItems: ZipCodeDropDownItem[];
selectedProvinceDropDownItem: ZipCodeDropDownItem | null;
selectedDistrictDropDownItem: ZipCodeDropDownItem | null;
selectedSubDistrictDropDownItem: ZipCodeDropDownItem | null;
isLoading: boolean;
error: ErrorResponse | null;
};
type ZipCodeActions = {
fetchZipCodes: (zipCode: string) => Promise<ServiceResponse<ZipCode[]>>;
setSelectedProvinceDropDownItem: (item: ZipCodeDropDownItem | null) => void;
setSelectedDistrictDropDownItem: (item: ZipCodeDropDownItem | null) => void;
setSelectedSubDistrictDropDownItem: (item: ZipCodeDropDownItem | null) => void;
clear: () => void;
};
type ZipCodeStore = ZipCodeState & ZipCodeActions;
declare const useZipCodeStore: zustand.UseBoundStore<zustand.StoreApi<ZipCodeStore>>;
declare const campaignType: {
draw: number;
free: number;
deal: number;
buy: number;
bid: number;
ads: number;
install: number;
booking: number;
interface: number;
event: number;
media: number;
ewalletTopUp: number;
ewalletRedeem: number;
ewalletTransfer: number;
ewalletBanking: number;
autofeed: number;
news: number;
reservation: number;
ewalletBuy: number;
pointRedemption: number;
donate: number;
pointFree: number;
voucher: number;
encrypt: number;
encryptRedeem: number;
giftCard: number;
verifyCode: number;
subscription: number;
fillCode: number;
subscriptionFood: number;
buyEVoucher: number;
uploadReceipt: number;
payWithPoints: number;
marketPlacePrivilege: number;
topup2C2P: number;
directTopup2C2P: number;
};
declare const campaignPointType: {
use: string;
get: string;
};
declare const campaignInterfaceType: {
web: string;
survey: string;
surveyApprove: string;
};
type LoginResponseHandler = (response: LoginResponse) => void;
type ErrorResponseHandler = (error: ErrorResponse) => void;
type ProfileImageSource = {
uri: string;
headers: {
[key: string]: unknown;
};
};
declare const eventEmitter: emittery__default<Record<PropertyKey, any>, Record<PropertyKey, any> & emittery.OmnipresentEventData, emittery.DatalessEventNames<Record<PropertyKey, any>>>;
declare function addDefaultHeaderInterceptor(axiosInstance: AxiosInstance, appId: string, subscriptionKey: string, tokenFunctions: TokenFunctions, apiVersion: string, corelationIdGenerator?: () => string): void;
declare function generateShortLivedId(): string;
declare function avatarUrl(baseUrl: string, appId: string, userId: string, token: string | null): string;
declare function largeImage(url: string): string;
declare function fetchImage(axiosClient: AxiosInstance, imageUrl: string): Promise<any>;
declare function createInterfaceWebsiteUrl(url: string, token?: string, returnUrl?: string, params?: {
[key: string]: any;
}): string;
declare function createInterfaceToken(token: string): string;
declare function createCartUrl(cartUrl: string, appName: string, accessKey: string, params?: {
[key: string]: any;
}): string;
declare function generateBlake2bSignatureHex(data: string, key: string, encoder: TextEncoder): string;
declare function getOtpSignatureHeaders({ appId, contactNumber, channel, encoder, now, }: {
appId: string;
contactNumber: string;
channel: string;
encoder: TextEncoder;
now?: Date;
}): {
'OTP-Signature': string;
Timestamp: number;
};
declare function addBlake2OtpSignatureInterceptor(axiosInstance: AxiosInstance, paths: string[], encoder: TextEncoder, getCurrentDateTime?: () => Date): void;
declare const getProfileImageSource: (baseUrl: string, appId: string, subscriptionKey: string, apiVersion: string, token: string, corelationIdGenerator?: () => string, timestamp?: number, type?: string) => ProfileImageSource;
/**
* Hook that provides access to the Zustand analytics store
*/
declare const useAnalyticsState: () => AnalyticsStore;
/**
* Utility function to track common events with immediate execution
*/
declare const trackCommonEvents: {
/**
* Track register success event
* Screen: register, Category: register, Event: register_success
*/
registerSuccess: (userInfo?: UserInfo) => Promise<void>;
/**
* Track login success event
* Screen: login, Category: login, Event: login_success
*/
loginSuccess: (userInfo?: UserInfo) => Promise<void>;
/**
* Track view campaign event
* Screen: campaign, Category: campaign_list, Event: view_campaign
*/
viewCampaign: (userInfo?: UserInfo) => Promise<void>;
/**
* Track redeem success event
* Screen: campaign, Category: campaign_redeem, Event: redeem_success
*/
redeemSuccess: (campaignId: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track unconsent success event
* Screen: marketing, Category: marketing_unconsent, Event: unconsent_success
*/
unconsentSuccess: (userInfo?: UserInfo) => Promise<void>;
/**
* Track button click event
*/
buttonClick: (buttonName: string, category?: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track form submit event
*/
formSubmit: (formName: string, success?: boolean, userInfo?: UserInfo) => Promise<void>;
/**
* Track search event
*/
search: (keyword: string, resultCount?: number, category?: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track purchase event
*/
purchase: (amount: number, currency?: string, productName?: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track user registration event
*/
userRegistration: (method?: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track user login event
*/
userLogin: (method?: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track error event
*/
error: (errorType: string, errorMessage?: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track custom event
*/
custom: (name: string, category: string, label?: string, value?: number, userInfo?: UserInfo) => Promise<void>;
};
/**
* Initialize analytics from anywhere in the app (useful for Zustand-only usage)
*/
declare const initializeAnalytics: (config: {
siteId: number;
urlBase: string;
trackerUrl?: string;
userId?: string;
disabled?: boolean;
log?: boolean;
}) => void;
/**
* Global analytics instance for direct usage without React hooks
*/
declare const analytics: {
/**
* Initialize analytics (can be called outside React components)
*/
init: (config: {
siteId: number;
urlBase: string;
trackerUrl?: string;
userId?: string;
disabled?: boolean;
log?: boolean;
}) => void;
/**
* Track event (can be called outside React components)
*/
trackEvent: (params: {
action: string;
name?: string;
category?: string;
value?: number;
campaign?: string;
userInfo?: UserInfo;
}) => Promise<void>;
/**
* Track screen view (can be called outside React components)
*/
trackScreenView: (name: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track app start (can be called outside React components)
*/
trackAppStart: (userInfo?: UserInfo) => Promise<void>;
/**
* Track site search (can be called outside React components)
*/
trackSiteSearch: (keyword: string, category?: string, count?: number, userInfo?: UserInfo) => Promise<void>;
/**
* Track link click (can be called outside React components)
*/
trackLink: (link: string, userInfo?: UserInfo) => Promise<void>;
/**
* Track download (can be called outside React components)
*/
trackDownload: (download: string, userInfo?: UserInfo) => Promise<void>;
/**
* Set user ID and update preset userInfo (can be called outside React components)
*/
setUserId: (userId: string | null) => void;
/**
* Set custom dimension (can be called outside React components)
*/
setCustomDimension: (id: number, value: string) => void;
/**
* Set preset user info (can be called outside React components)
*/
setPresetUserInfo: (userInfo: UserInfo) => void;
/**
* Clear preset user info (can be called outside React components)
*/
clearPresetUserInfo: () => void;
/**
* Enable/disable analytics (can be called outside React components)
*/
setEnabled: (enabled: boolean) => void;
/**
* Reset analytics (can be called outside React components)
*/
reset: () => void;
};
declare function isValidEmail(email: string): boolean;
type PurchaseItemInfo = {
title: string;
pointPerUnit: number;
expireDate: Date;
expiredIn?: number;
image: string;
showCode: boolean;
expired: boolean;
status: PurchaseItemStatus;
deliveryStatus: DeliveryStatus;
drawStatus: DrawStatus;
};
type PurchaseItemStatus = 'redeemed' | 'used' | 'expired';
type DeliveryStatus = null | 'packing' | 'shipping' | 'shipped';
type DrawStatus = null | 'draw_win' | 'draw_lose' | 'draw_waiting';
declare function getPurchaseItemStatus(item: Purchase): PurchaseItemInfo;
declare const localeToLCIDMap: {
[key: string]: number;
};
declare function findBestLocaleFromString(value: string): {
locale: string;
localeId: number;
};
export { type AddressActions, type AddressFormData, type AddressState, type AddressStore, type AfterRedeem, type AfterRedeemDestination, type AfterUse, type AlertActions, type AlertRequest, type AlertState, type AlertStore, type AnalyticsActions, type AnalyticsEventParams, type AnalyticsPageViewParams, type AnalyticsState, type AnalyticsStore, type AppLocale, type AppleLoginData, type AuthActions, type AuthState, type AuthStore, type AuthTokenType, type BuzzebeesAppActions, type BuzzebeesAppState, type BuzzebeesAppStore, type CampaignButtonType, type CampaignDetailActions, type CampaignDetailButtonState, type CampaignDetailState, type CampaignDetailStore, type CampaignState, type CampaignsActions, type CampaignsConfig, type CampaignsOptions, type CampaignsState, type CampaignsStore, type CartActions, type CartState, type CartStore, type CategoriesActions, type CategoriesConfig, type CategoriesState, type CategoriesStore, type ConfirmActions, type ConfirmRequest, type ConfirmState, type ConfirmStore, type ConsentActions, type ConsentState, type ConsentStore, type CouponActions, type CouponState, type CouponStore, type DashboardActions, type DashboardConfig, type DashboardState, type DashboardStore, type DeliveryStatus, type DrawStatus, EN, type ErrorResponseHandler, type FacebookLoginData, type FavoriteCampaignsActions, type FavoriteCampaignsConfig, type FavoriteCampaignsState, type FavoriteCampaignsStore, type GoogleLoginData, type LineLoginData, type LoadingIndicatorActions, type LoadingIndicatorState, type LoadingIndicatorStore, type LocaleActions, type LocaleState, type LocaleStore, type LoginResponseHandler, type MaintenanceActions, type MaintenanceState, type MaintenanceStore, type NotificationActions, type NotificationState, type NotificationStore, type PersonType, type PointLogActions, type PointLogConfig, type PointLogState, type PointLogStore, type PopupActions, type PopupRequest, type PopupState, type PopupStore, type ProfileImageSource, type PurchaseActions, type PurchaseConfig, type PurchaseItemInfo, type PurchaseItemStatus, type PurchaseState, type PurchaseStore, type RegistrationActions, type RegistrationFormData, type RegistrationState, type RegistrationStore, TH, type ThirdPartyConnection, type ThirdPartyLoginData, type TokenFunctions, type UpdateConsentParams, type UpdateProfileParams, type UserActions, type UserState, type UserStore, type ZipCodeActions, type ZipCodeDropDownItem, type ZipCodeState, type ZipCodeStore, addBlake2OtpSignatureInterceptor, addDefaultHeaderInterceptor, analytics, avatarUrl, campaignInterfaceType, campaignPointType, campaignType, createCampaignDetailStore, createCampaignsStore, createCartUrl, createCategoriesStore, createDashboardStore, createFavoriteCampaignsStore, createInterfaceToken, createPointLogStore, createPurchaseStore, eventEmitter, fetchImage, findBestLocaleFromString, generateBlake2bSignatureHex, generateShortLivedId, getOtpSignatureHeaders, getProfileImageSource, getPurchaseItemStatus, initializeAnalytics, createInterfaceWebsiteUrl as interfaceWebsite, isValidEmail, largeImage, localeToLCIDMap, trackCommonEvents, useAddressStore, useAlertStore, useAnalyticsState, useAnalyticsStore, useAuthStore, useBuzzebeesAppStore, useCartStore, useConfirmStore, useConsentStore, useCouponStore, useLoading, useLoadingIndicatorStore, useLocaleStore, useMaintenanceStore, useNotificationStore, usePopupStore, useRegistrationStore, useUserStore, useZipCodeStore };