@timardex/cluemart-shared 1.0.79 → 1.0.80
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/chunk-SCXVJDGI.mjs +114 -0
- package/dist/chunk-SCXVJDGI.mjs.map +1 -0
- package/dist/formFields/index.d.mts +1 -1
- package/dist/formFields/index.d.ts +1 -1
- package/dist/{global-Drk9CYfv.d.ts → global-Bieh1fh8.d.mts} +2 -10
- package/dist/{global-2TLPFthS.d.mts → global-By7aHQ1y.d.ts} +2 -10
- package/dist/graphql/index.cjs +152 -104
- package/dist/graphql/index.cjs.map +1 -1
- package/dist/graphql/index.d.mts +11 -13
- package/dist/graphql/index.d.ts +11 -13
- package/dist/graphql/index.mjs +32 -84
- package/dist/graphql/index.mjs.map +1 -1
- package/dist/hooks/index.cjs +202 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.mts +26 -3
- package/dist/hooks/index.d.ts +26 -3
- package/dist/hooks/index.mjs +104 -0
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.cjs +248 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +69 -20
- package/dist/index.d.ts +69 -20
- package/dist/index.mjs +220 -82
- package/dist/index.mjs.map +1 -1
- package/dist/{contactUs-CQ9xTjlE.d.mts → notification-H4hE5cdq.d.mts} +38 -1
- package/dist/{contactUs-CQ9xTjlE.d.ts → notification-H4hE5cdq.d.ts} +38 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/hooks/index.cjs
CHANGED
|
@@ -41,6 +41,7 @@ __export(hooks_exports, {
|
|
|
41
41
|
useLoginForm: () => useLoginForm,
|
|
42
42
|
useMarketForm: () => useMarketForm,
|
|
43
43
|
useMarketInfoForm: () => useMarketInfoForm,
|
|
44
|
+
useNotifications: () => useNotifications,
|
|
44
45
|
useRegisterForm: () => useRegisterForm,
|
|
45
46
|
useRequestPasswordResetForm: () => useRequestPasswordResetForm,
|
|
46
47
|
useResetPasswordForm: () => useResetPasswordForm,
|
|
@@ -1327,6 +1328,206 @@ function useContactUsForm(data) {
|
|
|
1327
1328
|
watch
|
|
1328
1329
|
};
|
|
1329
1330
|
}
|
|
1331
|
+
|
|
1332
|
+
// src/hooks/useNotifications.ts
|
|
1333
|
+
var import_client3 = require("@apollo/client");
|
|
1334
|
+
|
|
1335
|
+
// src/graphql/mutations/notificationMutations.ts
|
|
1336
|
+
var import_client = require("@apollo/client");
|
|
1337
|
+
var CREATE_NOTIFICATION = import_client.gql`
|
|
1338
|
+
mutation CreateNotification($input: CreateNotificationInput!) {
|
|
1339
|
+
createNotification(input: $input) {
|
|
1340
|
+
id
|
|
1341
|
+
userId
|
|
1342
|
+
title
|
|
1343
|
+
message
|
|
1344
|
+
type
|
|
1345
|
+
isRead
|
|
1346
|
+
data
|
|
1347
|
+
createdAt
|
|
1348
|
+
updatedAt
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
`;
|
|
1352
|
+
var CREATE_BULK_NOTIFICATIONS = import_client.gql`
|
|
1353
|
+
mutation CreateBulkNotifications($input: CreateBulkNotificationInput!) {
|
|
1354
|
+
createBulkNotifications(input: $input) {
|
|
1355
|
+
id
|
|
1356
|
+
userId
|
|
1357
|
+
title
|
|
1358
|
+
message
|
|
1359
|
+
type
|
|
1360
|
+
isRead
|
|
1361
|
+
data
|
|
1362
|
+
createdAt
|
|
1363
|
+
updatedAt
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
`;
|
|
1367
|
+
var MARK_NOTIFICATION_READ = import_client.gql`
|
|
1368
|
+
mutation MarkNotificationRead($input: MarkNotificationReadInput!) {
|
|
1369
|
+
markNotificationRead(input: $input) {
|
|
1370
|
+
id
|
|
1371
|
+
userId
|
|
1372
|
+
title
|
|
1373
|
+
message
|
|
1374
|
+
type
|
|
1375
|
+
isRead
|
|
1376
|
+
data
|
|
1377
|
+
createdAt
|
|
1378
|
+
updatedAt
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
`;
|
|
1382
|
+
var MARK_ALL_NOTIFICATIONS_READ = import_client.gql`
|
|
1383
|
+
mutation MarkAllNotificationsRead($input: MarkAllNotificationsReadInput!) {
|
|
1384
|
+
markAllNotificationsRead(input: $input)
|
|
1385
|
+
}
|
|
1386
|
+
`;
|
|
1387
|
+
|
|
1388
|
+
// src/graphql/queries/notificationQueries.ts
|
|
1389
|
+
var import_client2 = require("@apollo/client");
|
|
1390
|
+
var GET_USER_NOTIFICATIONS = import_client2.gql`
|
|
1391
|
+
query GetUserNotifications(
|
|
1392
|
+
$userId: String!
|
|
1393
|
+
$limit: Int
|
|
1394
|
+
$offset: Int
|
|
1395
|
+
$isRead: String
|
|
1396
|
+
) {
|
|
1397
|
+
userNotifications(
|
|
1398
|
+
userId: $userId
|
|
1399
|
+
limit: $limit
|
|
1400
|
+
offset: $offset
|
|
1401
|
+
isRead: $isRead
|
|
1402
|
+
) {
|
|
1403
|
+
id
|
|
1404
|
+
userId
|
|
1405
|
+
title
|
|
1406
|
+
message
|
|
1407
|
+
type
|
|
1408
|
+
isRead
|
|
1409
|
+
data
|
|
1410
|
+
createdAt
|
|
1411
|
+
updatedAt
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
`;
|
|
1415
|
+
var GET_NOTIFICATION_COUNT = import_client2.gql`
|
|
1416
|
+
query GetNotificationCount($userId: String!) {
|
|
1417
|
+
notificationCount(userId: $userId) {
|
|
1418
|
+
total
|
|
1419
|
+
unread
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
`;
|
|
1423
|
+
var GET_UNREAD_NOTIFICATIONS = import_client2.gql`
|
|
1424
|
+
query GetUnreadNotifications($userId: String!, $limit: Int) {
|
|
1425
|
+
unreadNotifications(userId: $userId, limit: $limit) {
|
|
1426
|
+
id
|
|
1427
|
+
userId
|
|
1428
|
+
title
|
|
1429
|
+
message
|
|
1430
|
+
type
|
|
1431
|
+
isRead
|
|
1432
|
+
data
|
|
1433
|
+
createdAt
|
|
1434
|
+
updatedAt
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
`;
|
|
1438
|
+
|
|
1439
|
+
// src/hooks/useNotifications.ts
|
|
1440
|
+
var useNotifications = (userId) => {
|
|
1441
|
+
const client = (0, import_client3.useApolloClient)();
|
|
1442
|
+
const {
|
|
1443
|
+
data: notificationsData,
|
|
1444
|
+
loading: notificationsLoading,
|
|
1445
|
+
error: notificationsError,
|
|
1446
|
+
refetch: refetchNotifications
|
|
1447
|
+
} = (0, import_client3.useQuery)(GET_USER_NOTIFICATIONS, {
|
|
1448
|
+
variables: { userId, limit: 50, offset: 0 },
|
|
1449
|
+
fetchPolicy: "cache-and-network"
|
|
1450
|
+
});
|
|
1451
|
+
const {
|
|
1452
|
+
data: countData,
|
|
1453
|
+
loading: countLoading,
|
|
1454
|
+
error: countError,
|
|
1455
|
+
refetch: refetchCount
|
|
1456
|
+
} = (0, import_client3.useQuery)(GET_NOTIFICATION_COUNT, {
|
|
1457
|
+
variables: { userId },
|
|
1458
|
+
fetchPolicy: "cache-and-network"
|
|
1459
|
+
});
|
|
1460
|
+
const {
|
|
1461
|
+
data: unreadData,
|
|
1462
|
+
loading: unreadLoading,
|
|
1463
|
+
error: unreadError,
|
|
1464
|
+
refetch: refetchUnread
|
|
1465
|
+
} = (0, import_client3.useQuery)(GET_UNREAD_NOTIFICATIONS, {
|
|
1466
|
+
variables: { userId, limit: 20 },
|
|
1467
|
+
fetchPolicy: "cache-and-network"
|
|
1468
|
+
});
|
|
1469
|
+
const [createNotification, { loading: createLoading }] = (0, import_client3.useMutation)(CREATE_NOTIFICATION);
|
|
1470
|
+
const [createBulkNotifications, { loading: createBulkLoading }] = (0, import_client3.useMutation)(
|
|
1471
|
+
CREATE_BULK_NOTIFICATIONS
|
|
1472
|
+
);
|
|
1473
|
+
const [markNotificationRead, { loading: markReadLoading }] = (0, import_client3.useMutation)(
|
|
1474
|
+
MARK_NOTIFICATION_READ
|
|
1475
|
+
);
|
|
1476
|
+
const [markAllNotificationsRead, { loading: markAllReadLoading }] = (0, import_client3.useMutation)(MARK_ALL_NOTIFICATIONS_READ);
|
|
1477
|
+
const refetchAll = () => {
|
|
1478
|
+
refetchNotifications();
|
|
1479
|
+
refetchCount();
|
|
1480
|
+
refetchUnread();
|
|
1481
|
+
};
|
|
1482
|
+
const invalidateCache = () => {
|
|
1483
|
+
client.cache.evict({ fieldName: "userNotifications" });
|
|
1484
|
+
client.cache.evict({ fieldName: "notificationCount" });
|
|
1485
|
+
client.cache.evict({ fieldName: "unreadNotifications" });
|
|
1486
|
+
client.cache.gc();
|
|
1487
|
+
};
|
|
1488
|
+
return {
|
|
1489
|
+
// Data
|
|
1490
|
+
notifications: notificationsData?.userNotifications || [],
|
|
1491
|
+
count: countData?.notificationCount || { total: 0, unread: 0 },
|
|
1492
|
+
unreadNotifications: unreadData?.unreadNotifications || [],
|
|
1493
|
+
// Loading states
|
|
1494
|
+
notificationsLoading,
|
|
1495
|
+
countLoading,
|
|
1496
|
+
unreadLoading,
|
|
1497
|
+
createLoading,
|
|
1498
|
+
createBulkLoading,
|
|
1499
|
+
markReadLoading,
|
|
1500
|
+
markAllReadLoading,
|
|
1501
|
+
// Errors
|
|
1502
|
+
notificationsError,
|
|
1503
|
+
countError,
|
|
1504
|
+
unreadError,
|
|
1505
|
+
// Actions
|
|
1506
|
+
createNotification: async (input) => {
|
|
1507
|
+
const result = await createNotification({ variables: { input } });
|
|
1508
|
+
refetchAll();
|
|
1509
|
+
return result;
|
|
1510
|
+
},
|
|
1511
|
+
createBulkNotifications: async (input) => {
|
|
1512
|
+
const result = await createBulkNotifications({ variables: { input } });
|
|
1513
|
+
refetchAll();
|
|
1514
|
+
return result;
|
|
1515
|
+
},
|
|
1516
|
+
markNotificationRead: async (input) => {
|
|
1517
|
+
const result = await markNotificationRead({ variables: { input } });
|
|
1518
|
+
refetchAll();
|
|
1519
|
+
return result;
|
|
1520
|
+
},
|
|
1521
|
+
markAllNotificationsRead: async (input) => {
|
|
1522
|
+
const result = await markAllNotificationsRead({ variables: { input } });
|
|
1523
|
+
refetchAll();
|
|
1524
|
+
return result;
|
|
1525
|
+
},
|
|
1526
|
+
// Utilities
|
|
1527
|
+
refetchAll,
|
|
1528
|
+
invalidateCache
|
|
1529
|
+
};
|
|
1530
|
+
};
|
|
1330
1531
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1331
1532
|
0 && (module.exports = {
|
|
1332
1533
|
defaultMarketFormValues,
|
|
@@ -1340,6 +1541,7 @@ function useContactUsForm(data) {
|
|
|
1340
1541
|
useLoginForm,
|
|
1341
1542
|
useMarketForm,
|
|
1342
1543
|
useMarketInfoForm,
|
|
1544
|
+
useNotifications,
|
|
1343
1545
|
useRegisterForm,
|
|
1344
1546
|
useRequestPasswordResetForm,
|
|
1345
1547
|
useResetPasswordForm,
|