@oxyhq/services 0.0.76 → 0.0.78
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/components/auth/AccountSwitcherModal.js +1 -1
- package/dist/components/auth/SessionOwnerButton.d.ts.map +1 -1
- package/dist/components/auth/SignInButton.js +1 -1
- package/dist/components/auth/styles/account-switcher-modal.module.css +35 -0
- package/dist/components/auth/styles/account-switcher-modal.module.css.map +1 -0
- package/dist/components/auth/styles/session-owner-modal.module.css +35 -0
- package/dist/components/auth/styles/session-owner-modal.module.css.map +1 -0
- package/dist/components/elements/ellipsis-wrapper/components/ellipsis-wrapper.d.ts +5 -0
- package/dist/components/elements/ellipsis-wrapper/components/ellipsis-wrapper.d.ts.map +1 -0
- package/dist/components/elements/ellipsis-wrapper/components/ellipsis-wrapper.js +4 -0
- package/dist/components/elements/ellipsis-wrapper/index.d.ts +1 -1
- package/dist/components/elements/ellipsis-wrapper/index.d.ts.map +1 -1
- package/dist/components/elements/ellipsis-wrapper/index.js +1 -1
- package/dist/components/elements/modal/components/confirmation-modal.js +1 -1
- package/dist/components/elements/modal/components/modal.js +1 -1
- package/dist/features/profile/components/user-name.js +1 -1
- package/dist/features/profile/components/user-username.js +1 -1
- package/dist/index.css +2 -0
- package/package.json +5 -7
- package/dist/assets/dot-icon.tsx +0 -11
- package/dist/assets/verified-icon.tsx +0 -19
- package/dist/components/assets/oxy-logo.tsx +0 -97
- package/dist/components/auth/AccountSwitcherModal.tsx +0 -139
- package/dist/components/auth/SessionOwnerButton.tsx +0 -67
- package/dist/components/auth/SignInButton.tsx +0 -31
- package/dist/components/auth/styles/oavatar.module.scss +0 -36
- package/dist/components/auth/styles/sign-in-button.module.scss +0 -32
- package/dist/components/elements/button/components/button.tsx +0 -35
- package/dist/components/elements/button/components/styles/button.module.scss +0 -27
- package/dist/components/elements/button/index.ts +0 -1
- package/dist/components/elements/ellipsis-wrapper/components/EllipsisWrapper.tsx +0 -18
- package/dist/components/elements/ellipsis-wrapper/components/styles/ellipses-wrapper.module.scss +0 -10
- package/dist/components/elements/ellipsis-wrapper/index.ts +0 -1
- package/dist/components/elements/modal/components/confirmation-modal.tsx +0 -62
- package/dist/components/elements/modal/components/modal.tsx +0 -182
- package/dist/components/elements/modal/components/styles/confirmation-modal.module.scss +0 -125
- package/dist/components/elements/modal/components/styles/modal.module.scss +0 -8
- package/dist/components/elements/modal/hooks/use-track-position.ts +0 -49
- package/dist/components/elements/modal/index.ts +0 -3
- package/dist/config/index.ts +0 -17
- package/dist/features/profile/components/avatar.tsx +0 -30
- package/dist/features/profile/components/styles/avatar.module.scss +0 -14
- package/dist/features/profile/components/styles/user-name.module.scss +0 -19
- package/dist/features/profile/components/styles/user-username.module.scss +0 -4
- package/dist/features/profile/components/user-name.tsx +0 -21
- package/dist/features/profile/components/user-username.tsx +0 -10
- package/dist/features/profile/index.ts +0 -3
- package/dist/hooks/get-user.ts +0 -30
- package/dist/hooks/getUserById.ts +0 -43
- package/dist/hooks/use-user.ts +0 -25
- package/dist/hooks/useOxySession.ts +0 -104
- package/dist/index.ts +0 -13
- package/dist/interfaces/index.tsx +0 -22
- package/dist/types/index.ts +0 -1
- package/dist/utils/cn.ts +0 -6
package/dist/hooks/get-user.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { OXY_AUTH_URL } from "../config";
|
|
3
|
-
|
|
4
|
-
export const getUser = async (id: string | undefined) => {
|
|
5
|
-
if (!id) {
|
|
6
|
-
throw new Error("User ID is required");
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
const response = await axios.get(OXY_AUTH_URL + `/api/users/${id}`);
|
|
10
|
-
return response.data;
|
|
11
|
-
} catch (error: any) {
|
|
12
|
-
if (axios.isAxiosError(error)) {
|
|
13
|
-
if (error.response) {
|
|
14
|
-
// Server responded with a status code outside of 2xx
|
|
15
|
-
throw new Error(
|
|
16
|
-
`Server responded with status ${error.response.status}: ${error.response.data}`
|
|
17
|
-
);
|
|
18
|
-
} else if (error.request) {
|
|
19
|
-
// Request was made but no response received
|
|
20
|
-
throw new Error("No response received from server");
|
|
21
|
-
} else {
|
|
22
|
-
// Error setting up the request
|
|
23
|
-
throw new Error(`Axios error: ${error.message}`);
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
// Non-Axios error
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { OXY_AUTH_URL } from "../config";
|
|
3
|
-
|
|
4
|
-
interface User {
|
|
5
|
-
id: string;
|
|
6
|
-
username: string;
|
|
7
|
-
name: string;
|
|
8
|
-
email: string;
|
|
9
|
-
role: string;
|
|
10
|
-
avatar: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const getUserById = async (id?: string | string[], fields?: (keyof User)[]) => {
|
|
14
|
-
try {
|
|
15
|
-
const response = await axios.get(OXY_AUTH_URL + `/api/users/${id}`);
|
|
16
|
-
if (response.status !== 200) {
|
|
17
|
-
throw new Error(`Unexpected response status: ${response.status}`);
|
|
18
|
-
}
|
|
19
|
-
const user = fields
|
|
20
|
-
? fields.reduce(
|
|
21
|
-
(obj, key) => ({ ...obj, [key]: response.data[key] }),
|
|
22
|
-
{} as User
|
|
23
|
-
)
|
|
24
|
-
: (response.data as User);
|
|
25
|
-
return user;
|
|
26
|
-
} catch (error) {
|
|
27
|
-
if (axios.isAxiosError(error)) {
|
|
28
|
-
if (error.response) {
|
|
29
|
-
throw new Error(
|
|
30
|
-
`Network error: ${error.message}, Status code: ${error.response.status}`
|
|
31
|
-
);
|
|
32
|
-
} else if (error.request) {
|
|
33
|
-
throw new Error("Network error: No response received from server.");
|
|
34
|
-
} else {
|
|
35
|
-
throw new Error(`Network error: ${error.message}`);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
throw new Error("An unknown error occurred while loading the user data.");
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default getUserById;
|
package/dist/hooks/use-user.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getUser } from "./get-user";
|
|
2
|
-
|
|
3
|
-
export interface IUser {
|
|
4
|
-
id: string;
|
|
5
|
-
username: string;
|
|
6
|
-
name: string;
|
|
7
|
-
email: string;
|
|
8
|
-
role: string;
|
|
9
|
-
avatar: string;
|
|
10
|
-
color: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const useUser = async ({
|
|
14
|
-
id,
|
|
15
|
-
initialData: IUser,
|
|
16
|
-
}: {
|
|
17
|
-
id: string | undefined;
|
|
18
|
-
initialData?: IUser;
|
|
19
|
-
}) => {
|
|
20
|
-
if (!id) {
|
|
21
|
-
// Return a default value or null when id is not provided
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return getUser(id);
|
|
25
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import { create } from "zustand";
|
|
4
|
-
import localforage from "localforage";
|
|
5
|
-
|
|
6
|
-
import { OXY_AUTH_URL } from "../config";
|
|
7
|
-
import { UserRole } from "../types";
|
|
8
|
-
|
|
9
|
-
interface SessionModel {
|
|
10
|
-
user: {
|
|
11
|
-
id: string;
|
|
12
|
-
username: string;
|
|
13
|
-
name: string;
|
|
14
|
-
lastname: string;
|
|
15
|
-
email: string;
|
|
16
|
-
verified: boolean;
|
|
17
|
-
avatar: string;
|
|
18
|
-
created_at: string;
|
|
19
|
-
role: UserRole;
|
|
20
|
-
isOAuth: boolean;
|
|
21
|
-
isTwoFactorEnabled: boolean;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type SessionState = {
|
|
26
|
-
session: SessionModel | null;
|
|
27
|
-
status: string;
|
|
28
|
-
error: any;
|
|
29
|
-
fetchSessionData: () => void;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const useSessionStore = create<SessionState>((set) => {
|
|
33
|
-
let isFirstFetch = true;
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
session: null,
|
|
37
|
-
status: "loading",
|
|
38
|
-
error: null,
|
|
39
|
-
fetchSessionData: async () => {
|
|
40
|
-
try {
|
|
41
|
-
if (isFirstFetch) {
|
|
42
|
-
set({ status: "loading" });
|
|
43
|
-
isFirstFetch = false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Get the session ID from the URL parameters if it exists
|
|
47
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
48
|
-
let clientKey = urlParams.get("clientKey");
|
|
49
|
-
|
|
50
|
-
// If the session ID was not found in the URL parameters, get it from local storage
|
|
51
|
-
if (!clientKey) {
|
|
52
|
-
clientKey = await localforage.getItem<string>("clientKey");
|
|
53
|
-
} else {
|
|
54
|
-
// If the session ID was found in the URL parameters, set it in local storage
|
|
55
|
-
await localforage.setItem<string>("clientKey", clientKey);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const response = await axios.get(
|
|
59
|
-
OXY_AUTH_URL + "/api/session/" + clientKey
|
|
60
|
-
);
|
|
61
|
-
if (response.status !== 200) {
|
|
62
|
-
throw new Error(`Unexpected response status: ${response.status}`);
|
|
63
|
-
}
|
|
64
|
-
set({ session: response.data, status: "success" });
|
|
65
|
-
} catch (error) {
|
|
66
|
-
if (axios.isAxiosError(error)) {
|
|
67
|
-
if (error.response) {
|
|
68
|
-
set({
|
|
69
|
-
error: `Network error: ${error.message}, Status code: ${error.response.status}`,
|
|
70
|
-
status: "error",
|
|
71
|
-
});
|
|
72
|
-
} else if (error.request) {
|
|
73
|
-
set({
|
|
74
|
-
error: "Network error: No response received from server.",
|
|
75
|
-
status: "error",
|
|
76
|
-
});
|
|
77
|
-
} else {
|
|
78
|
-
set({
|
|
79
|
-
error: `Network error: ${error.message}`,
|
|
80
|
-
status: "error",
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
set({
|
|
85
|
-
error: "An unknown error occurred while loading the session data.",
|
|
86
|
-
status: "error",
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
function useOxySession() {
|
|
95
|
-
const { session, status, error, fetchSessionData } = useSessionStore();
|
|
96
|
-
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
fetchSessionData();
|
|
99
|
-
}, []);
|
|
100
|
-
|
|
101
|
-
return { session, status, error };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export default useOxySession;
|
package/dist/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import useOxySession from "./hooks/useOxySession";
|
|
2
|
-
import getUserById from "./hooks/getUserById";
|
|
3
|
-
import SignInButton from "./components/auth/SignInButton";
|
|
4
|
-
import { AccountSwitcherModal } from "./components/auth/AccountSwitcherModal";
|
|
5
|
-
import { SessionOwnerButton } from "./components/auth/SessionOwnerButton";
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
useOxySession,
|
|
9
|
-
getUserById,
|
|
10
|
-
SignInButton,
|
|
11
|
-
AccountSwitcherModal,
|
|
12
|
-
SessionOwnerButton,
|
|
13
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
interface SessionModel {
|
|
2
|
-
user: {
|
|
3
|
-
id: string;
|
|
4
|
-
username: string;
|
|
5
|
-
name: string;
|
|
6
|
-
lastname: string;
|
|
7
|
-
email: string;
|
|
8
|
-
verified: boolean;
|
|
9
|
-
avatar: string;
|
|
10
|
-
created_at: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface IUser {
|
|
15
|
-
id: string;
|
|
16
|
-
username: string;
|
|
17
|
-
name: string;
|
|
18
|
-
email: string;
|
|
19
|
-
role: string;
|
|
20
|
-
avatar: string;
|
|
21
|
-
color: string;
|
|
22
|
-
}
|
package/dist/types/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type UserRole = "ADMIN" | "USER" | "MODERATOR";
|