@articles-media/articles-dev-box 1.0.31 → 1.0.33
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 +11 -3
- package/dist/Ad-BsG4C_lR.js +668 -0
- package/dist/Ad.js +2 -2
- package/dist/AdConfirmExitModal-heFPJNdX.js +55 -0
- package/dist/AdDetailsModal-D2-4lh9e.js +107 -0
- package/dist/ArticlesAd.js +15 -10
- package/dist/Button-DvEZjsVV.js +32 -0
- package/dist/CreditsModal.js +51 -35
- package/dist/DarkModeHandler.js +21 -13
- package/dist/FriendsList.js +49 -47
- package/dist/GameMenu-BD1HSDJ-.js +84 -0
- package/dist/GameMenu.js +2 -0
- package/dist/GameScoreboard-DVoXXDnM.js +174 -0
- package/dist/GameScoreboard.js +2 -2
- package/dist/GlobalBody.js +58 -23
- package/dist/GlobalHead.js +5 -5
- package/dist/Link-CguWJy6y.js +16 -0
- package/dist/ReturnToLauncherButton.js +26 -22
- package/dist/SessionButton.js +62 -38
- package/dist/SettingsModal-BWEW8IAS.js +430 -0
- package/dist/SettingsModal.js +2 -2
- package/dist/SignInButton.js +21 -17
- package/dist/SocketServerUrlHandler.js +14 -10
- package/dist/StatusModal-BXRbJQ10.js +84 -0
- package/dist/ToontownModeHandler.js +13 -10
- package/dist/ViewUserModal-Dgo1C4sR.js +1798 -0
- package/dist/ViewUserModal.js +2 -2
- package/dist/articles-dev-box.css +498 -2
- package/dist/classnames-No-mjhw1.js +66 -0
- package/dist/index.js +23 -22
- package/dist/numberWithCommas-B0B9bjWC.js +2198 -0
- package/dist/typicalZustandStoreExcludes.js +4 -3
- package/dist/typicalZustandStoreStateSlice.js +53 -49
- package/dist/useAuthSiteStatus-ZK1GbPBV.js +34 -0
- package/dist/useFullscreen.js +38 -18
- package/dist/useUserDetails.js +17 -16
- package/dist/useUserFriends.js +23 -21
- package/dist/useUserToken.js +12 -11
- package/package.json +2 -1
- package/dist/Ad-CFuDgQYL.js +0 -504
- package/dist/AdConfirmExitModal-skW9lp88.js +0 -55
- package/dist/AdDetailsModal-CdTR2Y9l.js +0 -107
- package/dist/Button-sSB4xpOw.js +0 -31
- package/dist/GameScoreboard-9GYlLx72.js +0 -165
- package/dist/Link-8nSDV4sI.js +0 -16
- package/dist/SettingsModal-CiLvMoLW.js +0 -303
- package/dist/StatusModal-PG3i9NKf.js +0 -75
- package/dist/ViewUserModal-C5gjfuJ5.js +0 -1549
- package/dist/classnames-DCsil9eG.js +0 -39
- package/dist/numberWithCommas-DSRplpBy.js +0 -1170
- package/dist/useAuthSiteStatus-Cj9IjMj7.js +0 -29
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { t as ArticlesButton } from "./Button-DvEZjsVV.js";
|
|
2
|
+
import { t as ViewUserModal } from "./ViewUserModal-Dgo1C4sR.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import useSWR from "swr";
|
|
6
|
+
import Modal from "react-bootstrap/Modal";
|
|
7
|
+
//#region src/components/UI/ArticlesSwitch.jsx
|
|
8
|
+
function ArticlesSwitch({ setChecked, checked, readOnly }) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
10
|
+
className: `articles-switch mb-0 ${checked && "checked"}`,
|
|
11
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
12
|
+
type: "checkbox",
|
|
13
|
+
readOnly: readOnly ? true : false,
|
|
14
|
+
checked,
|
|
15
|
+
onChange: () => {}
|
|
16
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
17
|
+
onClick: (e) => {
|
|
18
|
+
if (setChecked) {
|
|
19
|
+
setChecked(!checked);
|
|
20
|
+
return;
|
|
21
|
+
} else {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
className: "slider"
|
|
27
|
+
})]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/hooks/Games/useGameScoreboard.js
|
|
32
|
+
var fetcher = async (obj) => {
|
|
33
|
+
if (process.env.NODE_ENV === "development") try {
|
|
34
|
+
const params = new URLSearchParams({ game: obj.game }).toString();
|
|
35
|
+
return await (await fetch(`http://localhost:3001/api/community/games/scoreboard?${params}`)).json();
|
|
36
|
+
} catch (err) {}
|
|
37
|
+
const params = new URLSearchParams({ game: obj.game }).toString();
|
|
38
|
+
return fetch(`${obj.url}?${params}`).then((res) => res.json());
|
|
39
|
+
};
|
|
40
|
+
var options = {
|
|
41
|
+
dedupingInterval: 1e3 * 60 * 30,
|
|
42
|
+
errorRetryInterval: 1e3 * 60 * 5,
|
|
43
|
+
refreshInterval: 0,
|
|
44
|
+
revalidateOnFocus: false,
|
|
45
|
+
revalidateIfStale: false,
|
|
46
|
+
shouldRetryOnError: false
|
|
47
|
+
};
|
|
48
|
+
var useGameScoreboard = (params) => {
|
|
49
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR(params?.game ? {
|
|
50
|
+
url: "https://articles.media/api/community/games/scoreboard",
|
|
51
|
+
game: params.game
|
|
52
|
+
} : null, fetcher, options);
|
|
53
|
+
return {
|
|
54
|
+
data,
|
|
55
|
+
error,
|
|
56
|
+
isLoading,
|
|
57
|
+
isValidating,
|
|
58
|
+
mutate
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/components/Games/GameScoreboard.jsx
|
|
63
|
+
function GameScoreboard({ game, metric, reloadScoreboard, setReloadScoreboard, prepend, append }) {
|
|
64
|
+
const [showSettings, setShowSettings] = useState(false);
|
|
65
|
+
const [visible, setVisible] = useState(false);
|
|
66
|
+
const { data: scoreboard, isLoading: scoreboardIsLoading, mutate: scoreboardMutate } = useGameScoreboard({ game });
|
|
67
|
+
useEffect(() => {}, []);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (reloadScoreboard) {
|
|
70
|
+
setReloadScoreboard(false);
|
|
71
|
+
scoreboardMutate();
|
|
72
|
+
}
|
|
73
|
+
}, [reloadScoreboard]);
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
75
|
+
className: "scoreboard",
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsxs(Modal, {
|
|
78
|
+
show: showSettings,
|
|
79
|
+
size: "md",
|
|
80
|
+
className: "articles-modal",
|
|
81
|
+
centered: true,
|
|
82
|
+
onHide: () => setShowSettings(false),
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: "Scoreboard Settings" }) }),
|
|
85
|
+
/* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs("div", {
|
|
86
|
+
className: "d-flex justify-content-between align-items-center",
|
|
87
|
+
onClick: () => setVisible(!visible),
|
|
88
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("i", { className: "fas fa-trophy-alt" }), /* @__PURE__ */ jsx("span", { children: "Join Scoreboard?" })] }), /* @__PURE__ */ jsx(ArticlesSwitch, { checked: visible })]
|
|
89
|
+
}) }),
|
|
90
|
+
/* @__PURE__ */ jsx(Modal.Footer, {
|
|
91
|
+
className: "justify-content-between",
|
|
92
|
+
children: /* @__PURE__ */ jsx(ArticlesButton, {
|
|
93
|
+
variant: "articles",
|
|
94
|
+
onClick: () => {
|
|
95
|
+
setShowSettings(false);
|
|
96
|
+
},
|
|
97
|
+
children: "Close"
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ jsx("div", {
|
|
103
|
+
className: "prepend-container",
|
|
104
|
+
children: prepend
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsxs("div", {
|
|
107
|
+
className: "card card-articles card-sm mb-3 mb-lg-0",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsxs("div", {
|
|
110
|
+
className: "card-header d-flex justify-content-between align-items-center",
|
|
111
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [game, " Scoreboard"] }), /* @__PURE__ */ jsx(ArticlesButton, {
|
|
112
|
+
onClick: () => {
|
|
113
|
+
scoreboardMutate();
|
|
114
|
+
},
|
|
115
|
+
small: true,
|
|
116
|
+
children: /* @__PURE__ */ jsx("i", { className: "fad fa-redo me-0" })
|
|
117
|
+
})]
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsxs("div", {
|
|
120
|
+
className: "card-body p-0",
|
|
121
|
+
children: [(scoreboard?.length || 0) == 0 && /* @__PURE__ */ jsx("div", {
|
|
122
|
+
className: "small p-2",
|
|
123
|
+
children: "No scores yet"
|
|
124
|
+
}), scoreboard?.length > 0 && scoreboard?.map((doc, i) => /* @__PURE__ */ jsxs("div", {
|
|
125
|
+
className: "result d-flex flex-column justify-content-between border-bottom p-2",
|
|
126
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
127
|
+
className: "d-flex justify-content-between lh-sm",
|
|
128
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
129
|
+
className: "d-flex",
|
|
130
|
+
children: [/* @__PURE__ */ jsx("h5", {
|
|
131
|
+
className: "mb-0 me-3",
|
|
132
|
+
children: i + 1
|
|
133
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
134
|
+
className: "lh-sm",
|
|
135
|
+
children: /* @__PURE__ */ jsx(ViewUserModal, {
|
|
136
|
+
populated_user: doc.populated_user,
|
|
137
|
+
user_id: doc.user_id
|
|
138
|
+
})
|
|
139
|
+
})]
|
|
140
|
+
}), /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h5", {
|
|
141
|
+
className: "mb-0",
|
|
142
|
+
children: doc.score || doc.total
|
|
143
|
+
}) })]
|
|
144
|
+
}), doc.last_play && doc.public_last_play && /* @__PURE__ */ jsxs("small", {
|
|
145
|
+
className: "mt-1",
|
|
146
|
+
style: { fontSize: "0.75rem" },
|
|
147
|
+
children: ["Played: ", format(new Date(doc.last_play), "MM/d/yy hh:mmaa")]
|
|
148
|
+
})]
|
|
149
|
+
}, doc._id))]
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ jsxs("div", {
|
|
152
|
+
className: "card-footer d-flex justify-content-between align-items-center",
|
|
153
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
154
|
+
className: "small",
|
|
155
|
+
children: "Play to get on the board!"
|
|
156
|
+
}), /* @__PURE__ */ jsx(ArticlesButton, {
|
|
157
|
+
small: true,
|
|
158
|
+
onClick: () => {
|
|
159
|
+
setShowSettings(true);
|
|
160
|
+
},
|
|
161
|
+
children: /* @__PURE__ */ jsx("i", { className: "fad fa-cog me-0" })
|
|
162
|
+
})]
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ jsx("div", {
|
|
167
|
+
className: "append-container",
|
|
168
|
+
children: append
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
export { GameScoreboard as t };
|
package/dist/GameScoreboard.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
export {
|
|
1
|
+
import { t as GameScoreboard } from "./GameScoreboard-DVoXXDnM.js";
|
|
2
|
+
export { GameScoreboard as default };
|
package/dist/GlobalBody.js
CHANGED
|
@@ -1,36 +1,71 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { n as
|
|
3
|
-
import { n, t as
|
|
4
|
-
import { Suspense
|
|
5
|
-
import { Fragment
|
|
2
|
+
import { n as __toESM, t as require_classnames } from "./classnames-No-mjhw1.js";
|
|
3
|
+
import { n as useMainSiteStatus, t as useAuthSiteStatus } from "./useAuthSiteStatus-ZK1GbPBV.js";
|
|
4
|
+
import { Suspense, lazy, memo, useState } from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/Global/GlobalBody.jsx
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
var import_classnames = /* @__PURE__ */ __toESM(require_classnames(), 1);
|
|
8
|
+
var StatusModal = lazy(() => import("./StatusModal-BXRbJQ10.js"));
|
|
9
|
+
function GlobalBody(props) {
|
|
10
|
+
const [statusModal, setStatusModal] = useState(false);
|
|
11
|
+
const { data: mainSiteStatus, error: mainSiteStatusError, isLoading: mainSiteStatusLoading, mutate: mainSiteStatusMutate } = useMainSiteStatus({ disable: process.env.NODE_ENV !== "development" });
|
|
12
|
+
const { data: authSiteStatus, error: authSiteStatusError, isLoading: authSiteStatusLoading, mutate: authSiteStatusMutate } = useAuthSiteStatus({ disable: process.env.NODE_ENV !== "development" });
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("link", {
|
|
11
14
|
rel: "stylesheet",
|
|
12
|
-
href:
|
|
13
|
-
}), process.env.NODE_ENV === "development" && /* @__PURE__ */
|
|
14
|
-
/* @__PURE__ */
|
|
15
|
-
|
|
15
|
+
href: `https://cdn.articles.media/fonts/fontawesome/css/all.min.css`
|
|
16
|
+
}), process.env.NODE_ENV === "development" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
17
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
18
|
+
@keyframes grow-shrink {
|
|
19
|
+
0% { transform: translateY(-50px); }
|
|
20
|
+
50% { transform: translateY(0px); }
|
|
21
|
+
100% { transform: translateY(-50px); }
|
|
22
|
+
}
|
|
23
|
+
.articles-global-body {
|
|
24
|
+
transform: translateY(-40px);
|
|
25
|
+
z-index: 1055!important;
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 0;
|
|
28
|
+
left: 0;
|
|
29
|
+
display: flex;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
align-items: center;
|
|
32
|
+
width: 50px;
|
|
33
|
+
height: 50px;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
background-color: yellow;
|
|
37
|
+
color: #FFFFFF;
|
|
38
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
39
|
+
animation: grow-shrink 2s ease-in;
|
|
40
|
+
border: 4px solid red;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
.articles-global-body.main-connected {
|
|
44
|
+
background-color: green;
|
|
45
|
+
}
|
|
46
|
+
.articles-global-body.auth-connected {
|
|
47
|
+
border-color: blue;
|
|
48
|
+
}
|
|
49
|
+
` }),
|
|
50
|
+
/* @__PURE__ */ jsx("div", {
|
|
16
51
|
onClick: () => {
|
|
17
|
-
|
|
52
|
+
setStatusModal(true);
|
|
18
53
|
},
|
|
19
|
-
className: (0,
|
|
20
|
-
"main-connected":
|
|
21
|
-
"auth-connected":
|
|
54
|
+
className: (0, import_classnames.default)(`articles-global-body`, {
|
|
55
|
+
"main-connected": mainSiteStatus,
|
|
56
|
+
"auth-connected": authSiteStatus
|
|
22
57
|
}),
|
|
23
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
24
59
|
className: "content",
|
|
25
|
-
children: /* @__PURE__ */
|
|
60
|
+
children: /* @__PURE__ */ jsx("i", { className: "fas fa-thumbs-up" })
|
|
26
61
|
})
|
|
27
62
|
}),
|
|
28
|
-
|
|
29
|
-
show:
|
|
30
|
-
setShow:
|
|
63
|
+
statusModal && /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(StatusModal, {
|
|
64
|
+
show: statusModal,
|
|
65
|
+
setShow: setStatusModal
|
|
31
66
|
}) })
|
|
32
67
|
] })] });
|
|
33
68
|
}
|
|
34
|
-
var
|
|
69
|
+
var GlobalBody_default = memo(GlobalBody);
|
|
35
70
|
//#endregion
|
|
36
|
-
export {
|
|
71
|
+
export { GlobalBody_default as default };
|
package/dist/GlobalHead.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Fragment
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
//#region src/components/Global/GlobalHead.jsx
|
|
3
|
-
function
|
|
4
|
-
return /* @__PURE__ */
|
|
3
|
+
function GlobalHead() {
|
|
4
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("link", {
|
|
5
5
|
rel: "stylesheet",
|
|
6
|
-
href:
|
|
6
|
+
href: `https://cdn.articles.media/fonts/fontawesome/css/all.min.css`
|
|
7
7
|
}) });
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
|
-
export {
|
|
10
|
+
export { GlobalHead as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
//#region src/components/UI/Link.jsx
|
|
3
|
+
function Link(props) {
|
|
4
|
+
const { href, children, newPage, ...rest } = props;
|
|
5
|
+
return /* @__PURE__ */ jsx("a", {
|
|
6
|
+
href,
|
|
7
|
+
...rest,
|
|
8
|
+
...newPage && {
|
|
9
|
+
target: "_blank",
|
|
10
|
+
rel: "noopener noreferrer"
|
|
11
|
+
},
|
|
12
|
+
children
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Link as t };
|
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { t as
|
|
3
|
-
import { useEffect
|
|
4
|
-
import { jsx
|
|
2
|
+
import { t as ArticlesButton } from "./Button-DvEZjsVV.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/Games/ReturnToLauncherButton.jsx
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, [])
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
function ReturnToLauncherButton({ className, id }) {
|
|
7
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
setIsMounted(true);
|
|
10
|
+
}, []);
|
|
11
|
+
if (!isMounted) return null;
|
|
12
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
13
|
+
let { launcher_mode } = Object.fromEntries(urlParams);
|
|
14
|
+
launcher_mode = launcher_mode === "1" ? true : false;
|
|
15
|
+
if (!launcher_mode) return /* @__PURE__ */ jsxs(ArticlesButton, {
|
|
16
|
+
className: `${className} w-100`,
|
|
17
|
+
small: true,
|
|
18
|
+
id,
|
|
16
19
|
style: {
|
|
17
20
|
zIndex: 10,
|
|
18
21
|
position: "relative"
|
|
19
22
|
},
|
|
20
23
|
onClick: () => {
|
|
21
|
-
window.location.href =
|
|
24
|
+
window.location.href = `https://games.articles.media`;
|
|
22
25
|
},
|
|
23
|
-
children: [/* @__PURE__ */
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
id
|
|
26
|
+
children: [/* @__PURE__ */ jsx("i", { className: "fad fa-gamepad" }), "View our other games"]
|
|
27
|
+
});
|
|
28
|
+
return /* @__PURE__ */ jsxs(ArticlesButton, {
|
|
29
|
+
className: `${className} w-100`,
|
|
30
|
+
id,
|
|
31
|
+
small: true,
|
|
28
32
|
style: {
|
|
29
33
|
zIndex: 10,
|
|
30
34
|
position: "relative"
|
|
31
35
|
},
|
|
32
36
|
onClick: () => {
|
|
33
|
-
window.location.href =
|
|
37
|
+
window.location.href = `https://games.articles.media`;
|
|
34
38
|
},
|
|
35
|
-
children: [/* @__PURE__ */
|
|
39
|
+
children: [/* @__PURE__ */ jsx("i", { className: "fad fa-gamepad" }), "Return to Games"]
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
//#endregion
|
|
39
|
-
export {
|
|
43
|
+
export { ReturnToLauncherButton as default };
|
package/dist/SessionButton.js
CHANGED
|
@@ -1,46 +1,70 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { t as
|
|
6
|
-
import
|
|
1
|
+
import { t as ArticlesButton } from "./Button-DvEZjsVV.js";
|
|
2
|
+
import SignInButton from "./SignInButton.js";
|
|
3
|
+
import useUserDetails from "./useUserDetails.js";
|
|
4
|
+
import useUserToken from "./useUserToken.js";
|
|
5
|
+
import { t as ViewUserModal } from "./ViewUserModal-Dgo1C4sR.js";
|
|
6
|
+
import FriendsList from "./FriendsList.js";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
//#region src/components/User/SessionButton.jsx
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
function SessionButton({ port, friendsButton }) {
|
|
11
|
+
const { data: userToken, error: userTokenError, isLoading: userTokenLoading, mutate: userTokenMutate } = useUserToken(port);
|
|
12
|
+
const { data: userDetails, error: userDetailsError, isLoading: userDetailsLoading, mutate: userDetailsMutate } = useUserDetails({ token: userToken });
|
|
13
|
+
const logoutLink = `/api/signout`;
|
|
14
|
+
const [showFriendsModal, setShowFriendsModal] = useState(false);
|
|
15
|
+
return /* @__PURE__ */ jsx(Fragment, { children: !userDetails ? /* @__PURE__ */ jsx(SignInButton, { className: "mb-2" }) : /* @__PURE__ */ jsxs("div", {
|
|
11
16
|
className: "w-100 d-flex align-items-stretch mb-2",
|
|
12
|
-
children: [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
children: /* @__PURE__ */ s(e, {
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ jsx(ViewUserModal, {
|
|
19
|
+
buttonType: "Link",
|
|
16
20
|
className: "w-100",
|
|
17
|
-
|
|
21
|
+
children: /* @__PURE__ */ jsxs(ArticlesButton, {
|
|
22
|
+
className: "w-100",
|
|
23
|
+
small: true,
|
|
24
|
+
onClick: () => {
|
|
25
|
+
console.log("userDetails", userDetails);
|
|
26
|
+
},
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ jsx("i", { className: "fad fa-sign-out" }),
|
|
29
|
+
"Logged in as ",
|
|
30
|
+
userDetails?.display_name || "Unknown User"
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
}),
|
|
34
|
+
showFriendsModal && /* @__PURE__ */ jsx(FriendsList, {
|
|
35
|
+
show: showFriendsModal,
|
|
36
|
+
setShow: setShowFriendsModal,
|
|
37
|
+
componentType: "modal"
|
|
38
|
+
}),
|
|
39
|
+
friendsButton && /* @__PURE__ */ jsx(ArticlesButton, {
|
|
40
|
+
className: "",
|
|
41
|
+
small: true,
|
|
42
|
+
title: "My Friends",
|
|
18
43
|
onClick: () => {
|
|
19
|
-
|
|
44
|
+
setShowFriendsModal(true);
|
|
20
45
|
},
|
|
21
|
-
children:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
46
|
+
children: /* @__PURE__ */ jsx("i", { className: "fad fa-users" })
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx(ArticlesButton, {
|
|
49
|
+
className: "",
|
|
50
|
+
small: true,
|
|
51
|
+
title: "Sign out",
|
|
52
|
+
onClick: () => {
|
|
53
|
+
fetch(logoutLink, {
|
|
54
|
+
method: "GET",
|
|
55
|
+
headers: {}
|
|
56
|
+
}).then((response) => response.json()).then((data) => {
|
|
57
|
+
console.log("Logout successful:", data);
|
|
58
|
+
userTokenMutate(null);
|
|
59
|
+
userDetailsMutate(null);
|
|
60
|
+
}).catch((error) => {
|
|
61
|
+
console.error("Logout error:", error);
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
children: /* @__PURE__ */ jsx("i", { className: "fad fa-sign-out" })
|
|
26
65
|
})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
small: !0,
|
|
30
|
-
title: "Sign out",
|
|
31
|
-
onClick: () => {
|
|
32
|
-
fetch("/api/signout", {
|
|
33
|
-
method: "GET",
|
|
34
|
-
headers: {}
|
|
35
|
-
}).then((e) => e.json()).then((e) => {
|
|
36
|
-
console.log("Logout successful:", e), f(null), g(null);
|
|
37
|
-
}).catch((e) => {
|
|
38
|
-
console.error("Logout error:", e);
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
children: /* @__PURE__ */ o("i", { className: "fad fa-sign-out" })
|
|
42
|
-
})]
|
|
43
|
-
}) : /* @__PURE__ */ o(t, { className: "mb-2" }) });
|
|
66
|
+
]
|
|
67
|
+
}) });
|
|
44
68
|
}
|
|
45
69
|
//#endregion
|
|
46
|
-
export {
|
|
70
|
+
export { SessionButton as default };
|