fix auth
This commit is contained in:
@@ -32,6 +32,16 @@ export default function StorefrontPage() {
|
||||
|
||||
// ✅ Fetch Storefront Data
|
||||
useEffect(() => {
|
||||
const authToken = document.cookie
|
||||
.split("; ")
|
||||
.find((row) => row.startsWith("Authorization="))
|
||||
?.split("=")[1];
|
||||
|
||||
if (!authToken) {
|
||||
router.push("/login");
|
||||
return;
|
||||
}
|
||||
|
||||
const fetchStorefront = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
@@ -48,7 +58,9 @@ export default function StorefrontPage() {
|
||||
}, []);
|
||||
|
||||
// ✅ Handle Form Input Changes
|
||||
const handleInputChange = (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||
const handleInputChange = (
|
||||
e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
|
||||
) => {
|
||||
setStorefront({ ...storefront, [e.target.name]: e.target.value });
|
||||
};
|
||||
|
||||
@@ -134,12 +146,20 @@ export default function StorefrontPage() {
|
||||
|
||||
{/* Buttons */}
|
||||
<div className="sticky bottom-6 mt-8 flex justify-between">
|
||||
<Button onClick={() => setBroadcastOpen(true)} className="gap-2 bg-emerald-600 hover:bg-emerald-700 text-white">
|
||||
<Button
|
||||
onClick={() => setBroadcastOpen(true)}
|
||||
className="gap-2 bg-emerald-600 hover:bg-emerald-700 text-white"
|
||||
>
|
||||
<Send className="h-5 w-5" /> Broadcast Message
|
||||
</Button>
|
||||
|
||||
<Button onClick={saveStorefront} disabled={saving} className="gap-2 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white">
|
||||
<Save className="h-5 w-5" /> {saving ? "Saving..." : "Save Configuration"}
|
||||
<Button
|
||||
onClick={saveStorefront}
|
||||
disabled={saving}
|
||||
className="gap-2 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white"
|
||||
>
|
||||
<Save className="h-5 w-5" />{" "}
|
||||
{saving ? "Saving..." : "Save Configuration"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user