@timardex/cluemart-shared 2.0.17 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ad-BaKxf-Rj.d.ts → ad-CUckkB7I.d.ts} +3 -3
- package/dist/{ad-B4hhLfL-.d.mts → ad-sqc3JME-.d.mts} +3 -3
- package/dist/{affiliate-Bv4PXBXC.d.mts → affiliate-7SDCo04C.d.mts} +2 -2
- package/dist/{affiliate-xDFlLdJI.d.ts → affiliate-C03r7ssL.d.ts} +2 -2
- package/dist/auth/index.d.mts +3 -3
- package/dist/auth/index.d.ts +3 -3
- package/dist/auth/index.mjs +4 -15
- package/dist/auth/index.mjs.map +1 -1
- package/dist/{chunk-RNHDFZIC.mjs → chunk-KUC252SN.mjs} +9 -5
- package/dist/chunk-KUC252SN.mjs.map +1 -0
- package/dist/chunk-N46DFZ3R.mjs +20 -0
- package/dist/chunk-N46DFZ3R.mjs.map +1 -0
- package/dist/{chunk-JESR7H4R.mjs → chunk-PIEXGXTD.mjs} +1 -1
- package/dist/chunk-PIEXGXTD.mjs.map +1 -0
- package/dist/chunk-RE4NZPYY.mjs +43 -0
- package/dist/chunk-RE4NZPYY.mjs.map +1 -0
- package/dist/{chunk-5G3MQXQX.mjs → chunk-YPT2VOTM.mjs} +2 -2
- package/dist/{contactUs-DtKFwekV.d.ts → contactUs-BG3sJ6gc.d.ts} +1 -1
- package/dist/{contactUs-0IhAsiDW.d.mts → contactUs-CWFP59_0.d.mts} +1 -1
- package/dist/formFields/index.cjs.map +1 -1
- package/dist/formFields/index.d.mts +1 -1
- package/dist/formFields/index.d.ts +1 -1
- package/dist/formFields/index.mjs +3 -2
- package/dist/{global-C6w0hQ5Y.d.mts → global-BqeTWrvk.d.ts} +4 -1
- package/dist/{global-Coz5Jgi2.d.ts → global-CWo-hWKZ.d.mts} +4 -1
- package/dist/graphql/index.cjs +8 -4
- package/dist/graphql/index.cjs.map +1 -1
- package/dist/graphql/index.d.mts +6 -6
- package/dist/graphql/index.d.ts +6 -6
- package/dist/graphql/index.mjs +1 -1
- package/dist/hooks/index.cjs +6 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.mts +5 -5
- package/dist/hooks/index.d.ts +5 -5
- package/dist/hooks/index.mjs +4 -3
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.cjs +51 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.mjs +48 -4
- package/dist/index.mjs.map +1 -1
- package/dist/map/index.d.mts +1 -1
- package/dist/map/index.d.ts +1 -1
- package/dist/region/index.cjs +290 -0
- package/dist/region/index.cjs.map +1 -0
- package/dist/region/index.d.mts +36 -0
- package/dist/region/index.d.ts +36 -0
- package/dist/region/index.mjs +220 -0
- package/dist/region/index.mjs.map +1 -0
- package/dist/{resourceActivities-DScv6fiM.d.ts → resourceActivities-BbhGFtZA.d.ts} +1 -1
- package/dist/{resourceActivities-DIK3bwZg.d.mts → resourceActivities-D81u7Mu0.d.mts} +1 -1
- package/dist/sharing/index.d.mts +1 -1
- package/dist/sharing/index.d.ts +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.mts +7 -7
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.mjs +1 -1
- package/dist/{user-DhxdbFT7.d.ts → user-2peJoOeK.d.ts} +1 -1
- package/dist/{user-BwcVKK-h.d.mts → user-DKcyf8gn.d.mts} +1 -1
- package/dist/utils/index.cjs +43 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +8 -4
- package/dist/utils/index.d.ts +8 -4
- package/dist/utils/index.mjs +10 -2
- package/package.json +6 -1
- package/dist/chunk-JESR7H4R.mjs.map +0 -1
- package/dist/chunk-RNHDFZIC.mjs.map +0 -1
- /package/dist/{chunk-5G3MQXQX.mjs.map → chunk-YPT2VOTM.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnumPartnerType, EnumResourceType, EnumOSPlatform } from './enums/index.js';
|
|
2
|
-
import { Q as BaseResourceType, L as LocationType, B as BaseResourceTypeFormData, a2 as CreateFormData, aQ as ResourceContactDetailsType, aS as ResourceImageType, aT as SocialMediaType, aX as TermsAgreement, aq as OwnerType, aH as PromoCodeType, M as MutationResponse } from './global-
|
|
2
|
+
import { Q as BaseResourceType, L as LocationType, B as BaseResourceTypeFormData, a2 as CreateFormData, aQ as ResourceContactDetailsType, aS as ResourceImageType, aT as SocialMediaType, aX as TermsAgreement, aq as OwnerType, aH as PromoCodeType, M as MutationResponse } from './global-BqeTWrvk.js';
|
|
3
3
|
import { PosterAssetId } from './images/index.js';
|
|
4
|
-
import { S as SafeUserType, e as UserFormData } from './user-
|
|
4
|
+
import { S as SafeUserType, e as UserFormData } from './user-2peJoOeK.js';
|
|
5
5
|
|
|
6
6
|
interface PartnerFormData extends BaseResourceTypeFormData {
|
|
7
7
|
location: LocationType;
|
|
@@ -256,4 +256,4 @@ type AdSettingsType = {
|
|
|
256
256
|
rotationSeconds: number;
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
-
export { type AuthMutationResponse as A,
|
|
259
|
+
export { type AuthMutationResponse as A, EnumAdApprovalStatus as B, type CreateLoginFormData as C, EnumAdBookingSlotKind as D, EnumAdPlatform as E, EnumAdBookingState as F, EnumAdEntitlementSource as G, EnumAdPaymentStatus as H, EnumAdStatus as I, EnumAdStyle as J, EnumAdType as K, EnumVerificationType as L, type LoginFormData as M, type MarketingMaterialRequestInputType as N, type PosterInputType as O, type PartnerType as P, type RefreshTokenPayloadType as Q, type RefreshTokenMutationResponse as R, type SchoolType as S, type RegisterFormData as T, type RequestPasswordResetFormData as U, type ResetPasswordFormData as V, type SchoolCampaignType as W, type SchoolRegisteredUserType as X, type ValidateVerificationTokenFormData as Y, type AdType as a, EnumAdShowOn as b, type AppSettingsType as c, type SchoolReturnType as d, type CreateRegisterFormData as e, type CreateRequestPasswordResetFormData as f, type CreateValidateVerificationTokenFormData as g, type CreateResetPasswordFormData as h, type PartnerFormData as i, type AdFormData as j, type CreateAdFormState as k, type CreatePartnerFormData as l, type AppSettingsFormData as m, type CreateAppSettingsFormData as n, type SchoolFormData as o, type CreateSchoolFormData as p, type AdBookingType as q, type AdDailyPriceKey as r, type AdDailyPriceType as s, type AdFormState as t, type AdPlacement as u, type AdResource as v, type AdSettingsFormData as w, type AdSettingsType as x, type AuthPayloadType as y, type CreateAdFormData as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnumPartnerType, EnumResourceType, EnumOSPlatform } from './enums/index.mjs';
|
|
2
|
-
import { Q as BaseResourceType, L as LocationType, B as BaseResourceTypeFormData, a2 as CreateFormData, aQ as ResourceContactDetailsType, aS as ResourceImageType, aT as SocialMediaType, aX as TermsAgreement, aq as OwnerType, aH as PromoCodeType, M as MutationResponse } from './global-
|
|
2
|
+
import { Q as BaseResourceType, L as LocationType, B as BaseResourceTypeFormData, a2 as CreateFormData, aQ as ResourceContactDetailsType, aS as ResourceImageType, aT as SocialMediaType, aX as TermsAgreement, aq as OwnerType, aH as PromoCodeType, M as MutationResponse } from './global-CWo-hWKZ.mjs';
|
|
3
3
|
import { PosterAssetId } from './images/index.mjs';
|
|
4
|
-
import { S as SafeUserType, e as UserFormData } from './user-
|
|
4
|
+
import { S as SafeUserType, e as UserFormData } from './user-DKcyf8gn.mjs';
|
|
5
5
|
|
|
6
6
|
interface PartnerFormData extends BaseResourceTypeFormData {
|
|
7
7
|
location: LocationType;
|
|
@@ -256,4 +256,4 @@ type AdSettingsType = {
|
|
|
256
256
|
rotationSeconds: number;
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
-
export { type AuthMutationResponse as A,
|
|
259
|
+
export { type AuthMutationResponse as A, EnumAdApprovalStatus as B, type CreateLoginFormData as C, EnumAdBookingSlotKind as D, EnumAdPlatform as E, EnumAdBookingState as F, EnumAdEntitlementSource as G, EnumAdPaymentStatus as H, EnumAdStatus as I, EnumAdStyle as J, EnumAdType as K, EnumVerificationType as L, type LoginFormData as M, type MarketingMaterialRequestInputType as N, type PosterInputType as O, type PartnerType as P, type RefreshTokenPayloadType as Q, type RefreshTokenMutationResponse as R, type SchoolType as S, type RegisterFormData as T, type RequestPasswordResetFormData as U, type ResetPasswordFormData as V, type SchoolCampaignType as W, type SchoolRegisteredUserType as X, type ValidateVerificationTokenFormData as Y, type AdType as a, EnumAdShowOn as b, type AppSettingsType as c, type SchoolReturnType as d, type CreateRegisterFormData as e, type CreateRequestPasswordResetFormData as f, type CreateValidateVerificationTokenFormData as g, type CreateResetPasswordFormData as h, type PartnerFormData as i, type AdFormData as j, type CreateAdFormState as k, type CreatePartnerFormData as l, type AppSettingsFormData as m, type CreateAppSettingsFormData as n, type SchoolFormData as o, type CreateSchoolFormData as p, type AdBookingType as q, type AdDailyPriceKey as r, type AdDailyPriceType as s, type AdFormState as t, type AdPlacement as u, type AdResource as v, type AdSettingsFormData as w, type AdSettingsType as x, type AuthPayloadType as y, type CreateAdFormData as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnumResourceType } from './enums/index.mjs';
|
|
2
|
-
import { aH as PromoCodeType, L as LocationType, aT as SocialMediaType, aq as OwnerType, a2 as CreateFormData } from './global-
|
|
3
|
-
import { e as UserFormData } from './user-
|
|
2
|
+
import { aH as PromoCodeType, L as LocationType, aT as SocialMediaType, aq as OwnerType, a2 as CreateFormData } from './global-CWo-hWKZ.mjs';
|
|
3
|
+
import { e as UserFormData } from './user-DKcyf8gn.mjs';
|
|
4
4
|
|
|
5
5
|
declare enum EnumAffiliateParticipantType {
|
|
6
6
|
INDIVIDUAL = "INDIVIDUAL",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnumResourceType } from './enums/index.js';
|
|
2
|
-
import { aH as PromoCodeType, L as LocationType, aT as SocialMediaType, aq as OwnerType, a2 as CreateFormData } from './global-
|
|
3
|
-
import { e as UserFormData } from './user-
|
|
2
|
+
import { aH as PromoCodeType, L as LocationType, aT as SocialMediaType, aq as OwnerType, a2 as CreateFormData } from './global-BqeTWrvk.js';
|
|
3
|
+
import { e as UserFormData } from './user-2peJoOeK.js';
|
|
4
4
|
|
|
5
5
|
declare enum EnumAffiliateParticipantType {
|
|
6
6
|
INDIVIDUAL = "INDIVIDUAL",
|
package/dist/auth/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EnumUserRole, EnumResourceType, EnumUserLicence } from '../enums/index.mjs';
|
|
2
|
-
import { P as Permission, S as SafeUserType } from '../user-
|
|
3
|
-
export { a as PERMISSIONS, W as WILDCARD_PERMISSION } from '../user-
|
|
2
|
+
import { P as Permission, S as SafeUserType } from '../user-DKcyf8gn.mjs';
|
|
3
|
+
export { a as PERMISSIONS, W as WILDCARD_PERMISSION } from '../user-DKcyf8gn.mjs';
|
|
4
4
|
import { T as Tier } from '../subscription-bmAdrnfi.mjs';
|
|
5
5
|
import React, { ReactNode } from 'react';
|
|
6
|
-
import '../global-
|
|
6
|
+
import '../global-CWo-hWKZ.mjs';
|
|
7
7
|
import 'react-hook-form';
|
|
8
8
|
|
|
9
9
|
type AuthManager = {
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EnumUserRole, EnumResourceType, EnumUserLicence } from '../enums/index.js';
|
|
2
|
-
import { P as Permission, S as SafeUserType } from '../user-
|
|
3
|
-
export { a as PERMISSIONS, W as WILDCARD_PERMISSION } from '../user-
|
|
2
|
+
import { P as Permission, S as SafeUserType } from '../user-2peJoOeK.js';
|
|
3
|
+
export { a as PERMISSIONS, W as WILDCARD_PERMISSION } from '../user-2peJoOeK.js';
|
|
4
4
|
import { T as Tier } from '../subscription-BU8GvH2K.js';
|
|
5
5
|
import React, { ReactNode } from 'react';
|
|
6
|
-
import '../global-
|
|
6
|
+
import '../global-BqeTWrvk.js';
|
|
7
7
|
import 'react-hook-form';
|
|
8
8
|
|
|
9
9
|
type AuthManager = {
|
package/dist/auth/index.mjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
UserProvider,
|
|
4
|
+
useAuthUser
|
|
5
|
+
} from "../chunk-N46DFZ3R.mjs";
|
|
2
6
|
import {
|
|
3
7
|
ADMIN_APP_ROLES,
|
|
4
8
|
ADMIN_DASHBOARD_CONTEXTS,
|
|
@@ -333,21 +337,6 @@ function useAuthCore(adapters) {
|
|
|
333
337
|
setUser: handleSetAuthUser
|
|
334
338
|
};
|
|
335
339
|
}
|
|
336
|
-
|
|
337
|
-
// src/auth/UserProvider.tsx
|
|
338
|
-
import { createContext, useContext } from "react";
|
|
339
|
-
import { jsx } from "react/jsx-runtime";
|
|
340
|
-
var UserContext = createContext(void 0);
|
|
341
|
-
var UserProvider = ({ children, value }) => {
|
|
342
|
-
return /* @__PURE__ */ jsx(UserContext.Provider, { value, children });
|
|
343
|
-
};
|
|
344
|
-
var useAuthUser = () => {
|
|
345
|
-
const context = useContext(UserContext);
|
|
346
|
-
if (!context) {
|
|
347
|
-
throw new Error("useAuthUser must be used within a UserProvider");
|
|
348
|
-
}
|
|
349
|
-
return context;
|
|
350
|
-
};
|
|
351
340
|
export {
|
|
352
341
|
ADMIN_APP_ROLES,
|
|
353
342
|
ADMIN_DASHBOARD_CONTEXTS,
|
package/dist/auth/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/createAuthManager.ts","../../src/auth/licenceUtils.ts","../../src/auth/useAuthCore.ts","../../src/auth/UserProvider.tsx"],"sourcesContent":["export type AuthManager = {\n logout: () => Promise<void>;\n setLogout: (fn: () => Promise<void>) => void;\n handleRefetchUser: () => Promise<void>;\n setUserRefetch: (fn: () => Promise<void>) => void;\n};\n\n/**\n * Creates an auth manager used by Apollo error links to trigger logout/refetch\n * without importing React. Matches the former mobile authManager shape.\n *\n * `logout()` dedupes concurrent calls via an in-flight promise so token-refresh\n * failures do not kick off multiple logout sequences.\n */\nexport function createAuthManager(): AuthManager {\n let logoutFn: (() => Promise<void>) | null = null;\n let userRefetchFn: (() => Promise<void>) | null = null;\n let logoutPromise: Promise<void> | null = null;\n\n return {\n handleRefetchUser: async () => {\n if (userRefetchFn) {\n await userRefetchFn();\n } else {\n console.warn(\"❌ User refetch function not set!\");\n }\n },\n logout(): Promise<void> {\n if (logoutPromise !== null) return logoutPromise;\n if (logoutFn === null) {\n console.warn(\"❌ Logout function not set!\");\n return Promise.resolve();\n }\n logoutPromise = logoutFn().finally(() => {\n logoutPromise = null;\n });\n return logoutPromise;\n },\n setLogout(fn: () => Promise<void>) {\n logoutFn = fn;\n },\n setUserRefetch(fn: () => Promise<void>) {\n userRefetchFn = fn;\n },\n };\n}\n","/* eslint-disable camelcase */\nimport { EnumResourceType, EnumUserLicence } from \"../enums\";\nimport type { SafeUserType } from \"../types\";\nimport { TIERS_BY_PRIORITY, type Tier } from \"../types/subscription\";\n\nimport type {\n HasLicenceResult,\n LicencedResourceType,\n LicencesByRole,\n LimitType,\n ProfileBadgeLicence,\n RoleLicences,\n} from \"./types\";\n\nexport function isLicencedResourceType(\n resourceType: EnumResourceType,\n): resourceType is LicencedResourceType {\n return (\n resourceType !== EnumResourceType.AFFILIATE &&\n resourceType !== EnumResourceType.SCHOOL\n );\n}\n\nexport function isProfileBadgeLicence(\n licenceType: EnumUserLicence,\n): licenceType is ProfileBadgeLicence {\n return (\n licenceType !== EnumUserLicence.STANDARD_AFFILIATE &&\n licenceType !== EnumUserLicence.STANDARD_SCHOOL\n );\n}\n\nexport const hasUserLicenceType = (\n authUser: SafeUserType | null,\n licenceType: EnumUserLicence,\n): boolean =>\n authUser?.licences?.some((licence) => licence.licenceType === licenceType) ??\n false;\n\nexport const hasLicence = (\n authUser: SafeUserType | null,\n licenceType: \"vendor\" | \"partner\" | \"event\",\n): HasLicenceResult => {\n const directLicence =\n authUser?.licences?.some((licence) =>\n licence.licenceType?.includes(licenceType),\n ) ?? false;\n\n return {\n directLicence,\n };\n};\n\n/** Default limits per subscription tier. */\nexport const DEFAULT_LIMITS: Record<LimitType, Record<Tier, number>> = {\n // 1 means calendar/productMenu is enabled, 0 means disabled\n availability: { pro: 1, pro_plus: 1, standard: 0 },\n calendar: { pro: 1, pro_plus: 1, standard: 0 },\n coupons: { pro: 1, pro_plus: 1, standard: 0 },\n images: { pro: 12, pro_plus: 12, standard: 6 },\n posters: { pro: 5, pro_plus: 5, standard: 5 },\n productsList: { pro: 1, pro_plus: 1, standard: 0 },\n relationShare: { pro: 1, pro_plus: 1, standard: 0 },\n statistics: { pro: 1, pro_plus: 1, standard: 0 },\n};\n\n/** All tiers off — used when the viewer does not own the resource. */\nexport const NO_LICENCE_FLAGS: LicencesByRole = {\n event: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n partner: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n vendor: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n};\n\n/**\n * Parses an array of licence strings into structured, role-based licences.\n * Users with no licences yet default to pro (create / trial access).\n */\nexport function getLicenceFlagsByRole(licences?: string[]): LicencesByRole {\n const normalized = licences?.map((l) => l.toLowerCase()) ?? [];\n const hasAnyLicence = normalized.length > 0;\n\n function resolve(role: EnumResourceType): RoleLicences {\n const result: RoleLicences = {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n };\n\n for (const tier of TIERS_BY_PRIORITY) {\n if (normalized.some((l) => l.startsWith(`${tier}_${role}`))) {\n result[tier] = true;\n break; // stop at first match → ensures mutual exclusivity\n }\n }\n\n // No licences at all → grant pro so new users can use pro features\n if (!hasAnyLicence) {\n result.pro = true;\n }\n\n return result;\n }\n\n return {\n event: resolve(EnumResourceType.EVENT),\n partner: resolve(EnumResourceType.PARTNER),\n vendor: resolve(EnumResourceType.VENDOR),\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\n\nimport { EnumResourceType, EnumUserLicence, EnumUserRole } from \"../enums\";\nimport { useLogout } from \"../graphql/hooks/auth\";\nimport { useGetUser } from \"../graphql/hooks/user/hooksQuery\";\nimport { USER_STORAGE_KEY } from \"../storage\";\nimport type { SafeUserType } from \"../types\";\n\nimport {\n DEFAULT_LIMITS,\n getLicenceFlagsByRole,\n hasLicence,\n hasUserLicenceType,\n isLicencedResourceType,\n NO_LICENCE_FLAGS,\n} from \"./licenceUtils\";\nimport {\n getPermissionsForRoles,\n hasRole as roleHasRole,\n permissionListIncludes,\n} from \"./permissions\";\nimport type { Permission } from \"./permissions\";\nimport type {\n LimitType,\n LogoutReason,\n UseAuthCoreAdapters,\n UseAuthReturnType,\n} from \"./types\";\n\n/**\n * Platform-agnostic auth session core (source of truth for shared useAuth).\n *\n * Owns: persisted user load/set, refetch, role/licence flags, logout orchestration.\n * Does not own: AsyncStorage vs localStorage, Expo/Next navigation, toasts,\n * Apollo/WS reset, Firebase — those stay in each app's adapter wrapper.\n */\nexport function useAuthCore(adapters: UseAuthCoreAdapters): UseAuthReturnType {\n const {\n storage,\n authManager,\n afterLogout,\n shouldCallLogoutMutation = () => true,\n notifyLogoutSuccess,\n notifySessionExpired,\n onError,\n } = adapters;\n\n const [authUser, setAuthUser] = useState<SafeUserType | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n\n const userId = useMemo(() => authUser?._id ?? \"\", [authUser?._id]);\n const { refetch } = useGetUser(userId);\n const { logout, loading } = useLogout();\n\n const handleSetAuthUser = useCallback(\n async (user: SafeUserType | null) => {\n setAuthUser(user);\n if (user) {\n await storage.setItem(USER_STORAGE_KEY, JSON.stringify(user));\n } else {\n await storage.removeItem(USER_STORAGE_KEY);\n }\n },\n [storage],\n );\n\n const handleRefetchUser = useCallback(async () => {\n if (!authUser) return;\n try {\n const result = await refetch();\n if (!result) return;\n const { data } = result;\n if (data?.user) await handleSetAuthUser(data.user);\n } catch (error: unknown) {\n onError?.(error, { action: \"refetchUser\" });\n console.warn(\n \"Failed to refetch user:\",\n error instanceof Error ? error.message : error,\n );\n }\n }, [authUser, handleSetAuthUser, onError, refetch]);\n\n const licences = useCallback(\n (resourceId: string) => {\n const myLicences =\n authUser?.licences?.map((licence) => licence.licenceType) ?? [];\n\n const myResourceIds = [\n authUser?.vendor ?? null,\n authUser?.partner ?? null,\n ...(authUser?.events ?? []),\n ].filter((id): id is string => id !== null);\n\n return myResourceIds.includes(resourceId)\n ? getLicenceFlagsByRole(myLicences)\n : NO_LICENCE_FLAGS;\n },\n [authUser],\n );\n\n const getLicenseAccessLevel = useCallback(\n (\n limitType: LimitType,\n resourceId: string,\n resourceType: EnumResourceType,\n ): number => {\n if (!isLicencedResourceType(resourceType)) {\n return 0;\n }\n\n // No resource yet (e.g. create flow): grant pro limits.\n if (resourceId === \"\") {\n return DEFAULT_LIMITS[limitType].pro;\n }\n\n const roleLicences = licences(resourceId)[resourceType];\n\n if (roleLicences.pro_plus) return DEFAULT_LIMITS[limitType].pro_plus;\n if (roleLicences.pro) return DEFAULT_LIMITS[limitType].pro;\n if (roleLicences.standard) return DEFAULT_LIMITS[limitType].standard;\n\n return 0;\n },\n [licences],\n );\n\n const hasVendorLicence = useMemo(\n () => hasLicence(authUser, \"vendor\"),\n [authUser],\n );\n\n const hasPartnerLicence = useMemo(\n () => hasLicence(authUser, \"partner\"),\n [authUser],\n );\n\n const hasEventLicence = useMemo(\n () => hasLicence(authUser, \"event\"),\n [authUser],\n );\n\n const hasUserLicence = useCallback(\n (licenceType: EnumUserLicence) => hasUserLicenceType(authUser, licenceType),\n [authUser],\n );\n\n const permissions = useMemo(() => {\n if (authUser?.permissions != null) {\n return authUser.permissions;\n }\n return getPermissionsForRoles(authUser?.roles);\n }, [authUser?.permissions, authUser?.roles]);\n\n const hasPermissionFn = useCallback(\n (permission: Permission) => permissionListIncludes(permissions, permission),\n [permissions],\n );\n\n const hasRoleFn = useCallback(\n (role: EnumUserRole) => roleHasRole(authUser?.roles, role),\n [authUser?.roles],\n );\n\n const isAdmin = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.ADMIN) ||\n permissionListIncludes(permissions, \"dashboard.admin\") ||\n permissionListIncludes(permissions, \"*\"),\n [authUser?.roles, permissions],\n );\n\n const isSuperAdmin = useMemo(\n () => roleHasRole(authUser?.roles, EnumUserRole.SUPER_ADMIN),\n [authUser?.roles],\n );\n\n const isAffiliate = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.AFFILIATE) &&\n authUser?.affiliate !== null &&\n authUser?.affiliate !== undefined,\n [authUser?.roles, authUser?.affiliate],\n );\n\n const isSchool = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.SCHOOL) &&\n authUser?.school !== null &&\n authUser?.school !== undefined,\n [authUser?.roles, authUser?.school],\n );\n\n // Mount-only hydrate from storage. Do not re-run when adapter identities\n // change — that can overwrite a newer in-memory user (e.g. post-login setUser).\n useEffect(() => {\n const loadUser = async () => {\n try {\n const userJson = await storage.getItem(USER_STORAGE_KEY);\n await handleSetAuthUser(userJson ? JSON.parse(userJson) : null);\n } catch (error: unknown) {\n onError?.(error, { action: \"loadUserFromStorage\" });\n console.error(\"Failed to load user from storage:\", error);\n } finally {\n setIsLoading(false);\n }\n };\n\n void loadUser();\n }, []);\n\n const logoutWithReason = useCallback(\n async (reason: LogoutReason) => {\n try {\n if (shouldCallLogoutMutation(reason)) {\n try {\n const result = await logout();\n const message = result?.data?.logout?.message as string | undefined;\n if (message) {\n notifyLogoutSuccess?.(message);\n }\n } catch (err: unknown) {\n onError?.(err, { action: \"logout\" });\n console.warn(\"Logout request failed (ignored):\", err);\n }\n }\n } finally {\n await afterLogout(reason);\n setAuthUser(null);\n await storage.removeItem(USER_STORAGE_KEY);\n }\n },\n [\n afterLogout,\n logout,\n notifyLogoutSuccess,\n onError,\n shouldCallLogoutMutation,\n storage,\n ],\n );\n\n const handleLogoutExplicit = useCallback(\n () => logoutWithReason(\"manual\"),\n [logoutWithReason],\n );\n\n const handleLogoutExpired = useCallback(async () => {\n const hadSession = authUser != null;\n if (!hadSession) return;\n await logoutWithReason(\"expired\");\n notifySessionExpired?.();\n }, [authUser, logoutWithReason, notifySessionExpired]);\n\n useEffect(() => {\n authManager.setLogout(() => handleLogoutExpired());\n authManager.setUserRefetch(() => handleRefetchUser());\n }, [authManager, handleLogoutExpired, handleRefetchUser]);\n\n return {\n authUser,\n getLicenseAccessLevel,\n handleLogoutExplicit,\n hasEventLicence,\n hasPartnerLicence,\n hasPermission: hasPermissionFn,\n hasRole: hasRoleFn,\n hasUserLicence,\n hasVendorLicence,\n isAdmin,\n isAffiliate,\n isLoading: loading || isLoading,\n isSchool,\n isSuperAdmin,\n permissions,\n refetchUser: handleRefetchUser,\n setUser: handleSetAuthUser,\n };\n}\n","/**\n * Shared React context for auth session state.\n *\n * Apps keep a thin local UserProvider that calls their platform `useAuth`\n * (adapters) and pass the result here as `value`. Import `useAuthUser` from\n * this module (or re-export it) so consumers share one context instance.\n *\n * `\"use client\"`: required for Next.js; ignored by React Native.\n */\n\"use client\";\n\nimport React, { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { UseAuthReturnType } from \"./types\";\n\nconst UserContext = createContext<UseAuthReturnType | undefined>(undefined);\n\n/**\n * Provides auth session value from the app's thin useAuth wrapper.\n */\nexport const UserProvider: React.FC<{\n children: ReactNode;\n value: UseAuthReturnType;\n}> = ({ children, value }) => {\n return <UserContext.Provider value={value}>{children}</UserContext.Provider>;\n};\n\nexport const useAuthUser = (): UseAuthReturnType => {\n const context = useContext(UserContext);\n if (!context) {\n throw new Error(\"useAuthUser must be used within a UserProvider\");\n }\n return context;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,oBAAiC;AAC/C,MAAI,WAAyC;AAC7C,MAAI,gBAA8C;AAClD,MAAI,gBAAsC;AAE1C,SAAO;AAAA,IACL,mBAAmB,YAAY;AAC7B,UAAI,eAA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AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/auth/createAuthManager.ts","../../src/auth/licenceUtils.ts","../../src/auth/useAuthCore.ts"],"sourcesContent":["export type AuthManager = {\n logout: () => Promise<void>;\n setLogout: (fn: () => Promise<void>) => void;\n handleRefetchUser: () => Promise<void>;\n setUserRefetch: (fn: () => Promise<void>) => void;\n};\n\n/**\n * Creates an auth manager used by Apollo error links to trigger logout/refetch\n * without importing React. Matches the former mobile authManager shape.\n *\n * `logout()` dedupes concurrent calls via an in-flight promise so token-refresh\n * failures do not kick off multiple logout sequences.\n */\nexport function createAuthManager(): AuthManager {\n let logoutFn: (() => Promise<void>) | null = null;\n let userRefetchFn: (() => Promise<void>) | null = null;\n let logoutPromise: Promise<void> | null = null;\n\n return {\n handleRefetchUser: async () => {\n if (userRefetchFn) {\n await userRefetchFn();\n } else {\n console.warn(\"❌ User refetch function not set!\");\n }\n },\n logout(): Promise<void> {\n if (logoutPromise !== null) return logoutPromise;\n if (logoutFn === null) {\n console.warn(\"❌ Logout function not set!\");\n return Promise.resolve();\n }\n logoutPromise = logoutFn().finally(() => {\n logoutPromise = null;\n });\n return logoutPromise;\n },\n setLogout(fn: () => Promise<void>) {\n logoutFn = fn;\n },\n setUserRefetch(fn: () => Promise<void>) {\n userRefetchFn = fn;\n },\n };\n}\n","/* eslint-disable camelcase */\nimport { EnumResourceType, EnumUserLicence } from \"../enums\";\nimport type { SafeUserType } from \"../types\";\nimport { TIERS_BY_PRIORITY, type Tier } from \"../types/subscription\";\n\nimport type {\n HasLicenceResult,\n LicencedResourceType,\n LicencesByRole,\n LimitType,\n ProfileBadgeLicence,\n RoleLicences,\n} from \"./types\";\n\nexport function isLicencedResourceType(\n resourceType: EnumResourceType,\n): resourceType is LicencedResourceType {\n return (\n resourceType !== EnumResourceType.AFFILIATE &&\n resourceType !== EnumResourceType.SCHOOL\n );\n}\n\nexport function isProfileBadgeLicence(\n licenceType: EnumUserLicence,\n): licenceType is ProfileBadgeLicence {\n return (\n licenceType !== EnumUserLicence.STANDARD_AFFILIATE &&\n licenceType !== EnumUserLicence.STANDARD_SCHOOL\n );\n}\n\nexport const hasUserLicenceType = (\n authUser: SafeUserType | null,\n licenceType: EnumUserLicence,\n): boolean =>\n authUser?.licences?.some((licence) => licence.licenceType === licenceType) ??\n false;\n\nexport const hasLicence = (\n authUser: SafeUserType | null,\n licenceType: \"vendor\" | \"partner\" | \"event\",\n): HasLicenceResult => {\n const directLicence =\n authUser?.licences?.some((licence) =>\n licence.licenceType?.includes(licenceType),\n ) ?? false;\n\n return {\n directLicence,\n };\n};\n\n/** Default limits per subscription tier. */\nexport const DEFAULT_LIMITS: Record<LimitType, Record<Tier, number>> = {\n // 1 means calendar/productMenu is enabled, 0 means disabled\n availability: { pro: 1, pro_plus: 1, standard: 0 },\n calendar: { pro: 1, pro_plus: 1, standard: 0 },\n coupons: { pro: 1, pro_plus: 1, standard: 0 },\n images: { pro: 12, pro_plus: 12, standard: 6 },\n posters: { pro: 5, pro_plus: 5, standard: 5 },\n productsList: { pro: 1, pro_plus: 1, standard: 0 },\n relationShare: { pro: 1, pro_plus: 1, standard: 0 },\n statistics: { pro: 1, pro_plus: 1, standard: 0 },\n};\n\n/** All tiers off — used when the viewer does not own the resource. */\nexport const NO_LICENCE_FLAGS: LicencesByRole = {\n event: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n partner: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n vendor: {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n },\n};\n\n/**\n * Parses an array of licence strings into structured, role-based licences.\n * Users with no licences yet default to pro (create / trial access).\n */\nexport function getLicenceFlagsByRole(licences?: string[]): LicencesByRole {\n const normalized = licences?.map((l) => l.toLowerCase()) ?? [];\n const hasAnyLicence = normalized.length > 0;\n\n function resolve(role: EnumResourceType): RoleLicences {\n const result: RoleLicences = {\n pro_plus: false,\n // eslint-disable-next-line sort-keys\n pro: false,\n standard: false,\n };\n\n for (const tier of TIERS_BY_PRIORITY) {\n if (normalized.some((l) => l.startsWith(`${tier}_${role}`))) {\n result[tier] = true;\n break; // stop at first match → ensures mutual exclusivity\n }\n }\n\n // No licences at all → grant pro so new users can use pro features\n if (!hasAnyLicence) {\n result.pro = true;\n }\n\n return result;\n }\n\n return {\n event: resolve(EnumResourceType.EVENT),\n partner: resolve(EnumResourceType.PARTNER),\n vendor: resolve(EnumResourceType.VENDOR),\n };\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\n\nimport { EnumResourceType, EnumUserLicence, EnumUserRole } from \"../enums\";\nimport { useLogout } from \"../graphql/hooks/auth\";\nimport { useGetUser } from \"../graphql/hooks/user/hooksQuery\";\nimport { USER_STORAGE_KEY } from \"../storage\";\nimport type { SafeUserType } from \"../types\";\n\nimport {\n DEFAULT_LIMITS,\n getLicenceFlagsByRole,\n hasLicence,\n hasUserLicenceType,\n isLicencedResourceType,\n NO_LICENCE_FLAGS,\n} from \"./licenceUtils\";\nimport {\n getPermissionsForRoles,\n hasRole as roleHasRole,\n permissionListIncludes,\n} from \"./permissions\";\nimport type { Permission } from \"./permissions\";\nimport type {\n LimitType,\n LogoutReason,\n UseAuthCoreAdapters,\n UseAuthReturnType,\n} from \"./types\";\n\n/**\n * Platform-agnostic auth session core (source of truth for shared useAuth).\n *\n * Owns: persisted user load/set, refetch, role/licence flags, logout orchestration.\n * Does not own: AsyncStorage vs localStorage, Expo/Next navigation, toasts,\n * Apollo/WS reset, Firebase — those stay in each app's adapter wrapper.\n */\nexport function useAuthCore(adapters: UseAuthCoreAdapters): UseAuthReturnType {\n const {\n storage,\n authManager,\n afterLogout,\n shouldCallLogoutMutation = () => true,\n notifyLogoutSuccess,\n notifySessionExpired,\n onError,\n } = adapters;\n\n const [authUser, setAuthUser] = useState<SafeUserType | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n\n const userId = useMemo(() => authUser?._id ?? \"\", [authUser?._id]);\n const { refetch } = useGetUser(userId);\n const { logout, loading } = useLogout();\n\n const handleSetAuthUser = useCallback(\n async (user: SafeUserType | null) => {\n setAuthUser(user);\n if (user) {\n await storage.setItem(USER_STORAGE_KEY, JSON.stringify(user));\n } else {\n await storage.removeItem(USER_STORAGE_KEY);\n }\n },\n [storage],\n );\n\n const handleRefetchUser = useCallback(async () => {\n if (!authUser) return;\n try {\n const result = await refetch();\n if (!result) return;\n const { data } = result;\n if (data?.user) await handleSetAuthUser(data.user);\n } catch (error: unknown) {\n onError?.(error, { action: \"refetchUser\" });\n console.warn(\n \"Failed to refetch user:\",\n error instanceof Error ? error.message : error,\n );\n }\n }, [authUser, handleSetAuthUser, onError, refetch]);\n\n const licences = useCallback(\n (resourceId: string) => {\n const myLicences =\n authUser?.licences?.map((licence) => licence.licenceType) ?? [];\n\n const myResourceIds = [\n authUser?.vendor ?? null,\n authUser?.partner ?? null,\n ...(authUser?.events ?? []),\n ].filter((id): id is string => id !== null);\n\n return myResourceIds.includes(resourceId)\n ? getLicenceFlagsByRole(myLicences)\n : NO_LICENCE_FLAGS;\n },\n [authUser],\n );\n\n const getLicenseAccessLevel = useCallback(\n (\n limitType: LimitType,\n resourceId: string,\n resourceType: EnumResourceType,\n ): number => {\n if (!isLicencedResourceType(resourceType)) {\n return 0;\n }\n\n // No resource yet (e.g. create flow): grant pro limits.\n if (resourceId === \"\") {\n return DEFAULT_LIMITS[limitType].pro;\n }\n\n const roleLicences = licences(resourceId)[resourceType];\n\n if (roleLicences.pro_plus) return DEFAULT_LIMITS[limitType].pro_plus;\n if (roleLicences.pro) return DEFAULT_LIMITS[limitType].pro;\n if (roleLicences.standard) return DEFAULT_LIMITS[limitType].standard;\n\n return 0;\n },\n [licences],\n );\n\n const hasVendorLicence = useMemo(\n () => hasLicence(authUser, \"vendor\"),\n [authUser],\n );\n\n const hasPartnerLicence = useMemo(\n () => hasLicence(authUser, \"partner\"),\n [authUser],\n );\n\n const hasEventLicence = useMemo(\n () => hasLicence(authUser, \"event\"),\n [authUser],\n );\n\n const hasUserLicence = useCallback(\n (licenceType: EnumUserLicence) => hasUserLicenceType(authUser, licenceType),\n [authUser],\n );\n\n const permissions = useMemo(() => {\n if (authUser?.permissions != null) {\n return authUser.permissions;\n }\n return getPermissionsForRoles(authUser?.roles);\n }, [authUser?.permissions, authUser?.roles]);\n\n const hasPermissionFn = useCallback(\n (permission: Permission) => permissionListIncludes(permissions, permission),\n [permissions],\n );\n\n const hasRoleFn = useCallback(\n (role: EnumUserRole) => roleHasRole(authUser?.roles, role),\n [authUser?.roles],\n );\n\n const isAdmin = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.ADMIN) ||\n permissionListIncludes(permissions, \"dashboard.admin\") ||\n permissionListIncludes(permissions, \"*\"),\n [authUser?.roles, permissions],\n );\n\n const isSuperAdmin = useMemo(\n () => roleHasRole(authUser?.roles, EnumUserRole.SUPER_ADMIN),\n [authUser?.roles],\n );\n\n const isAffiliate = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.AFFILIATE) &&\n authUser?.affiliate !== null &&\n authUser?.affiliate !== undefined,\n [authUser?.roles, authUser?.affiliate],\n );\n\n const isSchool = useMemo(\n () =>\n roleHasRole(authUser?.roles, EnumUserRole.SCHOOL) &&\n authUser?.school !== null &&\n authUser?.school !== undefined,\n [authUser?.roles, authUser?.school],\n );\n\n // Mount-only hydrate from storage. Do not re-run when adapter identities\n // change — that can overwrite a newer in-memory user (e.g. post-login setUser).\n useEffect(() => {\n const loadUser = async () => {\n try {\n const userJson = await storage.getItem(USER_STORAGE_KEY);\n await handleSetAuthUser(userJson ? JSON.parse(userJson) : null);\n } catch (error: unknown) {\n onError?.(error, { action: \"loadUserFromStorage\" });\n console.error(\"Failed to load user from storage:\", error);\n } finally {\n setIsLoading(false);\n }\n };\n\n void loadUser();\n }, []);\n\n const logoutWithReason = useCallback(\n async (reason: LogoutReason) => {\n try {\n if (shouldCallLogoutMutation(reason)) {\n try {\n const result = await logout();\n const message = result?.data?.logout?.message as string | undefined;\n if (message) {\n notifyLogoutSuccess?.(message);\n }\n } catch (err: unknown) {\n onError?.(err, { action: \"logout\" });\n console.warn(\"Logout request failed (ignored):\", err);\n }\n }\n } finally {\n await afterLogout(reason);\n setAuthUser(null);\n await storage.removeItem(USER_STORAGE_KEY);\n }\n },\n [\n afterLogout,\n logout,\n notifyLogoutSuccess,\n onError,\n shouldCallLogoutMutation,\n storage,\n ],\n );\n\n const handleLogoutExplicit = useCallback(\n () => logoutWithReason(\"manual\"),\n [logoutWithReason],\n );\n\n const handleLogoutExpired = useCallback(async () => {\n const hadSession = authUser != null;\n if (!hadSession) return;\n await logoutWithReason(\"expired\");\n notifySessionExpired?.();\n }, [authUser, logoutWithReason, notifySessionExpired]);\n\n useEffect(() => {\n authManager.setLogout(() => handleLogoutExpired());\n authManager.setUserRefetch(() => handleRefetchUser());\n }, [authManager, handleLogoutExpired, handleRefetchUser]);\n\n return {\n authUser,\n getLicenseAccessLevel,\n handleLogoutExplicit,\n hasEventLicence,\n hasPartnerLicence,\n hasPermission: hasPermissionFn,\n hasRole: hasRoleFn,\n hasUserLicence,\n hasVendorLicence,\n isAdmin,\n isAffiliate,\n isLoading: loading || isLoading,\n isSchool,\n isSuperAdmin,\n permissions,\n refetchUser: handleRefetchUser,\n setUser: handleSetAuthUser,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,oBAAiC;AAC/C,MAAI,WAAyC;AAC7C,MAAI,gBAA8C;AAClD,MAAI,gBAAsC;AAE1C,SAAO;AAAA,IACL,mBAAmB,YAAY;AAC7B,UAAI,eAAe;AACjB,cAAM,cAAc;AAAA,MACtB,OAAO;AACL,gBAAQ,KAAK,uCAAkC;AAAA,MACjD;AAAA,IACF;AAAA,IACA,SAAwB;AACtB,UAAI,kBAAkB,KAAM,QAAO;AACnC,UAAI,aAAa,MAAM;AACrB,gBAAQ,KAAK,iCAA4B;AACzC,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AAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,uBAAuB;AAAA,IAC3B,MAAM,iBAAiB,QAAQ;AAAA,IAC/B,CAAC,gBAAgB;AAAA,EACnB;AAEA,QAAM,sBAAsB,YAAY,YAAY;AAClD,UAAM,aAAa,YAAY;AAC/B,QAAI,CAAC,WAAY;AACjB,UAAM,iBAAiB,SAAS;AAChC,2BAAuB;AAAA,EACzB,GAAG,CAAC,UAAU,kBAAkB,oBAAoB,CAAC;AAErD,YAAU,MAAM;AACd,gBAAY,UAAU,MAAM,oBAAoB,CAAC;AACjD,gBAAY,eAAe,MAAM,kBAAkB,CAAC;AAAA,EACtD,GAAG,CAAC,aAAa,qBAAqB,iBAAiB,CAAC;AAExD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,WAAW;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AACF;","names":[]}
|
|
@@ -2199,8 +2199,12 @@ var GET_AD = gql20`
|
|
|
2199
2199
|
${AD_FIELDS_FRAGMENT}
|
|
2200
2200
|
`;
|
|
2201
2201
|
var GET_ADS_BY_REGION = gql20`
|
|
2202
|
-
query getAdsByRegion(
|
|
2203
|
-
|
|
2202
|
+
query getAdsByRegion(
|
|
2203
|
+
$region: String!
|
|
2204
|
+
$platform: AdPlatformEnum!
|
|
2205
|
+
$showOn: AdShowOnEnum
|
|
2206
|
+
) {
|
|
2207
|
+
adsByRegion(region: $region, platform: $platform, showOn: $showOn) {
|
|
2204
2208
|
...AdFields
|
|
2205
2209
|
}
|
|
2206
2210
|
}
|
|
@@ -2303,11 +2307,11 @@ var useGetAd = (_id) => {
|
|
|
2303
2307
|
refetch
|
|
2304
2308
|
};
|
|
2305
2309
|
};
|
|
2306
|
-
var useGetAdsByRegion = (region, platform) => {
|
|
2310
|
+
var useGetAdsByRegion = (region, platform, showOn) => {
|
|
2307
2311
|
const { data, loading, error, refetch } = useQuery6(GET_ADS_BY_REGION, {
|
|
2308
2312
|
fetchPolicy: "no-cache",
|
|
2309
2313
|
skip: !region || region === "",
|
|
2310
|
-
variables: { platform, region }
|
|
2314
|
+
variables: { platform, region, showOn }
|
|
2311
2315
|
});
|
|
2312
2316
|
return {
|
|
2313
2317
|
adsByRegion: data?.adsByRegion || [],
|
|
@@ -4358,4 +4362,4 @@ export {
|
|
|
4358
4362
|
useGetCoupon,
|
|
4359
4363
|
usePaginatedList
|
|
4360
4364
|
};
|
|
4361
|
-
//# sourceMappingURL=chunk-
|
|
4365
|
+
//# sourceMappingURL=chunk-KUC252SN.mjs.map
|