// import { component$ } from "@builder.io/qwik";
// import { useNanostore$ } from "~/hooks/nanostores";
// import { isSettingsOpen, userInfo } from "~/lib/stores";
// import { StereoUser } from "~/lib/types";
import { $, component$, useComputed$, useSignal, useTask$, useVisibleTask$ } from "@builder.io/qwik";
import ky from "ky";
import { useNanostore$ } from "~/hooks/nanostores";
import { isSettingsOpen, userInfo } from "~/lib/stores";
const StorageAndPlan = component$(() => {
const user = useNanostore$(userInfo);
useVisibleTask$(({track}) => {
if (user.value) {
console.log(user.value.global_name);
}
});
const title = useSignal("this is a test");
const description = useSignal("this is a test description");
const color = useSignal("#FF264E");
return (
storage used: 3.8 / 15 GB
upgrade your plan for more features
embed editor
{user.value && (
{user.value.global_name}
{new Date().toLocaleTimeString().split(":").slice(0, 2).join(":")}
{(title.value || description.value) ? (
<>
{ title.value &&
{title.value}
}
{ description.value &&
{description.value}
}
>
) : (

)}
)}
);
});
const Integrations = component$(() => {
return (
manage your api keys and integrations here
);
});
const PrivacyAndSecurity = component$(() => {
return (
manage your privacy settings and security options
);
});
const DangerZone = component$(() => {
const handleLogout = $(() => {
ky.get("/api/auth/logout", { credentials: "include" })
.then(() => {
window.location.href = "/";
});
});
return (
delete your account and data here
);
});
export default component$(() => {
const open = useNanostore$(isSettingsOpen);
const visible = useSignal(false);
const shouldRender = useSignal(open.value);
useTask$(({ track }) => {
track(() => open.value);
if (open.value) {
shouldRender.value = true;
setTimeout(() => { visible.value = true; }, 10);
} else {
visible.value = false;
setTimeout(() => { shouldRender.value = false; }, 300);
}
});
const categories = useSignal([
{
name: "storage & plan",
description: "manage your storage and plan details",
component: StorageAndPlan
},
{
name: "api & integrations",
description: "manage your api keys and integrations",
component: Integrations
},
{
name: "privacy & security",
description: "manage your privacy settings and security options",
component: PrivacyAndSecurity
},
{
name: "danger zone",
description: "delete your account and data",
component: DangerZone
}
])
const selectedCategory = useSignal(0);
const SelectedComponent = useComputed$(() => {
return categories.value[selectedCategory.value].component;
});
if (!shouldRender.value) return <>>;
return (
(open.value = false)}
style={{
opacity: visible.value ? 1 : 0,
}}
class="z-[50] fixed inset-0 flex items-center justify-center bg-black/50 text-white text-6xl backdrop-blur-3xl transition-opacity duration-300"
>
e.stopPropagation()}
class="flex gap-8 bg-black/30 bg-gradient-to-t from-stereo/20 to-transparent p-8 rounded-3xl shadow-lg w-4/7 h-4/7"
>
settings
{categories.value.map((category, i) => (
(selectedCategory.value = i)}
>
{category.name}
{category.description}
))}
{categories.value[selectedCategory.value].name}
);
});