@oxyhq/services 0.0.70 → 0.0.72
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.d.ts +4 -2
- package/dist/components/auth/AccountSwitcherModal.d.ts.map +1 -1
- package/dist/components/auth/AccountSwitcherModal.js +4 -3
- package/dist/components/auth/SessionOwnerButton.d.ts.map +1 -1
- package/dist/components/auth/SessionOwnerButton.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/hooks/get-user.d.ts.map +1 -1
- package/dist/hooks/get-user.js +18 -15
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
interface AccountSwitcherModalProps {
|
|
3
3
|
onClose: () => void;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
|
+
export declare const AccountSwitcherModal: React.ForwardRefExoticComponent<AccountSwitcherModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export {};
|
|
5
7
|
//# sourceMappingURL=AccountSwitcherModal.d.ts.map
|
|
@@ -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,
|
|
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,UAAU,yBAAyB;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,oBAAoB,kGA0G/B,CAAC"}
|
|
@@ -9,8 +9,9 @@ import { PiSignOutBold } from "react-icons/pi";
|
|
|
9
9
|
import { AiOutlineClose } from "react-icons/ai";
|
|
10
10
|
import { Avatar } from "../../features/profile";
|
|
11
11
|
import getUserById from "../../hooks/getUserById";
|
|
12
|
-
import styles from "./styles/
|
|
13
|
-
export const AccountSwitcherModal = forwardRef((
|
|
12
|
+
import styles from "./styles/account-switcher-modal.module.css";
|
|
13
|
+
export const AccountSwitcherModal = forwardRef((props, ref) => {
|
|
14
|
+
const { onClose } = props;
|
|
14
15
|
const { session } = useOxySession();
|
|
15
16
|
const [user, setUser] = useState(null);
|
|
16
17
|
const [error, setError] = useState(null);
|
|
@@ -44,7 +45,7 @@ export const AccountSwitcherModal = forwardRef(({ onClose }, ref) => {
|
|
|
44
45
|
return (React.createElement(motion.div, { initial: { opacity: 0, y: "100%" }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: "100%" }, transition: {
|
|
45
46
|
ease: "easeInOut",
|
|
46
47
|
duration: 0.2,
|
|
47
|
-
}, className: styles.container, role: "group", onClick: handleBackdropClick },
|
|
48
|
+
}, className: styles.container, role: "group", onClick: handleBackdropClick, ref: ref },
|
|
48
49
|
React.createElement("button", { className: "absolute right-3 top-3 rounded-full bg-indigo-50 p-1 hover:bg-zinc-200", onClick: onClose },
|
|
49
50
|
React.createElement(AiOutlineClose, { className: "h-5 w-5 rounded-full stroke-2 text-zinc-700" })),
|
|
50
51
|
React.createElement("p", null, session?.user?.email),
|
|
@@ -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,yBAoD9B,CAAC"}
|
|
@@ -31,5 +31,5 @@ export const SessionOwnerButton = () => {
|
|
|
31
31
|
React.createElement("div", { className: "hidden fill-secondary-100 xxl:inline [&>svg]:size-h2" },
|
|
32
32
|
React.createElement(DotIcon, null))),
|
|
33
33
|
React.createElement(AnimatePresence, null, isModalOpen && (React.createElement(Modal, { onClose: () => setIsModalOpen(false), background: "none", minViewportWidth: 500 },
|
|
34
|
-
React.createElement(AccountSwitcherModal, {
|
|
34
|
+
React.createElement(AccountSwitcherModal, { onClose: () => setIsModalOpen(false) }))))));
|
|
35
35
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
width: 300px;
|
|
3
|
+
background-color: var(--clr-background);
|
|
4
|
+
box-shadow: 0 0rem 10px -2px var(--clr-tertiary);
|
|
5
|
+
border-radius: 1rem;
|
|
6
|
+
padding: 0.8em 0;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
position: fixed;
|
|
9
|
+
top: 0;
|
|
10
|
+
bottom: 0;
|
|
11
|
+
left: 0;
|
|
12
|
+
right: 0;
|
|
13
|
+
margin: auto;
|
|
14
|
+
a {
|
|
15
|
+
font-size: var(--fs-milli);
|
|
16
|
+
font-weight: var(--fw-700);
|
|
17
|
+
display: block;
|
|
18
|
+
padding: 0.8em 1em;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition: background-color 0.1s ease-in-out;
|
|
21
|
+
&:hover {
|
|
22
|
+
background-color: var(--clr-trends-hover);
|
|
23
|
+
}
|
|
24
|
+
&:active {
|
|
25
|
+
background-color: var(--clr-trends-active);
|
|
26
|
+
}
|
|
27
|
+
&:focus-visible {
|
|
28
|
+
background-color: var(--clr-trends-hover);
|
|
29
|
+
outline: 2px solid var(--clr-primary-disabled);
|
|
30
|
+
outline-offset: -2px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/*# sourceMappingURL=account-switcher-modal.module.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../../../src/components/auth/styles/account-switcher-modal.module.css"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;IACE;IACA;IACA;IACA;IACA;IACA;IAEA;MACE;;IAGF;MACE;;IAGF;MACE;MACA;MACA","file":"account-switcher-modal.module.css"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-user.d.ts","sourceRoot":"","sources":["../../src/hooks/get-user.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,OAAc,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"get-user.d.ts","sourceRoot":"","sources":["../../src/hooks/get-user.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,OAAc,MAAM,GAAG,SAAS,iBA0BnD,CAAC"}
|
package/dist/hooks/get-user.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { OXY_AUTH_URL } from "../config";
|
|
3
3
|
export const getUser = async (id) => {
|
|
4
|
+
if (!id) {
|
|
5
|
+
throw new Error("User ID is required");
|
|
6
|
+
}
|
|
4
7
|
try {
|
|
5
8
|
const response = await axios.get(OXY_AUTH_URL + `/api/users/${id}`);
|
|
6
9
|
return response.data;
|
|
7
10
|
}
|
|
8
11
|
catch (error) {
|
|
9
|
-
if (error
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
if (axios.isAxiosError(error)) {
|
|
13
|
+
if (error.response) {
|
|
14
|
+
// Server responded with a status code outside of 2xx
|
|
15
|
+
throw new Error(`Server responded with status ${error.response.status}: ${error.response.data}`);
|
|
16
|
+
}
|
|
17
|
+
else if (error.request) {
|
|
18
|
+
// Request was made but no response received
|
|
19
|
+
throw new Error("No response received from server");
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// Error setting up the request
|
|
23
|
+
throw new Error(`Axios error: ${error.message}`);
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
else {
|
|
23
|
-
//
|
|
24
|
-
|
|
27
|
+
// Non-Axios error
|
|
28
|
+
throw error;
|
|
25
29
|
}
|
|
26
|
-
console.log(error.config);
|
|
27
30
|
}
|
|
28
31
|
};
|