Files
pos/resources/js/admin/tailadmin/pages/AuthPages/AuthPageLayout.tsx
2026-03-06 03:26:11 +07:00

66 lines
2.3 KiB
TypeScript

import React, { useEffect, useState } from "react";
import GridShape from "../../components/common/GridShape";
import { Link } from "react-router-dom";
import ThemeTogglerTwo from "../../components/common/ThemeTogglerTwo";
import { apiGet } from "../../lib/api";
export default function AuthLayout({
children,
}: {
children: React.ReactNode;
}) {
const [storeName, setStoreName] = useState("POS");
const [storeLogo, setStoreLogo] = useState("");
useEffect(() => {
let mounted = true;
apiGet<{ data: { toko?: { nama?: string } } }>("/admin-api/pengaturan")
.then((res) => {
const name = res?.data?.toko?.nama?.trim();
const logo = res?.data?.toko?.logo || "";
if (mounted && name) setStoreName(name);
if (mounted) setStoreLogo(logo);
})
.catch(() => {});
return () => {
mounted = false;
};
}, []);
return (
<div className="relative p-6 bg-white z-1 dark:bg-gray-900 sm:p-0">
<div className="relative flex flex-col justify-center w-full h-screen lg:flex-row dark:bg-gray-900 sm:p-0">
{children}
<div className="items-center hidden w-full h-full lg:w-1/2 bg-brand-950 dark:bg-white/5 lg:grid">
<div className="relative flex items-center justify-center z-1">
{/* <!-- ===== Common Grid Shape Start ===== --> */}
<GridShape />
<div className="flex flex-col items-center max-w-xs">
<Link to="/" className="block mb-4">
<div className="flex flex-col items-center gap-3">
{storeLogo ? (
<img
src={storeLogo}
alt="Logo"
className="h-16 w-16 rounded-xl border border-white/10 bg-white/5 object-contain"
/>
) : null}
<span className="text-2xl font-semibold text-white">
{storeName}
</span>
</div>
</Link>
<p className="text-center text-gray-400 dark:text-white/60">
Sistem kasir sederhana untuk operasional harian
</p>
</div>
</div>
</div>
<div className="fixed z-50 hidden bottom-6 right-6 sm:block">
<ThemeTogglerTwo />
</div>
</div>
</div>
);
}