@replyke/core 6.0.0-beta.5 → 6.0.0-beta.7
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/cjs/helpers/addNotificationsMessages.js.map +1 -1
- package/dist/cjs/hooks/relationships/connections/index.d.ts +13 -0
- package/dist/cjs/hooks/relationships/connections/index.js +33 -0
- package/dist/cjs/hooks/relationships/connections/index.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useAcceptConnection.d.ts +5 -0
- package/dist/cjs/hooks/relationships/connections/useAcceptConnection.js +76 -0
- package/dist/cjs/hooks/relationships/connections/useAcceptConnection.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useConnectionManager.d.ts +26 -0
- package/dist/cjs/hooks/relationships/connections/useConnectionManager.js +342 -0
- package/dist/cjs/hooks/relationships/connections/useConnectionManager.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useDeclineConnection.d.ts +5 -0
- package/dist/cjs/hooks/relationships/connections/useDeclineConnection.js +76 -0
- package/dist/cjs/hooks/relationships/connections/useDeclineConnection.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionStatus.d.ts +5 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionStatus.js +79 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionStatus.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnections.d.ts +7 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnections.js +95 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnections.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsByUserId.d.ts +8 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsByUserId.js +75 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsByUserId.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsCount.d.ts +3 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsCount.js +72 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsCount.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsCountByUserId.d.ts +6 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsCountByUserId.js +70 -0
- package/dist/cjs/hooks/relationships/connections/useFetchConnectionsCountByUserId.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useFetchReceivedPendingConnections.d.ts +7 -0
- package/dist/cjs/hooks/relationships/connections/useFetchReceivedPendingConnections.js +95 -0
- package/dist/cjs/hooks/relationships/connections/useFetchReceivedPendingConnections.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useFetchSentPendingConnections.d.ts +7 -0
- package/dist/cjs/hooks/relationships/connections/useFetchSentPendingConnections.js +95 -0
- package/dist/cjs/hooks/relationships/connections/useFetchSentPendingConnections.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useRemoveConnection.d.ts +5 -0
- package/dist/cjs/hooks/relationships/connections/useRemoveConnection.js +76 -0
- package/dist/cjs/hooks/relationships/connections/useRemoveConnection.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useRemoveConnectionByUserId.d.ts +5 -0
- package/dist/cjs/hooks/relationships/connections/useRemoveConnectionByUserId.js +79 -0
- package/dist/cjs/hooks/relationships/connections/useRemoveConnectionByUserId.js.map +1 -0
- package/dist/cjs/hooks/relationships/connections/useRequestConnection.d.ts +3 -0
- package/dist/cjs/hooks/relationships/connections/useRequestConnection.js +71 -0
- package/dist/cjs/hooks/relationships/connections/useRequestConnection.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/index.d.ts +12 -3
- package/dist/cjs/hooks/relationships/follows/index.js +25 -7
- package/dist/cjs/hooks/relationships/follows/index.js.map +1 -1
- package/dist/cjs/hooks/relationships/follows/useFetchFollowStatus.d.ts +8 -0
- package/dist/cjs/hooks/relationships/follows/{useFetchFollow.js → useFetchFollowStatus.js} +5 -5
- package/dist/cjs/hooks/relationships/follows/useFetchFollowStatus.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowers.d.ts +23 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowers.js +91 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowers.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowersByUserId.d.ts +24 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowersByUserId.js +70 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowersByUserId.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowersCount.d.ts +4 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowersCount.js +72 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowersCount.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowersCountByUserId.d.ts +6 -0
- package/dist/cjs/hooks/{users/useFetchUserFollowersCount.js → relationships/follows/useFetchFollowersCountByUserId.js} +9 -10
- package/dist/cjs/hooks/relationships/follows/useFetchFollowersCountByUserId.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowing.d.ts +23 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowing.js +94 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowing.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowingByUserId.d.ts +24 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowingByUserId.js +75 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowingByUserId.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowingCount.d.ts +4 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowingCount.js +72 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowingCount.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFetchFollowingCountByUserId.d.ts +6 -0
- package/dist/cjs/hooks/{users/useFetchUserFollowingCount.js → relationships/follows/useFetchFollowingCountByUserId.js} +9 -10
- package/dist/cjs/hooks/relationships/follows/useFetchFollowingCountByUserId.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useFollowManager.js +8 -8
- package/dist/cjs/hooks/relationships/follows/useFollowManager.js.map +1 -1
- package/dist/cjs/hooks/relationships/follows/useUnfollowByFollowId.d.ts +4 -0
- package/dist/cjs/hooks/relationships/follows/useUnfollowByFollowId.js +78 -0
- package/dist/cjs/hooks/relationships/follows/useUnfollowByFollowId.js.map +1 -0
- package/dist/cjs/hooks/relationships/follows/useUnfollowUserByUserId.d.ts +4 -0
- package/dist/cjs/hooks/relationships/follows/{useUnfollowUser.js → useUnfollowUserByUserId.js} +5 -5
- package/dist/cjs/hooks/relationships/follows/useUnfollowUserByUserId.js.map +1 -0
- package/dist/cjs/hooks/users/index.d.ts +0 -2
- package/dist/cjs/hooks/users/index.js +1 -5
- package/dist/cjs/hooks/users/index.js.map +1 -1
- package/dist/cjs/hooks/users/useUpdateUser.d.ts +1 -2
- package/dist/cjs/hooks/users/useUpdateUser.js +7 -2
- package/dist/cjs/hooks/users/useUpdateUser.js.map +1 -1
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +28 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/models/AppNotification.d.ts +26 -2
- package/dist/cjs/interfaces/models/Connection.d.ts +87 -0
- package/dist/cjs/interfaces/models/Connection.js +3 -0
- package/dist/cjs/interfaces/models/Connection.js.map +1 -0
- package/dist/cjs/interfaces/models/Follow.d.ts +2 -0
- package/dist/esm/helpers/addNotificationsMessages.js.map +1 -1
- package/dist/esm/hooks/relationships/connections/index.d.ts +13 -0
- package/dist/esm/hooks/relationships/connections/index.js +14 -0
- package/dist/esm/hooks/relationships/connections/index.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useAcceptConnection.d.ts +5 -0
- package/dist/esm/hooks/relationships/connections/useAcceptConnection.js +71 -0
- package/dist/esm/hooks/relationships/connections/useAcceptConnection.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useConnectionManager.d.ts +26 -0
- package/dist/esm/hooks/relationships/connections/useConnectionManager.js +337 -0
- package/dist/esm/hooks/relationships/connections/useConnectionManager.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useDeclineConnection.d.ts +5 -0
- package/dist/esm/hooks/relationships/connections/useDeclineConnection.js +71 -0
- package/dist/esm/hooks/relationships/connections/useDeclineConnection.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionStatus.d.ts +5 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionStatus.js +74 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionStatus.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnections.d.ts +7 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnections.js +90 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnections.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsByUserId.d.ts +8 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsByUserId.js +70 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsByUserId.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsCount.d.ts +3 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsCount.js +67 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsCount.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsCountByUserId.d.ts +6 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsCountByUserId.js +65 -0
- package/dist/esm/hooks/relationships/connections/useFetchConnectionsCountByUserId.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useFetchReceivedPendingConnections.d.ts +7 -0
- package/dist/esm/hooks/relationships/connections/useFetchReceivedPendingConnections.js +90 -0
- package/dist/esm/hooks/relationships/connections/useFetchReceivedPendingConnections.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useFetchSentPendingConnections.d.ts +7 -0
- package/dist/esm/hooks/relationships/connections/useFetchSentPendingConnections.js +90 -0
- package/dist/esm/hooks/relationships/connections/useFetchSentPendingConnections.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useRemoveConnection.d.ts +5 -0
- package/dist/esm/hooks/relationships/connections/useRemoveConnection.js +71 -0
- package/dist/esm/hooks/relationships/connections/useRemoveConnection.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useRemoveConnectionByUserId.d.ts +5 -0
- package/dist/esm/hooks/relationships/connections/useRemoveConnectionByUserId.js +74 -0
- package/dist/esm/hooks/relationships/connections/useRemoveConnectionByUserId.js.map +1 -0
- package/dist/esm/hooks/relationships/connections/useRequestConnection.d.ts +3 -0
- package/dist/esm/hooks/relationships/connections/useRequestConnection.js +66 -0
- package/dist/esm/hooks/relationships/connections/useRequestConnection.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/index.d.ts +12 -3
- package/dist/esm/hooks/relationships/follows/index.js +12 -3
- package/dist/esm/hooks/relationships/follows/index.js.map +1 -1
- package/dist/esm/hooks/relationships/follows/useFetchFollowStatus.d.ts +8 -0
- package/dist/esm/hooks/relationships/follows/{useFetchFollow.js → useFetchFollowStatus.js} +5 -5
- package/dist/esm/hooks/relationships/follows/useFetchFollowStatus.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowers.d.ts +23 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowers.js +86 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowers.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowersByUserId.d.ts +24 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowersByUserId.js +65 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowersByUserId.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowersCount.d.ts +4 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowersCount.js +67 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowersCount.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowersCountByUserId.d.ts +6 -0
- package/dist/esm/hooks/{users/useFetchUserFollowersCount.js → relationships/follows/useFetchFollowersCountByUserId.js} +8 -9
- package/dist/esm/hooks/relationships/follows/useFetchFollowersCountByUserId.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowing.d.ts +23 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowing.js +89 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowing.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowingByUserId.d.ts +24 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowingByUserId.js +70 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowingByUserId.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowingCount.d.ts +4 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowingCount.js +67 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowingCount.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFetchFollowingCountByUserId.d.ts +6 -0
- package/dist/esm/hooks/{users/useFetchUserFollowingCount.js → relationships/follows/useFetchFollowingCountByUserId.js} +8 -9
- package/dist/esm/hooks/relationships/follows/useFetchFollowingCountByUserId.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useFollowManager.js +8 -8
- package/dist/esm/hooks/relationships/follows/useFollowManager.js.map +1 -1
- package/dist/esm/hooks/relationships/follows/useUnfollowByFollowId.d.ts +4 -0
- package/dist/esm/hooks/relationships/follows/useUnfollowByFollowId.js +73 -0
- package/dist/esm/hooks/relationships/follows/useUnfollowByFollowId.js.map +1 -0
- package/dist/esm/hooks/relationships/follows/useUnfollowUserByUserId.d.ts +4 -0
- package/dist/esm/hooks/relationships/follows/{useUnfollowUser.js → useUnfollowUserByUserId.js} +5 -5
- package/dist/esm/hooks/relationships/follows/useUnfollowUserByUserId.js.map +1 -0
- package/dist/esm/hooks/users/index.d.ts +0 -2
- package/dist/esm/hooks/users/index.js +0 -2
- package/dist/esm/hooks/users/index.js.map +1 -1
- package/dist/esm/hooks/users/useUpdateUser.d.ts +1 -2
- package/dist/esm/hooks/users/useUpdateUser.js +7 -2
- package/dist/esm/hooks/users/useUpdateUser.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/models/AppNotification.d.ts +26 -2
- package/dist/esm/interfaces/models/Connection.d.ts +87 -0
- package/dist/esm/interfaces/models/Connection.js +2 -0
- package/dist/esm/interfaces/models/Connection.js.map +1 -0
- package/dist/esm/interfaces/models/Follow.d.ts +2 -0
- package/package.json +1 -1
- package/dist/cjs/hooks/relationships/follows/useFetchFollow.d.ts +0 -6
- package/dist/cjs/hooks/relationships/follows/useFetchFollow.js.map +0 -1
- package/dist/cjs/hooks/relationships/follows/useUnfollowUser.d.ts +0 -4
- package/dist/cjs/hooks/relationships/follows/useUnfollowUser.js.map +0 -1
- package/dist/cjs/hooks/users/useFetchUserFollowersCount.d.ts +0 -6
- package/dist/cjs/hooks/users/useFetchUserFollowersCount.js.map +0 -1
- package/dist/cjs/hooks/users/useFetchUserFollowingCount.d.ts +0 -6
- package/dist/cjs/hooks/users/useFetchUserFollowingCount.js.map +0 -1
- package/dist/esm/hooks/relationships/follows/useFetchFollow.d.ts +0 -6
- package/dist/esm/hooks/relationships/follows/useFetchFollow.js.map +0 -1
- package/dist/esm/hooks/relationships/follows/useUnfollowUser.d.ts +0 -4
- package/dist/esm/hooks/relationships/follows/useUnfollowUser.js.map +0 -1
- package/dist/esm/hooks/users/useFetchUserFollowersCount.d.ts +0 -6
- package/dist/esm/hooks/users/useFetchUserFollowersCount.js.map +0 -1
- package/dist/esm/hooks/users/useFetchUserFollowingCount.d.ts +0 -6
- package/dist/esm/hooks/users/useFetchUserFollowingCount.js.map +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ConnectionStatus } from "../../../interfaces/models/Connection";
|
|
2
|
+
interface UseConnectionManagerProps {
|
|
3
|
+
userId: string;
|
|
4
|
+
}
|
|
5
|
+
interface ConnectionData {
|
|
6
|
+
connectionId: string | null;
|
|
7
|
+
connectedAt?: string;
|
|
8
|
+
requestedAt?: string;
|
|
9
|
+
createdAt?: string;
|
|
10
|
+
respondedAt?: string;
|
|
11
|
+
type?: "sent" | "received";
|
|
12
|
+
}
|
|
13
|
+
declare function useConnectionManager({ userId }: UseConnectionManagerProps): {
|
|
14
|
+
connectionStatus: ConnectionStatus;
|
|
15
|
+
connectionId: string | null;
|
|
16
|
+
connectionData: ConnectionData;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
sendConnectionRequest: (message?: string) => Promise<void>;
|
|
19
|
+
acceptConnectionRequest: () => Promise<void>;
|
|
20
|
+
declineConnectionRequest: () => Promise<void>;
|
|
21
|
+
withdrawConnectionRequest: () => Promise<void>;
|
|
22
|
+
disconnectUser: () => Promise<void>;
|
|
23
|
+
removeConnectionSmart: () => Promise<void>;
|
|
24
|
+
refreshConnectionStatus: () => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
export default useConnectionManager;
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { useState, useEffect, useCallback } from "react";
|
|
38
|
+
import useRequestConnection from "./useRequestConnection";
|
|
39
|
+
import useAcceptConnection from "./useAcceptConnection";
|
|
40
|
+
import useDeclineConnection from "./useDeclineConnection";
|
|
41
|
+
import useRemoveConnection from "./useRemoveConnection";
|
|
42
|
+
import useRemoveConnectionByUserId from "./useRemoveConnectionByUserId";
|
|
43
|
+
import useGetConnectionStatus from "./useFetchConnectionStatus";
|
|
44
|
+
import useUser from "../../user/useUser";
|
|
45
|
+
function useConnectionManager(_a) {
|
|
46
|
+
var _this = this;
|
|
47
|
+
var userId = _a.userId;
|
|
48
|
+
var user = useUser().user;
|
|
49
|
+
var _b = useState("none"), connectionStatus = _b[0], setConnectionStatus = _b[1];
|
|
50
|
+
var _c = useState({
|
|
51
|
+
connectionId: null,
|
|
52
|
+
}), connectionData = _c[0], setConnectionData = _c[1];
|
|
53
|
+
var _d = useState(true), isLoading = _d[0], setIsLoading = _d[1];
|
|
54
|
+
var requestConnection = useRequestConnection();
|
|
55
|
+
var acceptConnection = useAcceptConnection();
|
|
56
|
+
var declineConnection = useDeclineConnection();
|
|
57
|
+
var removeConnection = useRemoveConnection();
|
|
58
|
+
var removeConnectionByUserId = useRemoveConnectionByUserId();
|
|
59
|
+
var getConnectionStatus = useGetConnectionStatus();
|
|
60
|
+
var loadConnectionStatus = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
61
|
+
var statusResponse, error_1;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
if (!userId || (user === null || user === void 0 ? void 0 : user.id) === userId) {
|
|
66
|
+
setConnectionStatus("none");
|
|
67
|
+
setConnectionData({ connectionId: null });
|
|
68
|
+
setIsLoading(false);
|
|
69
|
+
return [2 /*return*/];
|
|
70
|
+
}
|
|
71
|
+
_a.label = 1;
|
|
72
|
+
case 1:
|
|
73
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
74
|
+
setIsLoading(true);
|
|
75
|
+
return [4 /*yield*/, getConnectionStatus({ userId: userId })];
|
|
76
|
+
case 2:
|
|
77
|
+
statusResponse = _a.sent();
|
|
78
|
+
switch (statusResponse.status) {
|
|
79
|
+
case "none":
|
|
80
|
+
setConnectionStatus("none");
|
|
81
|
+
setConnectionData({ connectionId: null });
|
|
82
|
+
break;
|
|
83
|
+
case "pending":
|
|
84
|
+
setConnectionStatus(statusResponse.type === "sent" ? "pending-sent" : "pending-received");
|
|
85
|
+
setConnectionData({
|
|
86
|
+
connectionId: statusResponse.connectionId,
|
|
87
|
+
createdAt: statusResponse.createdAt,
|
|
88
|
+
type: statusResponse.type,
|
|
89
|
+
});
|
|
90
|
+
break;
|
|
91
|
+
case "connected":
|
|
92
|
+
setConnectionStatus("connected");
|
|
93
|
+
setConnectionData({
|
|
94
|
+
connectionId: statusResponse.connectionId,
|
|
95
|
+
connectedAt: statusResponse.connectedAt,
|
|
96
|
+
requestedAt: statusResponse.requestedAt,
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
case "declined":
|
|
100
|
+
setConnectionStatus(statusResponse.type === "sent" ? "declined-sent" : "declined-received");
|
|
101
|
+
setConnectionData({
|
|
102
|
+
connectionId: statusResponse.connectionId,
|
|
103
|
+
respondedAt: statusResponse.respondedAt,
|
|
104
|
+
type: statusResponse.type,
|
|
105
|
+
});
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
setConnectionStatus("none");
|
|
109
|
+
setConnectionData({ connectionId: null });
|
|
110
|
+
}
|
|
111
|
+
return [3 /*break*/, 5];
|
|
112
|
+
case 3:
|
|
113
|
+
error_1 = _a.sent();
|
|
114
|
+
console.error("Failed to fetch connection status:", error_1);
|
|
115
|
+
setConnectionStatus("none");
|
|
116
|
+
setConnectionData({ connectionId: null });
|
|
117
|
+
return [3 /*break*/, 5];
|
|
118
|
+
case 4:
|
|
119
|
+
setIsLoading(false);
|
|
120
|
+
return [7 /*endfinally*/];
|
|
121
|
+
case 5: return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); }, [userId, user === null || user === void 0 ? void 0 : user.id, getConnectionStatus]);
|
|
125
|
+
useEffect(function () {
|
|
126
|
+
loadConnectionStatus();
|
|
127
|
+
}, [loadConnectionStatus]);
|
|
128
|
+
var sendConnectionRequest = useCallback(function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
129
|
+
var result, error_2;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0:
|
|
133
|
+
if ((connectionStatus !== "none" && connectionStatus !== "declined-received") ||
|
|
134
|
+
isLoading ||
|
|
135
|
+
(user === null || user === void 0 ? void 0 : user.id) === userId)
|
|
136
|
+
return [2 /*return*/];
|
|
137
|
+
_a.label = 1;
|
|
138
|
+
case 1:
|
|
139
|
+
_a.trys.push([1, 3, , 4]);
|
|
140
|
+
return [4 /*yield*/, requestConnection({ userId: userId, message: message })];
|
|
141
|
+
case 2:
|
|
142
|
+
result = _a.sent();
|
|
143
|
+
setConnectionStatus("pending-sent");
|
|
144
|
+
setConnectionData({
|
|
145
|
+
connectionId: result.id,
|
|
146
|
+
type: "sent",
|
|
147
|
+
createdAt: result.createdAt,
|
|
148
|
+
});
|
|
149
|
+
return [3 /*break*/, 4];
|
|
150
|
+
case 3:
|
|
151
|
+
error_2 = _a.sent();
|
|
152
|
+
console.error("Failed to send connection request:", error_2);
|
|
153
|
+
throw error_2;
|
|
154
|
+
case 4: return [2 /*return*/];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); }, [connectionStatus, isLoading, userId, user === null || user === void 0 ? void 0 : user.id, requestConnection]);
|
|
158
|
+
var acceptConnectionRequest = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
159
|
+
var error_3;
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
switch (_a.label) {
|
|
162
|
+
case 0:
|
|
163
|
+
if (connectionStatus !== "pending-received" ||
|
|
164
|
+
!connectionData.connectionId ||
|
|
165
|
+
isLoading)
|
|
166
|
+
return [2 /*return*/];
|
|
167
|
+
_a.label = 1;
|
|
168
|
+
case 1:
|
|
169
|
+
_a.trys.push([1, 4, , 5]);
|
|
170
|
+
return [4 /*yield*/, acceptConnection({
|
|
171
|
+
connectionId: connectionData.connectionId,
|
|
172
|
+
})];
|
|
173
|
+
case 2:
|
|
174
|
+
_a.sent();
|
|
175
|
+
setConnectionStatus("connected");
|
|
176
|
+
// Reload to get the updated connection data with dates
|
|
177
|
+
return [4 /*yield*/, loadConnectionStatus()];
|
|
178
|
+
case 3:
|
|
179
|
+
// Reload to get the updated connection data with dates
|
|
180
|
+
_a.sent();
|
|
181
|
+
return [3 /*break*/, 5];
|
|
182
|
+
case 4:
|
|
183
|
+
error_3 = _a.sent();
|
|
184
|
+
console.error("Failed to accept connection request:", error_3);
|
|
185
|
+
throw error_3;
|
|
186
|
+
case 5: return [2 /*return*/];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}); }, [
|
|
190
|
+
connectionStatus,
|
|
191
|
+
connectionData.connectionId,
|
|
192
|
+
isLoading,
|
|
193
|
+
acceptConnection,
|
|
194
|
+
loadConnectionStatus,
|
|
195
|
+
]);
|
|
196
|
+
var declineConnectionRequest = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
197
|
+
var result, error_4;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
if (connectionStatus !== "pending-received" ||
|
|
202
|
+
!connectionData.connectionId ||
|
|
203
|
+
isLoading)
|
|
204
|
+
return [2 /*return*/];
|
|
205
|
+
_a.label = 1;
|
|
206
|
+
case 1:
|
|
207
|
+
_a.trys.push([1, 3, , 4]);
|
|
208
|
+
return [4 /*yield*/, declineConnection({ connectionId: connectionData.connectionId })];
|
|
209
|
+
case 2:
|
|
210
|
+
result = _a.sent();
|
|
211
|
+
// When you decline someone, from your perspective it's "declined-received"
|
|
212
|
+
// (you received and declined their request)
|
|
213
|
+
setConnectionStatus("declined-received");
|
|
214
|
+
setConnectionData({
|
|
215
|
+
connectionId: connectionData.connectionId,
|
|
216
|
+
respondedAt: result.respondedAt,
|
|
217
|
+
type: "received",
|
|
218
|
+
});
|
|
219
|
+
return [3 /*break*/, 4];
|
|
220
|
+
case 3:
|
|
221
|
+
error_4 = _a.sent();
|
|
222
|
+
console.error("Failed to decline connection request:", error_4);
|
|
223
|
+
throw error_4;
|
|
224
|
+
case 4: return [2 /*return*/];
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}); }, [
|
|
228
|
+
connectionStatus,
|
|
229
|
+
connectionData.connectionId,
|
|
230
|
+
isLoading,
|
|
231
|
+
declineConnection,
|
|
232
|
+
]);
|
|
233
|
+
var withdrawConnectionRequest = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
234
|
+
var error_5;
|
|
235
|
+
return __generator(this, function (_a) {
|
|
236
|
+
switch (_a.label) {
|
|
237
|
+
case 0:
|
|
238
|
+
if (connectionStatus !== "pending-sent" ||
|
|
239
|
+
!connectionData.connectionId ||
|
|
240
|
+
isLoading)
|
|
241
|
+
return [2 /*return*/];
|
|
242
|
+
_a.label = 1;
|
|
243
|
+
case 1:
|
|
244
|
+
_a.trys.push([1, 3, , 4]);
|
|
245
|
+
return [4 /*yield*/, removeConnection({ connectionId: connectionData.connectionId })];
|
|
246
|
+
case 2:
|
|
247
|
+
_a.sent();
|
|
248
|
+
setConnectionStatus("none");
|
|
249
|
+
setConnectionData({ connectionId: null });
|
|
250
|
+
return [3 /*break*/, 4];
|
|
251
|
+
case 3:
|
|
252
|
+
error_5 = _a.sent();
|
|
253
|
+
console.error("Failed to withdraw connection request:", error_5);
|
|
254
|
+
throw error_5;
|
|
255
|
+
case 4: return [2 /*return*/];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}); }, [
|
|
259
|
+
connectionStatus,
|
|
260
|
+
connectionData.connectionId,
|
|
261
|
+
isLoading,
|
|
262
|
+
removeConnection,
|
|
263
|
+
]);
|
|
264
|
+
var disconnectUser = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
265
|
+
var error_6;
|
|
266
|
+
return __generator(this, function (_a) {
|
|
267
|
+
switch (_a.label) {
|
|
268
|
+
case 0:
|
|
269
|
+
if (connectionStatus !== "connected" ||
|
|
270
|
+
!connectionData.connectionId ||
|
|
271
|
+
isLoading)
|
|
272
|
+
return [2 /*return*/];
|
|
273
|
+
_a.label = 1;
|
|
274
|
+
case 1:
|
|
275
|
+
_a.trys.push([1, 3, , 4]);
|
|
276
|
+
return [4 /*yield*/, removeConnection({ connectionId: connectionData.connectionId })];
|
|
277
|
+
case 2:
|
|
278
|
+
_a.sent();
|
|
279
|
+
setConnectionStatus("none");
|
|
280
|
+
setConnectionData({ connectionId: null });
|
|
281
|
+
return [3 /*break*/, 4];
|
|
282
|
+
case 3:
|
|
283
|
+
error_6 = _a.sent();
|
|
284
|
+
console.error("Failed to disconnect user:", error_6);
|
|
285
|
+
throw error_6;
|
|
286
|
+
case 4: return [2 /*return*/];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}); }, [
|
|
290
|
+
connectionStatus,
|
|
291
|
+
connectionData.connectionId,
|
|
292
|
+
isLoading,
|
|
293
|
+
removeConnection,
|
|
294
|
+
]);
|
|
295
|
+
var removeConnectionSmart = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
296
|
+
var error_7;
|
|
297
|
+
return __generator(this, function (_a) {
|
|
298
|
+
switch (_a.label) {
|
|
299
|
+
case 0:
|
|
300
|
+
if (connectionStatus === "none" ||
|
|
301
|
+
connectionStatus === "declined-sent" ||
|
|
302
|
+
isLoading ||
|
|
303
|
+
(user === null || user === void 0 ? void 0 : user.id) === userId)
|
|
304
|
+
return [2 /*return*/];
|
|
305
|
+
_a.label = 1;
|
|
306
|
+
case 1:
|
|
307
|
+
_a.trys.push([1, 3, , 4]);
|
|
308
|
+
return [4 /*yield*/, removeConnectionByUserId({ userId: userId })];
|
|
309
|
+
case 2:
|
|
310
|
+
_a.sent();
|
|
311
|
+
setConnectionStatus("none");
|
|
312
|
+
setConnectionData({ connectionId: null });
|
|
313
|
+
return [3 /*break*/, 4];
|
|
314
|
+
case 3:
|
|
315
|
+
error_7 = _a.sent();
|
|
316
|
+
console.error("Failed to remove connection:", error_7);
|
|
317
|
+
throw error_7;
|
|
318
|
+
case 4: return [2 /*return*/];
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}); }, [connectionStatus, isLoading, userId, user === null || user === void 0 ? void 0 : user.id, removeConnectionByUserId]);
|
|
322
|
+
return {
|
|
323
|
+
connectionStatus: connectionStatus,
|
|
324
|
+
connectionId: connectionData.connectionId,
|
|
325
|
+
connectionData: connectionData,
|
|
326
|
+
isLoading: isLoading,
|
|
327
|
+
sendConnectionRequest: sendConnectionRequest,
|
|
328
|
+
acceptConnectionRequest: acceptConnectionRequest,
|
|
329
|
+
declineConnectionRequest: declineConnectionRequest,
|
|
330
|
+
withdrawConnectionRequest: withdrawConnectionRequest,
|
|
331
|
+
disconnectUser: disconnectUser,
|
|
332
|
+
removeConnectionSmart: removeConnectionSmart,
|
|
333
|
+
refreshConnectionStatus: loadConnectionStatus,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
export default useConnectionManager;
|
|
337
|
+
//# sourceMappingURL=useConnectionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnectionManager.js","sourceRoot":"","sources":["../../../../../src/hooks/relationships/connections/useConnectionManager.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,2BAA2B,MAAM,+BA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SAA0C,CAAC;oBAC3C,mBAAmB,CAAC,MAAM,CAAC,CAAC;oBAC5B,iBAAiB,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;;;;oBAE1C,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,OAAK,CAAC,CAAC;oBACrD,MAAM,OAAK,CAAC;;;;SAEf,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,EAAE,EAAE,wBAAwB,CAAC,CAAC,CAAC;IAE9E,OAAO;QACL,gBAAgB,kBAAA;QAChB,YAAY,EAAE,cAAc,CAAC,YAAY;QACzC,cAAc,gBAAA;QACd,SAAS,WAAA;QACT,qBAAqB,uBAAA;QACrB,uBAAuB,yBAAA;QACvB,wBAAwB,0BAAA;QACxB,yBAAyB,2BAAA;QACzB,cAAc,gBAAA;QACd,qBAAqB,uBAAA;QACrB,uBAAuB,EAAE,oBAAoB;KAC9C,CAAC;AACJ,CAAC;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { useCallback } from "react";
|
|
38
|
+
import useAxiosPrivate from "../../../config/useAxiosPrivate";
|
|
39
|
+
import useProject from "../../projects/useProject";
|
|
40
|
+
import { useUser } from "../../user";
|
|
41
|
+
function useDeclineConnection() {
|
|
42
|
+
var _this = this;
|
|
43
|
+
var axios = useAxiosPrivate();
|
|
44
|
+
var projectId = useProject().projectId;
|
|
45
|
+
var user = useUser().user;
|
|
46
|
+
var declineConnection = useCallback(function (props) { return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
+
var connectionId, response;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
connectionId = props.connectionId;
|
|
52
|
+
if (!projectId) {
|
|
53
|
+
throw new Error("No project specified");
|
|
54
|
+
}
|
|
55
|
+
if (!user) {
|
|
56
|
+
throw new Error("No user is logged in");
|
|
57
|
+
}
|
|
58
|
+
if (!connectionId) {
|
|
59
|
+
throw new Error("No connection ID was provided");
|
|
60
|
+
}
|
|
61
|
+
return [4 /*yield*/, axios.put("/connections/".concat(connectionId, "/decline"), {}, { withCredentials: true })];
|
|
62
|
+
case 1:
|
|
63
|
+
response = _a.sent();
|
|
64
|
+
return [2 /*return*/, response.data];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}); }, [axios, projectId, user]);
|
|
68
|
+
return declineConnection;
|
|
69
|
+
}
|
|
70
|
+
export default useDeclineConnection;
|
|
71
|
+
//# sourceMappingURL=useDeclineConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeclineConnection.js","sourceRoot":"","sources":["../../../../../src/hooks/relationships/connections/useDeclineConnection.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,SAAS,oBAAoB;IAA7B,iBAgCC;IA/BC,IAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IACxB,IAAA,SAAS,GAAK,UAAU,EAAE,UAAjB,CAAkB;IAC3B,IAAA,IAAI,GAAK,OAAO,EAAE,KAAd,CAAe;IAE3B,IAAM,iBAAiB,GAAG,WAAW,CACnC,UAAO,KAA+B;;;;;oBAC5B,YAAY,GAAK,KAAK,aAAV,CAAW;oBAC/B,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBAED,IAAI,CAAC,IAAI,EAAE,CAAC;wBACV,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBAED,IAAI,CAAC,YAAY,EAAE,CAAC;wBAClB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;oBACnD,CAAC;oBAEgB,qBAAM,KAAK,CAAC,GAAG,CAC9B,uBAAgB,YAAY,aAAU,EACtC,EAAE,EACF,EAAE,eAAe,EAAE,IAAI,EAAE,CAC1B,EAAA;;oBAJK,QAAQ,GAAG,SAIhB;oBAED,sBAAO,QAAQ,CAAC,IAAgC,EAAC;;;SAClD,EACD,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,CACzB,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { useCallback } from "react";
|
|
38
|
+
import useAxiosPrivate from "../../../config/useAxiosPrivate";
|
|
39
|
+
import useProject from "../../projects/useProject";
|
|
40
|
+
import { useUser } from "../../user";
|
|
41
|
+
function useFetchConnectionStatus() {
|
|
42
|
+
var _this = this;
|
|
43
|
+
var axios = useAxiosPrivate();
|
|
44
|
+
var projectId = useProject().projectId;
|
|
45
|
+
var user = useUser().user;
|
|
46
|
+
var getConnectionStatus = useCallback(function (props) { return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
+
var userId, response;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
userId = props.userId;
|
|
52
|
+
if (!projectId) {
|
|
53
|
+
throw new Error("No project specified");
|
|
54
|
+
}
|
|
55
|
+
if (!user) {
|
|
56
|
+
throw new Error("No user is logged in");
|
|
57
|
+
}
|
|
58
|
+
if (!userId) {
|
|
59
|
+
throw new Error("No user ID was provided");
|
|
60
|
+
}
|
|
61
|
+
if (userId === user.id) {
|
|
62
|
+
throw new Error("Cannot check connection status with yourself");
|
|
63
|
+
}
|
|
64
|
+
return [4 /*yield*/, axios.get("/users/".concat(userId, "/connection"), { withCredentials: true })];
|
|
65
|
+
case 1:
|
|
66
|
+
response = _a.sent();
|
|
67
|
+
return [2 /*return*/, response.data];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}); }, [axios, projectId, user]);
|
|
71
|
+
return getConnectionStatus;
|
|
72
|
+
}
|
|
73
|
+
export default useFetchConnectionStatus;
|
|
74
|
+
//# sourceMappingURL=useFetchConnectionStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchConnectionStatus.js","sourceRoot":"","s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AO,mBAAmB,CAAC;AAC7B,CAAC;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConnectionsResponse } from "../../../interfaces/models/Connection";
|
|
2
|
+
interface FetchConnectionsParams {
|
|
3
|
+
page?: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
}
|
|
6
|
+
declare function useFetchConnections(): (props?: FetchConnectionsParams) => Promise<ConnectionsResponse>;
|
|
7
|
+
export default useFetchConnections;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
import { useCallback } from "react";
|
|
47
|
+
import useAxiosPrivate from "../../../config/useAxiosPrivate";
|
|
48
|
+
import useProject from "../../projects/useProject";
|
|
49
|
+
import { useUser } from "../../user";
|
|
50
|
+
function useFetchConnections() {
|
|
51
|
+
var _this = this;
|
|
52
|
+
var axios = useAxiosPrivate();
|
|
53
|
+
var projectId = useProject().projectId;
|
|
54
|
+
var user = useUser().user;
|
|
55
|
+
var fetchConnections = useCallback(function () {
|
|
56
|
+
var args_1 = [];
|
|
57
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
58
|
+
args_1[_i] = arguments[_i];
|
|
59
|
+
}
|
|
60
|
+
return __awaiter(_this, __spreadArray([], args_1, true), void 0, function (props) {
|
|
61
|
+
var _a, page, _b, limit, response;
|
|
62
|
+
if (props === void 0) { props = {}; }
|
|
63
|
+
return __generator(this, function (_c) {
|
|
64
|
+
switch (_c.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
_a = props.page, page = _a === void 0 ? 1 : _a, _b = props.limit, limit = _b === void 0 ? 20 : _b;
|
|
67
|
+
if (!projectId) {
|
|
68
|
+
throw new Error("No project specified");
|
|
69
|
+
}
|
|
70
|
+
if (!user) {
|
|
71
|
+
throw new Error("No user is logged in");
|
|
72
|
+
}
|
|
73
|
+
return [4 /*yield*/, axios.get("/connections", {
|
|
74
|
+
params: {
|
|
75
|
+
page: page,
|
|
76
|
+
limit: limit,
|
|
77
|
+
},
|
|
78
|
+
withCredentials: true,
|
|
79
|
+
})];
|
|
80
|
+
case 1:
|
|
81
|
+
response = _c.sent();
|
|
82
|
+
return [2 /*return*/, response.data];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}, [axios, projectId, user]);
|
|
87
|
+
return fetchConnections;
|
|
88
|
+
}
|
|
89
|
+
export default useFetchConnections;
|
|
90
|
+
//# sourceMappingURL=useFetchConnections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchConnections.js","sourceRoot":"","sources":["../../../../../src/hooks/relationships/connections/useFetchConnections.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAA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