mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { KeyRound, CreditCard, Mail, Megaphone, ChevronRight, Eye, EyeOff, ShieldAlert, Trash2 } from "lucide-react";
|
||||
import { KeyRound, CreditCard, Mail, Megaphone, Info, ChevronRight, Eye, EyeOff, ShieldAlert, Trash2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -283,6 +283,57 @@ function NewsletterSection() {
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Course Notices ───────────────────────────────────────────────────────────
|
||||
// One-time informational dialogs shown while studying (e.g. InfoDialog in
|
||||
// UnitList.jsx) — this list grows as more generic client notices are added.
|
||||
|
||||
const NOTICE_OPTIONS = [
|
||||
{
|
||||
key: "show_course_notices",
|
||||
label: "Course notices",
|
||||
description: "Informational pop-ups about course readiness, such as when an assessment hasn't been built yet.",
|
||||
},
|
||||
];
|
||||
|
||||
function CourseNoticesSection() {
|
||||
const { profile, getProfile, updateProfile, profileLoading } = useProfile();
|
||||
|
||||
useEffect(() => {
|
||||
getProfile();
|
||||
}, []);
|
||||
|
||||
const handleToggle = async (key, value) => {
|
||||
const result = await updateProfile({ [key]: value });
|
||||
if (result?.success) {
|
||||
toast.success("Preference saved.");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{NOTICE_OPTIONS.map((opt, i) => (
|
||||
<div key={opt.key}>
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<div className="space-y-0.5">
|
||||
<p className="text-sm font-medium">{opt.label}</p>
|
||||
<p className="text-xs text-muted-foreground">{opt.description}</p>
|
||||
</div>
|
||||
{profileLoading ? (
|
||||
<Skeleton className="h-6 w-11 rounded-full shrink-0" />
|
||||
) : (
|
||||
<Switch
|
||||
checked={profile?.personal_info?.[opt.key] ?? true}
|
||||
onCheckedChange={(v) => handleToggle(opt.key, v)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{i < NOTICE_OPTIONS.length - 1 && <Separator className="mt-4" />}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Advertisements ───────────────────────────────────────────────────────────
|
||||
|
||||
const AD_OPTIONS = [
|
||||
@@ -492,6 +543,10 @@ export default function AccountSettings() {
|
||||
<NewsletterSection />
|
||||
</Section>
|
||||
|
||||
<Section icon={Info} title="Course Notices" description="Control informational notices shown while studying.">
|
||||
<CourseNoticesSection />
|
||||
</Section>
|
||||
|
||||
<Section icon={Megaphone} title="Advertisements" description="Control which advertisements you see across the platform.">
|
||||
<AdvertisementsSection />
|
||||
</Section>
|
||||
|
||||
Reference in New Issue
Block a user