@oxyhq/services 0.0.61 → 0.0.63
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/README.md +8 -1
- package/dist/components/auth/AccountSwitcherModal.d.ts.map +1 -1
- package/dist/components/auth/AccountSwitcherModal.js +14 -2
- package/dist/components/auth/SessionOwnerButton.d.ts.map +1 -1
- package/dist/components/auth/SessionOwnerButton.js +8 -3
- package/dist/components/elements/button/components/button.d.ts.map +1 -1
- package/dist/components/elements/button/components/button.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Oxy Services Module 🚀
|
|
2
|
+
|
|
3
|
+
The Oxy Services Module is a comprehensive package designed to provide reusable services and components for building front-end applications with Oxy. It includes hooks and components for session management, user handling, and more, making it easier to integrate Oxy-based functionalities into your React applications.
|
|
4
|
+
|
|
5
|
+
## Features ✨
|
|
6
|
+
- **Session Management**: Easily manage user sessions with hooks like `useOxySession`.
|
|
7
|
+
- **User Handling**: Fetch and display user information using functions like `getUserById`.
|
|
8
|
+
- **Components**: Ready-to-use components such as `SignInButton`, `AccountSwitcherModal`, and `SessionOwnerButton`.
|
|
2
9
|
|
|
3
10
|
## Usage Instructions
|
|
4
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountSwitcherModal.d.ts","sourceRoot":"","sources":["../../../src/components/auth/AccountSwitcherModal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B,eAAO,MAAM,oBAAoB;aAEpB,MAAM,IAAI;
|
|
1
|
+
{"version":3,"file":"AccountSwitcherModal.d.ts","sourceRoot":"","sources":["../../../src/components/auth/AccountSwitcherModal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B,eAAO,MAAM,oBAAoB;aAEpB,MAAM,IAAI;2CAoFrB,CAAC"}
|
|
@@ -13,10 +13,21 @@ import styles from "./styles/session-owner-modal.module.css";
|
|
|
13
13
|
export const AccountSwitcherModal = forwardRef(({ onClose }, ref) => {
|
|
14
14
|
const { session } = useOxySession();
|
|
15
15
|
const [user, setUser] = useState(null);
|
|
16
|
+
const [error, setError] = useState(null);
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
const fetchUser = async () => {
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
try {
|
|
20
|
+
const fetchedUser = await getUserById(session?.user?.id);
|
|
21
|
+
setUser(fetchedUser);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error instanceof Error) {
|
|
25
|
+
setError(error.message);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
setError("An unknown error occurred");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
20
31
|
};
|
|
21
32
|
if (session) {
|
|
22
33
|
fetchUser();
|
|
@@ -25,6 +36,7 @@ export const AccountSwitcherModal = forwardRef(({ onClose }, ref) => {
|
|
|
25
36
|
if (!session)
|
|
26
37
|
return null;
|
|
27
38
|
const handleBackdropClick = (e) => {
|
|
39
|
+
e.stopPropagation();
|
|
28
40
|
if (e.currentTarget === e.target) {
|
|
29
41
|
onClose();
|
|
30
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionOwnerButton.d.ts","sourceRoot":"","sources":["../../../src/components/auth/SessionOwnerButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"SessionOwnerButton.d.ts","sourceRoot":"","sources":["../../../src/components/auth/SessionOwnerButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,eAAO,MAAM,kBAAkB,yBAuD9B,CAAC"}
|
|
@@ -10,12 +10,17 @@ import { Modal } from "../../components/elements/modal";
|
|
|
10
10
|
import { Avatar, UserName, UserUsername } from "../../features/profile";
|
|
11
11
|
import { AccountSwitcherModal } from "./AccountSwitcherModal";
|
|
12
12
|
export const SessionOwnerButton = () => {
|
|
13
|
-
const { session } = useOxySession();
|
|
13
|
+
const { session, error } = useOxySession();
|
|
14
14
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
15
15
|
const buttonRef = useRef(null);
|
|
16
|
-
const openModal = () => {
|
|
16
|
+
const openModal = React.useCallback(() => {
|
|
17
17
|
setIsModalOpen(true);
|
|
18
|
-
};
|
|
18
|
+
}, []);
|
|
19
|
+
if (error) {
|
|
20
|
+
return React.createElement("div", null,
|
|
21
|
+
"Error: ",
|
|
22
|
+
error);
|
|
23
|
+
}
|
|
19
24
|
return (React.createElement(React.Fragment, null,
|
|
20
25
|
React.createElement(Button, { "aria-label": "Account menu", onClick: openModal, ref: buttonRef, "aria-haspopup": "menu", "aria-expanded": isModalOpen, className: "p-[0.75em] hover:bg-neutral-500 focus-visible:bg-neutral-500 focus-visible:outline-secondary-100 active:bg-neutral-600 xxl:flex xxl:w-full xxl:gap-3" },
|
|
21
26
|
React.createElement(Avatar, { userImage: session?.user?.avatar }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../../src/components/elements/button/components/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,UAAU,OAAQ,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../../src/components/elements/button/components/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,UAAU,OAAQ,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,mFAwBlB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { cn } from "../../../../utils/cn";
|
|
3
3
|
export const Button = forwardRef(({ children, className, ...props }, ref) => {
|
|
4
|
-
return (React.createElement("button", { ref: ref, ...props, className: cn("grid cursor-pointer place-items-center rounded-full", "transition-colors duration-200 ease-in-out", "fill-secondary-100 p-[0.5em]", "focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary-100", "fill-secondary-100 [&>svg]:w-h2", "disabled-button", className) }, children));
|
|
4
|
+
return (React.createElement("button", { ref: ref, ...props, className: cn("grid cursor-pointer place-items-center rounded-full", "transition-colors duration-200 ease-in-out", "fill-secondary-100 p-[0.5em]", "focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary-100", "fill-secondary-100 [&>svg]:w-h2", "disabled-button", className, "hover:bg-neutral-500 active:bg-neutral-600", "focus-visible:bg-neutral-500 focus-visible:outline-secondary-100"), "aria-pressed": props["aria-pressed"], "aria-disabled": props.disabled }, children));
|
|
5
5
|
});
|
|
6
6
|
Button.displayName = "Button";
|
package/package.json
CHANGED