@noya-app/noya-api-client-react 0.1.46 → 0.1.47
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +7 -0
- package/dist/index.d.mts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/react/hooks.ts +39 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-api-client-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@legendapp/state": "^2.1.1",
|
|
13
|
-
"@noya-app/noya-api": "0.1.
|
|
13
|
+
"@noya-app/noya-api": "0.1.47",
|
|
14
14
|
"@noya-app/noya-utils": "0.1.9",
|
|
15
15
|
"@noya-app/observable": "0.1.12",
|
|
16
16
|
"@noya-app/observable-store": "0.1.2",
|
package/src/react/hooks.ts
CHANGED
|
@@ -214,6 +214,45 @@ export function useNoyaWorkspaces() {
|
|
|
214
214
|
return workspaces;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
export type WorkspaceMemberInfo = {
|
|
218
|
+
userId: string;
|
|
219
|
+
name: string | null;
|
|
220
|
+
email: string | null;
|
|
221
|
+
image: string | null;
|
|
222
|
+
role: "OWNER" | "ADMIN" | "MEMBER";
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Hook to get workspace members for a specific workspace.
|
|
227
|
+
* Returns the members array and a lookup map for easy access by userId.
|
|
228
|
+
*/
|
|
229
|
+
export function useNoyaWorkspaceMembers(workspaceId: string): {
|
|
230
|
+
members: WorkspaceMemberInfo[];
|
|
231
|
+
membersById: Map<string, WorkspaceMemberInfo>;
|
|
232
|
+
loading: boolean;
|
|
233
|
+
} {
|
|
234
|
+
const { workspaces, loading } = useNoyaWorkspaces();
|
|
235
|
+
|
|
236
|
+
return useMemo(() => {
|
|
237
|
+
const workspace = workspaces.find((w) => w.id === workspaceId);
|
|
238
|
+
const members: WorkspaceMemberInfo[] =
|
|
239
|
+
workspace?.members.map((m) => ({
|
|
240
|
+
userId: m.userId,
|
|
241
|
+
name: m.user.name,
|
|
242
|
+
email: m.user.email,
|
|
243
|
+
image: m.user.image,
|
|
244
|
+
role: m.role,
|
|
245
|
+
})) ?? [];
|
|
246
|
+
|
|
247
|
+
const membersById = new Map<string, WorkspaceMemberInfo>();
|
|
248
|
+
for (const member of members) {
|
|
249
|
+
membersById.set(member.userId, member);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return { members, membersById, loading };
|
|
253
|
+
}, [workspaces, workspaceId, loading]);
|
|
254
|
+
}
|
|
255
|
+
|
|
217
256
|
export function useNoyaMultiplayerRoomToken(fileId: string) {
|
|
218
257
|
const client = useNoyaClientOrFallback();
|
|
219
258
|
const multiplayerRoomToken = useObservable(
|