@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.
@@ -1,5 +1,7 @@
1
1
  import * as React from "react";
2
- export declare const AccountSwitcherModal: React.ForwardRefExoticComponent<{
2
+ interface AccountSwitcherModalProps {
3
3
  onClose: () => void;
4
- } & React.RefAttributes<HTMLButtonElement>>;
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,eAAO,MAAM,oBAAoB;aAEpB,MAAM,IAAI;2CAsGrB,CAAC"}
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/session-owner-modal.module.css";
13
- export const AccountSwitcherModal = forwardRef(({ onClose }, ref) => {
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,yBAuD9B,CAAC"}
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, { ref: buttonRef, onClose: () => setIsModalOpen(false) }))))));
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,iBAsBnD,CAAC"}
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"}
@@ -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.response) {
10
- // The request was made and the server responded with a status code
11
- // that falls out of the range of 2xx
12
- console.log(error.response.data);
13
- console.log(error.response.status);
14
- console.log(error.response.headers);
15
- }
16
- else if (error.request) {
17
- // The request was made but no response was received
18
- // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
19
- // http.ClientRequest in node.js
20
- console.log(error.request);
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
- // Something happened in setting up the request that triggered an Error
24
- console.log("Error", error.message);
27
+ // Non-Axios error
28
+ throw error;
25
29
  }
26
- console.log(error.config);
27
30
  }
28
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/services",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "description": "",
5
5
  "homepage": "https://oxy.so/",
6
6
  "main": "./dist/index.js",