@timardex/cluemart-shared 1.0.79 → 1.0.81

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/index.mjs CHANGED
@@ -3377,81 +3377,15 @@ var useGetStallholderInfo = (stallholderId) => {
3377
3377
  };
3378
3378
  };
3379
3379
 
3380
- // src/graphql/hooks/subscriptions.ts
3381
- import { useSubscription } from "@apollo/client";
3382
-
3383
- // src/graphql/subscriptions/chat.ts
3384
- import { gql as gql16 } from "@apollo/client";
3385
- var GET_CHAT_MESSAGE = gql16`
3386
- subscription {
3387
- getChatMessage {
3388
- ...ChatFields
3389
- }
3390
- }
3391
- ${CHAT_FIELDS_FRAGMENT}
3392
- `;
3393
-
3394
- // src/graphql/subscriptions/notification.ts
3395
- import { gql as gql17 } from "@apollo/client";
3396
- var NOTIFICATION_FIELDS_FRAGMENT = gql17`
3397
- fragment NotificationFields on NotificationType {
3398
- createdBy
3399
- important
3400
- message
3401
- notifyUser
3402
- resourceId
3403
- resourceType
3404
- }
3405
- `;
3406
- var GET_GLOBAL_NOTIFICATION = gql17`
3407
- subscription {
3408
- getGlobalNotification {
3409
- ...NotificationFields
3410
- }
3411
- }
3412
- ${NOTIFICATION_FIELDS_FRAGMENT}
3413
- `;
3414
- var GET_RELATION_NOTIFICATION = gql17`
3415
- subscription {
3416
- getRelationNotification {
3417
- ...NotificationFields
3418
- }
3419
- }
3420
- ${NOTIFICATION_FIELDS_FRAGMENT}
3421
- `;
3422
-
3423
- // src/graphql/hooks/subscriptions.ts
3424
- var useGetNotification = () => {
3425
- const {
3426
- data: global,
3427
- loading: loadingGlobal,
3428
- error: errorGlobal
3429
- } = useSubscription(GET_GLOBAL_NOTIFICATION);
3430
- const {
3431
- data: relation,
3432
- loading: loadingImportant,
3433
- error: errorImportant
3434
- } = useSubscription(GET_RELATION_NOTIFICATION);
3435
- const error = errorGlobal || errorImportant;
3436
- const loading = loadingGlobal || loadingImportant;
3437
- const notification = relation?.getRelationNotification || global?.getGlobalNotification;
3438
- return { error, loading, notification };
3439
- };
3440
- var useGetChatSubscription = () => {
3441
- const { data, loading, error } = useSubscription(GET_CHAT_MESSAGE);
3442
- const chat = data?.getChat;
3443
- return { chat, error, loading };
3444
- };
3445
-
3446
3380
  // src/graphql/hooks/testers/hooksMutation.ts
3447
3381
  import { useMutation as useMutation10 } from "@apollo/client";
3448
3382
 
3449
3383
  // src/graphql/mutations/testers.ts
3450
- import { gql as gql19 } from "@apollo/client";
3384
+ import { gql as gql17 } from "@apollo/client";
3451
3385
 
3452
3386
  // src/graphql/queries/testers.ts
3453
- import { gql as gql18 } from "@apollo/client";
3454
- var TESTER_FIELDS_FRAGMENT = gql18`
3387
+ import { gql as gql16 } from "@apollo/client";
3388
+ var TESTER_FIELDS_FRAGMENT = gql16`
3455
3389
  fragment TesterFields on TesterType {
3456
3390
  _id
3457
3391
  active
@@ -3464,7 +3398,7 @@ var TESTER_FIELDS_FRAGMENT = gql18`
3464
3398
  updatedAt
3465
3399
  }
3466
3400
  `;
3467
- var GET_TESTERS = gql18`
3401
+ var GET_TESTERS = gql16`
3468
3402
  query getTesters {
3469
3403
  testers {
3470
3404
  ...TesterFields
@@ -3472,7 +3406,7 @@ var GET_TESTERS = gql18`
3472
3406
  }
3473
3407
  ${TESTER_FIELDS_FRAGMENT}
3474
3408
  `;
3475
- var GET_TESTER = gql18`
3409
+ var GET_TESTER = gql16`
3476
3410
  query getTester($_id: ID!) {
3477
3411
  tester(_id: $_id) {
3478
3412
  ...TesterFields
@@ -3482,7 +3416,7 @@ var GET_TESTER = gql18`
3482
3416
  `;
3483
3417
 
3484
3418
  // src/graphql/mutations/testers.ts
3485
- var CREATE_TESTER_MUTATION = gql19`
3419
+ var CREATE_TESTER_MUTATION = gql17`
3486
3420
  mutation createTester($input: TesterInputType!) {
3487
3421
  createTester(input: $input) {
3488
3422
  ...TesterFields
@@ -3490,7 +3424,7 @@ var CREATE_TESTER_MUTATION = gql19`
3490
3424
  }
3491
3425
  ${TESTER_FIELDS_FRAGMENT}
3492
3426
  `;
3493
- var UPDATE_TESTER_MUTATION = gql19`
3427
+ var UPDATE_TESTER_MUTATION = gql17`
3494
3428
  mutation updateTester($_id: ID!, $input: TesterInputType!) {
3495
3429
  updateTester(_id: $_id, input: $input) {
3496
3430
  ...TesterFields
@@ -3498,7 +3432,7 @@ var UPDATE_TESTER_MUTATION = gql19`
3498
3432
  }
3499
3433
  ${TESTER_FIELDS_FRAGMENT}
3500
3434
  `;
3501
- var DELETE_TESTER_MUTATION = gql19`
3435
+ var DELETE_TESTER_MUTATION = gql17`
3502
3436
  mutation deleteTester($_id: ID!) {
3503
3437
  deleteTester(_id: $_id)
3504
3438
  }
@@ -3559,8 +3493,8 @@ var useGetTester = (_id) => {
3559
3493
  import { useMutation as useMutation11 } from "@apollo/client";
3560
3494
 
3561
3495
  // src/graphql/mutations/user.ts
3562
- import { gql as gql20 } from "@apollo/client";
3563
- var CREATE_USER_MUTATION = gql20`
3496
+ import { gql as gql18 } from "@apollo/client";
3497
+ var CREATE_USER_MUTATION = gql18`
3564
3498
  mutation createUser($input: UserInputType!) {
3565
3499
  createUser(input: $input) {
3566
3500
  ...UserFields
@@ -3568,7 +3502,7 @@ var CREATE_USER_MUTATION = gql20`
3568
3502
  }
3569
3503
  ${USER_FIELDS_FRAGMENT}
3570
3504
  `;
3571
- var UPDATE_USER_MUTATION = gql20`
3505
+ var UPDATE_USER_MUTATION = gql18`
3572
3506
  mutation updateUser($_id: ID!, $input: UserInputType!) {
3573
3507
  updateUser(_id: $_id, input: $input) {
3574
3508
  ...UserFields
@@ -3576,12 +3510,12 @@ var UPDATE_USER_MUTATION = gql20`
3576
3510
  }
3577
3511
  ${USER_FIELDS_FRAGMENT}
3578
3512
  `;
3579
- var DELETE_USER_MUTATION = gql20`
3513
+ var DELETE_USER_MUTATION = gql18`
3580
3514
  mutation deleteUser($_id: ID!) {
3581
3515
  deleteUser(_id: $_id)
3582
3516
  }
3583
3517
  `;
3584
- var ADD_USER_FAVOURITE_RESOURCE_MUTATION = gql20`
3518
+ var ADD_USER_FAVOURITE_RESOURCE_MUTATION = gql18`
3585
3519
  mutation addUserFavouriteResource(
3586
3520
  $resourceId: ID!
3587
3521
  $resourceType: ResourceTypeEnum!
@@ -3597,7 +3531,7 @@ var ADD_USER_FAVOURITE_RESOURCE_MUTATION = gql20`
3597
3531
  }
3598
3532
  ${USER_FIELDS_FRAGMENT}
3599
3533
  `;
3600
- var REMOVE_USER_FAVOURITE_RESOURCE_MUTATION = gql20`
3534
+ var REMOVE_USER_FAVOURITE_RESOURCE_MUTATION = gql18`
3601
3535
  mutation removeUserFavouriteResource(
3602
3536
  $resourceId: ID!
3603
3537
  $resourceType: ResourceTypeEnum!
@@ -3705,6 +3639,110 @@ var useGetUserNotifications = () => {
3705
3639
  return { error, loading, refetch, userNotifications };
3706
3640
  };
3707
3641
 
3642
+ // src/graphql/queries/notificationQueries.ts
3643
+ import { gql as gql19 } from "@apollo/client";
3644
+ var GET_USER_NOTIFICATIONS2 = gql19`
3645
+ query GetUserNotifications(
3646
+ $userId: String!
3647
+ $limit: Int
3648
+ $offset: Int
3649
+ $isRead: String
3650
+ ) {
3651
+ userNotifications(
3652
+ userId: $userId
3653
+ limit: $limit
3654
+ offset: $offset
3655
+ isRead: $isRead
3656
+ ) {
3657
+ id
3658
+ userId
3659
+ title
3660
+ message
3661
+ type
3662
+ isRead
3663
+ data
3664
+ createdAt
3665
+ updatedAt
3666
+ }
3667
+ }
3668
+ `;
3669
+ var GET_NOTIFICATION_COUNT = gql19`
3670
+ query GetNotificationCount($userId: String!) {
3671
+ notificationCount(userId: $userId) {
3672
+ total
3673
+ unread
3674
+ }
3675
+ }
3676
+ `;
3677
+ var GET_UNREAD_NOTIFICATIONS = gql19`
3678
+ query GetUnreadNotifications($userId: String!, $limit: Int) {
3679
+ unreadNotifications(userId: $userId, limit: $limit) {
3680
+ id
3681
+ userId
3682
+ title
3683
+ message
3684
+ type
3685
+ isRead
3686
+ data
3687
+ createdAt
3688
+ updatedAt
3689
+ }
3690
+ }
3691
+ `;
3692
+
3693
+ // src/graphql/mutations/notificationMutations.ts
3694
+ import { gql as gql20 } from "@apollo/client";
3695
+ var CREATE_NOTIFICATION = gql20`
3696
+ mutation CreateNotification($input: CreateNotificationInput!) {
3697
+ createNotification(input: $input) {
3698
+ id
3699
+ userId
3700
+ title
3701
+ message
3702
+ type
3703
+ isRead
3704
+ data
3705
+ createdAt
3706
+ updatedAt
3707
+ }
3708
+ }
3709
+ `;
3710
+ var CREATE_BULK_NOTIFICATIONS = gql20`
3711
+ mutation CreateBulkNotifications($input: CreateBulkNotificationInput!) {
3712
+ createBulkNotifications(input: $input) {
3713
+ id
3714
+ userId
3715
+ title
3716
+ message
3717
+ type
3718
+ isRead
3719
+ data
3720
+ createdAt
3721
+ updatedAt
3722
+ }
3723
+ }
3724
+ `;
3725
+ var MARK_NOTIFICATION_READ = gql20`
3726
+ mutation MarkNotificationRead($input: MarkNotificationReadInput!) {
3727
+ markNotificationRead(input: $input) {
3728
+ id
3729
+ userId
3730
+ title
3731
+ message
3732
+ type
3733
+ isRead
3734
+ data
3735
+ createdAt
3736
+ updatedAt
3737
+ }
3738
+ }
3739
+ `;
3740
+ var MARK_ALL_NOTIFICATIONS_READ = gql20`
3741
+ mutation MarkAllNotificationsRead($input: MarkAllNotificationsReadInput!) {
3742
+ markAllNotificationsRead(input: $input)
3743
+ }
3744
+ `;
3745
+
3708
3746
  // src/hooks/useLocationSearch.ts
3709
3747
  var handleApiError = (error, message) => {
3710
3748
  console.error(message, error);
@@ -4885,6 +4923,100 @@ function useContactUsForm(data) {
4885
4923
  };
4886
4924
  }
4887
4925
 
4926
+ // src/hooks/useNotifications.ts
4927
+ import { useMutation as useMutation12, useQuery as useQuery7, useApolloClient } from "@apollo/client";
4928
+ var useNotifications = (userId) => {
4929
+ const client = useApolloClient();
4930
+ const {
4931
+ data: notificationsData,
4932
+ loading: notificationsLoading,
4933
+ error: notificationsError,
4934
+ refetch: refetchNotifications
4935
+ } = useQuery7(GET_USER_NOTIFICATIONS2, {
4936
+ variables: { userId, limit: 50, offset: 0 },
4937
+ fetchPolicy: "cache-and-network"
4938
+ });
4939
+ const {
4940
+ data: countData,
4941
+ loading: countLoading,
4942
+ error: countError,
4943
+ refetch: refetchCount
4944
+ } = useQuery7(GET_NOTIFICATION_COUNT, {
4945
+ variables: { userId },
4946
+ fetchPolicy: "cache-and-network"
4947
+ });
4948
+ const {
4949
+ data: unreadData,
4950
+ loading: unreadLoading,
4951
+ error: unreadError,
4952
+ refetch: refetchUnread
4953
+ } = useQuery7(GET_UNREAD_NOTIFICATIONS, {
4954
+ variables: { userId, limit: 20 },
4955
+ fetchPolicy: "cache-and-network"
4956
+ });
4957
+ const [createNotification, { loading: createLoading }] = useMutation12(CREATE_NOTIFICATION);
4958
+ const [createBulkNotifications, { loading: createBulkLoading }] = useMutation12(
4959
+ CREATE_BULK_NOTIFICATIONS
4960
+ );
4961
+ const [markNotificationRead, { loading: markReadLoading }] = useMutation12(
4962
+ MARK_NOTIFICATION_READ
4963
+ );
4964
+ const [markAllNotificationsRead, { loading: markAllReadLoading }] = useMutation12(MARK_ALL_NOTIFICATIONS_READ);
4965
+ const refetchAll = () => {
4966
+ refetchNotifications();
4967
+ refetchCount();
4968
+ refetchUnread();
4969
+ };
4970
+ const invalidateCache = () => {
4971
+ client.cache.evict({ fieldName: "userNotifications" });
4972
+ client.cache.evict({ fieldName: "notificationCount" });
4973
+ client.cache.evict({ fieldName: "unreadNotifications" });
4974
+ client.cache.gc();
4975
+ };
4976
+ return {
4977
+ // Data
4978
+ notifications: notificationsData?.userNotifications || [],
4979
+ count: countData?.notificationCount || { total: 0, unread: 0 },
4980
+ unreadNotifications: unreadData?.unreadNotifications || [],
4981
+ // Loading states
4982
+ notificationsLoading,
4983
+ countLoading,
4984
+ unreadLoading,
4985
+ createLoading,
4986
+ createBulkLoading,
4987
+ markReadLoading,
4988
+ markAllReadLoading,
4989
+ // Errors
4990
+ notificationsError,
4991
+ countError,
4992
+ unreadError,
4993
+ // Actions
4994
+ createNotification: async (input) => {
4995
+ const result = await createNotification({ variables: { input } });
4996
+ refetchAll();
4997
+ return result;
4998
+ },
4999
+ createBulkNotifications: async (input) => {
5000
+ const result = await createBulkNotifications({ variables: { input } });
5001
+ refetchAll();
5002
+ return result;
5003
+ },
5004
+ markNotificationRead: async (input) => {
5005
+ const result = await markNotificationRead({ variables: { input } });
5006
+ refetchAll();
5007
+ return result;
5008
+ },
5009
+ markAllNotificationsRead: async (input) => {
5010
+ const result = await markAllNotificationsRead({ variables: { input } });
5011
+ refetchAll();
5012
+ return result;
5013
+ },
5014
+ // Utilities
5015
+ refetchAll,
5016
+ invalidateCache
5017
+ };
5018
+ };
5019
+
4888
5020
  // src/storage/index.ts
4889
5021
  var SAVED_PASSWORD_KEY = "savedPassword";
4890
5022
  var SAVED_EMAIL_KEY = "savedEmail";
@@ -4930,6 +5062,8 @@ var fonts = {
4930
5062
  }
4931
5063
  };
4932
5064
  export {
5065
+ CREATE_BULK_NOTIFICATIONS,
5066
+ CREATE_NOTIFICATION,
4933
5067
  EnumInviteStatus,
4934
5068
  EnumNotification,
4935
5069
  EnumOSType,
@@ -4941,7 +5075,12 @@ export {
4941
5075
  EnumSocialMedia,
4942
5076
  EnumUserLicence,
4943
5077
  EnumUserRole,
5078
+ GET_NOTIFICATION_COUNT,
5079
+ GET_UNREAD_NOTIFICATIONS,
5080
+ GET_USER_NOTIFICATIONS2 as GET_USER_NOTIFICATIONS,
4944
5081
  ImageTypeEnum,
5082
+ MARK_ALL_NOTIFICATIONS_READ,
5083
+ MARK_NOTIFICATION_READ,
4945
5084
  SAVED_EMAIL_KEY,
4946
5085
  SAVED_PASSWORD_KEY,
4947
5086
  SAVED_REFRESH_TOKEN_KEY,
@@ -5031,14 +5170,12 @@ export {
5031
5170
  useDeleteTester,
5032
5171
  useDeleteUser,
5033
5172
  useGetChat,
5034
- useGetChatSubscription,
5035
5173
  useGetMarket,
5036
5174
  useGetMarketInfo,
5037
5175
  useGetMarketRelations,
5038
5176
  useGetMarkets,
5039
5177
  useGetMarketsByRegion,
5040
5178
  useGetMarketsNearMe,
5041
- useGetNotification,
5042
5179
  useGetRelation,
5043
5180
  useGetRelationByMarketAndStallholder,
5044
5181
  useGetResourceConnections,
@@ -5062,6 +5199,7 @@ export {
5062
5199
  useLogout,
5063
5200
  useMarketForm,
5064
5201
  useMarketInfoForm,
5202
+ useNotifications,
5065
5203
  useRefreshToken,
5066
5204
  useRegister,
5067
5205
  useRegisterForm,