@revenexx/cover 0.1.15 → 0.1.16
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.
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default defineNuxtRouteMiddleware(async (to) => {
|
|
2
|
+
const routeName = typeof to.name === "string" ? to.name : "";
|
|
3
|
+
const isAccountRoute = routeName.startsWith("account");
|
|
4
|
+
|
|
5
|
+
if (!isAccountRoute) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Resolve the session against the BFF like guest-only and checkout-guard
|
|
10
|
+
// do. The auth store's user is not hydrated during SSR, so store-based
|
|
11
|
+
// checks would bounce signed-in users to /login — and guest-only would
|
|
12
|
+
// bounce them straight back, looping the request.
|
|
13
|
+
const headers = useRequestHeaders(["cookie"]);
|
|
14
|
+
const user = await $fetch<{ $id: string } | null>("/api/auth/me", { headers }).catch(() => null);
|
|
15
|
+
if (user) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const localePath = useLocalePath();
|
|
20
|
+
return navigateTo(localePath({
|
|
21
|
+
path: "/login",
|
|
22
|
+
query: { redirect: to.fullPath },
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default defineNuxtRouteMiddleware(() => {
|
|
2
|
+
const localePath = useLocalePath();
|
|
3
|
+
|
|
4
|
+
// Authentication is handled on the page itself (checkout gate with
|
|
5
|
+
// login + guest ordering per organization flags) — the guard only
|
|
6
|
+
// ensures there is something to check out.
|
|
7
|
+
const cartHasItems = useCookie("cover-cart-has-items");
|
|
8
|
+
if (!cartHasItems.value) {
|
|
9
|
+
return navigateTo(localePath("cart"));
|
|
10
|
+
}
|
|
11
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default defineNuxtRouteMiddleware(async () => {
|
|
2
|
+
const localePath = useLocalePath();
|
|
3
|
+
|
|
4
|
+
const headers = useRequestHeaders(["cookie"]);
|
|
5
|
+
const user = await $fetch<{ $id: string } | null>("/api/auth/me", { headers }).catch(() => null);
|
|
6
|
+
if (user) {
|
|
7
|
+
return navigateTo(localePath("/account"));
|
|
8
|
+
}
|
|
9
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
2
|
+
const patch = () => {
|
|
3
|
+
void nextTick(() => {
|
|
4
|
+
document.querySelectorAll("[data-slot=\"link\"]:not([tabindex]), button[role=\"combobox\"]:not([tabindex])").forEach((el) => {
|
|
5
|
+
el.setAttribute("tabindex", "0");
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
nuxtApp.hook("page:finish", patch);
|
|
10
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|