style: apply consistent code formatting across project files

This commit is contained in:
Firman Ramdhani
2026-09-16 13:14:02 +07:00
parent d5791e759e
commit 51d05653c6
48 changed files with 3585 additions and 2575 deletions
+48 -29
View File
@@ -12,12 +12,19 @@ interface ShareButtonProps {
orderId: string
orderTitle?: string
className?: string
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost"
size?: "default" | "sm" | "lg" | "icon"
variant?: 'link' | 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost'
size?: 'default' | 'sm' | 'lg' | 'icon'
showText?: boolean
}
export function ShareButton({ orderId, orderTitle = 'Pesanan', className, variant = "outline", size = "sm", showText = true }: ShareButtonProps) {
export function ShareButton({
orderId,
orderTitle = 'Pesanan',
className,
variant = 'outline',
size = 'sm',
showText = true,
}: ShareButtonProps) {
const [copied, setCopied] = useState(false)
const [open, setOpen] = useState(false)
const [broadcasting, setBroadcasting] = useState(false)
@@ -31,11 +38,13 @@ export function ShareButton({ orderId, orderTitle = 'Pesanan', className, varian
const handleShareWA = async () => {
const settings = await getSettings()
let template = settings.WHATSAPP_TEMPLATE || 'Halo tim! Lagi ada orderan open nih untuk {title}. Mumpung belum di-checkout, yang mau ikutan nitip bisa langsung cek ke sini ya: {url}'
let template =
settings.WHATSAPP_TEMPLATE ||
'Halo tim! Lagi ada orderan open nih untuk {title}. Mumpung belum di-checkout, yang mau ikutan nitip bisa langsung cek ke sini ya: {url}'
const url = `${window.location.origin}/order/${orderId}`
const text = template.replace('{title}', orderTitle).replace('{url}', url)
window.open(`https://api.whatsapp.com/send?text=${encodeURIComponent(text)}`, '_blank')
}
@@ -46,13 +55,13 @@ export function ShareButton({ orderId, orderTitle = 'Pesanan', className, varian
if (res.success) {
toast.success('Broadcast Terkirim!', {
description: 'Berhasil mengirim pesan ke Mattermost.',
duration: 3000
duration: 3000,
})
setOpen(false)
} else {
toast.error('Gagal Broadcast', {
description: res.error || 'Terjadi kesalahan saat mengirim.',
duration: 3000
duration: 3000,
})
}
setBroadcasting(false)
@@ -60,48 +69,58 @@ export function ShareButton({ orderId, orderTitle = 'Pesanan', className, varian
return (
<>
<Button
<Button
variant={variant}
size={size}
className={cn("transition-all", className)}
className={cn('transition-all', className)}
title="Bagikan PO"
onClick={() => setOpen(true)}
>
<Share2 className="w-3.5 h-3.5 shrink-0" />
{showText && <span className="truncate hidden sm:inline">Bagikan</span>}
<Share2 className="h-3.5 w-3.5 shrink-0" />
{showText && <span className="hidden truncate sm:inline">Bagikan</span>}
</Button>
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent className="sm:max-w-xs p-6 rounded-3xl border-slate-200/90 dark:border-slate-800">
<DialogTitle className="text-xl font-black text-center text-slate-900 dark:text-white mb-2">Bagikan Pesanan</DialogTitle>
<p className="text-sm text-slate-500 text-center mb-4">
<DialogContent className="rounded-3xl border-slate-200/90 p-6 sm:max-w-xs dark:border-slate-800">
<DialogTitle className="mb-2 text-center text-xl font-black text-slate-900 dark:text-white">
Bagikan Pesanan
</DialogTitle>
<p className="mb-4 text-center text-sm text-slate-500">
Pilih metode untuk membagikan PO ini ke teman atau tim Anda.
</p>
<div className="space-y-3">
<Button
variant="outline"
onClick={handleCopyLink}
className="w-full h-11 rounded-xl justify-start font-bold gap-3 text-slate-700 dark:text-slate-300"
<Button
variant="outline"
onClick={handleCopyLink}
className="h-11 w-full justify-start gap-3 rounded-xl font-bold text-slate-700 dark:text-slate-300"
>
{copied ? <Check className="w-4 h-4 text-emerald-500" /> : <Copy className="w-4 h-4" />}
{copied ? (
<Check className="h-4 w-4 text-emerald-500" />
) : (
<Copy className="h-4 w-4" />
)}
{copied ? 'Tautan Disalin!' : 'Salin Tautan'}
</Button>
<Button
onClick={handleShareWA}
className="w-full h-11 rounded-xl justify-start font-bold gap-3 bg-[#25D366] hover:bg-[#20bd5a] text-white"
<Button
onClick={handleShareWA}
className="h-11 w-full justify-start gap-3 rounded-xl bg-[#25D366] font-bold text-white hover:bg-[#20bd5a]"
>
<MessageCircle className="w-4 h-4" />
<MessageCircle className="h-4 w-4" />
Kirim ke WhatsApp
</Button>
<Button
onClick={handleBroadcastMattermost}
<Button
onClick={handleBroadcastMattermost}
disabled={broadcasting}
className="w-full h-11 rounded-xl justify-start font-bold gap-3 bg-[#0668E1] hover:bg-[#0557bc] text-white"
className="h-11 w-full justify-start gap-3 rounded-xl bg-[#0668E1] font-bold text-white hover:bg-[#0557bc]"
>
{broadcasting ? <Loader2 className="w-4 h-4 animate-spin" /> : <MessageSquare className="w-4 h-4" />}
{broadcasting ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
<MessageSquare className="h-4 w-4" />
)}
{broadcasting ? 'Mengirim...' : 'Broadcast ke Mattermost'}
</Button>
</div>