refactor(social): use Modal for AddAccountDialog

This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 22:04:24 -04:00
1 parent 8541836b26
commit 69724f0188
1 file changed
+54 -82
@@ -1,8 +1,7 @@
import { useState } from "react"; import { useState } from "react";
import { motion } from "framer-motion"; import { SignIn } from "@phosphor-icons/react";
import { SignIn, X } from "@phosphor-icons/react";
import type { SocialPlatform } from "@shared/types"; import type { SocialPlatform } from "@shared/types";
import { ActionButton } from "../ui"; import { ActionButton, Modal } from "../ui";
import { platformConfig } from "./social-config"; import { platformConfig } from "./social-config";
interface AddAccountDialogProps { interface AddAccountDialogProps {
@@ -15,91 +14,64 @@ export function AddAccountDialog({ onAddAndLogin, onClose }: AddAccountDialogPro
const [requireApproval, setRequireApproval] = useState(true); const [requireApproval, setRequireApproval] = useState(true);
return ( return (
<motion.div <Modal open onClose={onClose} title="Add Social Account" width="420px">
initial={{ opacity: 0 }} <div className="space-y-4">
animate={{ opacity: 1 }} <div>
exit={{ opacity: 0 }} <label className="mb-1.5 block text-[12px] font-medium text-muted-foreground">Platform</label>
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4" <div className="max-h-[240px] overflow-y-auto rounded-lg border border-border p-1.5">
onClick={onClose} <div className="grid grid-cols-3 gap-1.5">
> {(Object.entries(platformConfig) as [SocialPlatform, typeof platformConfig.twitter][]).map(([key, config]) => (
<motion.div <button
initial={{ scale: 0.95, opacity: 0 }} key={key}
animate={{ scale: 1, opacity: 1 }} type="button"
exit={{ scale: 0.95, opacity: 0 }} onClick={() => setPlatform(key)}
className="w-full max-w-[420px] rounded-lg border border-border bg-card p-6 shadow-xl" className={`flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-[11px] font-medium transition ${
onClick={(e) => e.stopPropagation()} platform === key
> ? "border-[color:var(--primary)] bg-accent text-primary"
<div className="mb-5 flex items-center justify-between"> : "border-border text-muted-foreground hover:border-border"
<h3 className="text-[16px] font-bold text-foreground">Add Social Account</h3> }`}
<button type="button" onClick={onClose} className="rounded-lg p-1 text-muted-foreground hover:bg-muted"> >
<X size={18} /> <span style={{ color: config.color }}>
</button> <config.icon size={14} />
</div> </span>
<span className="truncate">{config.label}</span>
<div className="space-y-4"> </button>
<div> ))}
<label className="mb-1.5 block text-[12px] font-medium text-muted-foreground">Platform</label>
<div className="max-h-[240px] overflow-y-auto rounded-lg border border-border p-1.5">
<div className="grid grid-cols-3 gap-1.5">
{(Object.entries(platformConfig) as [SocialPlatform, typeof platformConfig.twitter][]).map(([key, config]) => (
<button
key={key}
type="button"
onClick={() => setPlatform(key)}
className={`flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-[11px] font-medium transition ${
platform === key
? "border-[color:var(--primary)] bg-accent text-primary"
: "border-border text-muted-foreground hover:border-border"
}`}
>
<span style={{ color: config.color }}>
<config.icon size={14} />
</span>
<span className="truncate">{config.label}</span>
</button>
))}
</div>
</div> </div>
</div> </div>
</div>
<div className="rounded-lg border border-border bg-muted px-4 py-3"> <div className="rounded-lg border border-border bg-muted px-4 py-3">
<label className="flex items-center gap-3"> <label className="flex items-center gap-3">
<input <input
type="checkbox" type="checkbox"
checked={requireApproval} checked={requireApproval}
onChange={(e) => setRequireApproval(e.target.checked)} onChange={(e) => setRequireApproval(e.target.checked)}
className="h-4 w-4 rounded border-border accent-[color:var(--primary)]" className="h-4 w-4 rounded border-border accent-[color:var(--primary)]"
/> />
<div> <div>
<div className="text-[12px] font-medium text-foreground">Require Board Approval for Posts</div> <div className="text-[12px] font-medium text-foreground">Require Board Approval for Posts</div>
<div className="mt-0.5 text-[10px] text-muted-foreground"> <div className="mt-0.5 text-[10px] text-muted-foreground">
Agents must get approval before publishing content to this account Agents must get approval before publishing content to this account
</div>
</div> </div>
</label> </div>
</div> </label>
<div className="rounded-lg bg-accent px-4 py-3 text-[11px] text-muted-foreground">
A browser window will open for you to sign in. Your username and profile info will be detected automatically after login.
</div>
</div> </div>
<div className="mt-6 flex justify-end gap-3"> <div className="rounded-lg bg-accent px-4 py-3 text-[11px] text-muted-foreground">
<button A browser window will open for you to sign in. Your username and profile info will be detected automatically after login.
type="button"
onClick={onClose}
className="rounded-lg px-4 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-muted"
>
Cancel
</button>
<ActionButton
label="Login"
onClick={() => onAddAndLogin(platform, requireApproval)}
icon={SignIn}
tone="accent"
/>
</div> </div>
</motion.div> </div>
</motion.div>
<div className="mt-6 flex justify-end gap-3">
<ActionButton label="Cancel" onClick={onClose} />
<ActionButton
label="Login"
onClick={() => onAddAndLogin(platform, requireApproval)}
icon={SignIn}
tone="accent"
/>
</div>
</Modal>
); );
} }