-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
399 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Avatar, AvatarFallback, AvatarImage } from "@midday/ui/avatar"; | ||
import { InvoiceStatus } from "./invoice-status"; | ||
|
||
type Props = { | ||
name: string; | ||
website: string; | ||
status: "overdue" | "paid" | "unpaid" | "draft" | "canceled"; | ||
}; | ||
|
||
export default function CustomerHeader({ name, website, status }: Props) { | ||
return ( | ||
<div className="flex justify-between items-center mb-4"> | ||
<div className="flex items-center space-x-2"> | ||
<Avatar className="size-5"> | ||
{website && ( | ||
<AvatarImage | ||
src={`https://img.logo.dev/${website}?token=pk_X-1ZO13GSgeOoUrIuJ6GMQ&size=60`} | ||
alt={`${name} logo`} | ||
/> | ||
)} | ||
<AvatarFallback className="text-[9px] font-medium"> | ||
{name?.[0]} | ||
</AvatarFallback> | ||
</Avatar> | ||
<span className="truncate text-sm">{name}</span> | ||
</div> | ||
|
||
<InvoiceStatus status={status} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use client"; | ||
|
||
import { Button } from "@midday/ui/button"; | ||
import { motion } from "framer-motion"; | ||
import { | ||
MdChatBubbleOutline, | ||
MdContentCopy, | ||
MdOutlineFileDownload, | ||
} from "react-icons/md"; | ||
import { InvoiceViewers } from "./invoice-viewers"; | ||
|
||
export type Customer = { | ||
name: string; | ||
website?: string; | ||
}; | ||
|
||
type Props = { | ||
customer: Customer; | ||
}; | ||
|
||
export default function InvoiceToolbar({ customer }: Props) { | ||
return ( | ||
<motion.div | ||
className="fixed inset-x-0 bottom-2 flex justify-center" | ||
initial={{ opacity: 0, filter: "blur(8px)", y: 0 }} | ||
animate={{ opacity: 1, filter: "blur(0px)", y: -24 }} | ||
transition={{ type: "spring", stiffness: 260, damping: 20 }} | ||
> | ||
<div className="backdrop-filter backdrop-blur-lg dark:bg-[#1A1A1A]/80 bg-[#F6F6F3]/80 rounded-full px-4 py-3 h-10 flex items-center justify-center"> | ||
<Button variant="ghost" size="icon" className="rounded-full size-8"> | ||
<MdOutlineFileDownload className="size-4" /> | ||
</Button> | ||
|
||
<Button variant="ghost" size="icon" className="rounded-full size-8"> | ||
<MdContentCopy /> | ||
</Button> | ||
|
||
<Button | ||
variant="ghost" | ||
size="icon" | ||
className="rounded-full size-8 relative" | ||
> | ||
<div className="rounded-full size-1 absolute bg-[#FFD02B] right-[3px] top-[3px] ring-2 ring-background"> | ||
<div className="absolute inset-0 rounded-full bg-[#FFD02B] animate-[ping_1s_ease-in-out_5]" /> | ||
<div className="absolute inset-0 rounded-full bg-[#FFD02B] animate-[pulse_1s_ease-in-out_5] opacity-75" /> | ||
<div className="absolute inset-0 rounded-full bg-[#FFD02B] animate-[pulse_1s_ease-in-out_5] opacity-50" /> | ||
</div> | ||
<MdChatBubbleOutline /> | ||
</Button> | ||
|
||
<InvoiceViewers customer={customer} /> | ||
</div> | ||
</motion.div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
"use client"; | ||
|
||
import { createClient } from "@midday/supabase/client"; | ||
import { AnimatedSizeContainer } from "@midday/ui/animated-size-container"; | ||
import { Avatar, AvatarFallback, AvatarImage } from "@midday/ui/avatar"; | ||
import { Separator } from "@midday/ui/separator"; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from "@midday/ui/tooltip"; | ||
import { motion } from "framer-motion"; | ||
import { useEffect, useState } from "react"; | ||
import type { Customer } from "./invoice-toolbar"; | ||
|
||
interface User { | ||
id: string; | ||
avatar_url: string | null; | ||
full_name: string | null; | ||
} | ||
|
||
type Props = { | ||
customer: Customer; | ||
}; | ||
|
||
export function InvoiceViewers({ customer }: Props) { | ||
const [currentUser, setCurrentUser] = useState<User | null>(null); | ||
const supabase = createClient(); | ||
|
||
useEffect(() => { | ||
async function fetchCurrentUser() { | ||
const { | ||
data: { user }, | ||
} = await supabase.auth.getUser(); | ||
if (user) { | ||
setCurrentUser({ | ||
id: user.id, | ||
avatar_url: user.user_metadata.avatar_url, | ||
full_name: user.user_metadata.full_name, | ||
}); | ||
} | ||
} | ||
|
||
fetchCurrentUser(); | ||
}, []); | ||
|
||
if (!currentUser) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<AnimatedSizeContainer width> | ||
<motion.div | ||
className="flex items-center" | ||
initial={{ width: 0, opacity: 0 }} | ||
animate={{ width: "auto", opacity: 1 }} | ||
transition={{ duration: 0.3, ease: "easeInOut", delay: 0.5 }} | ||
> | ||
<Separator orientation="vertical" className="mr-3 ml-2 h-4" /> | ||
|
||
{currentUser && ( | ||
<div className="mr-2"> | ||
<TooltipProvider delayDuration={0}> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Avatar className="size-5 object-contain border border-border"> | ||
<AvatarImage src={currentUser.avatar_url || undefined} /> | ||
<AvatarFallback> | ||
{currentUser.full_name?.[0]} | ||
</AvatarFallback> | ||
</Avatar> | ||
</TooltipTrigger> | ||
<TooltipContent sideOffset={20} className="text-xs px-2 py-1"> | ||
<p>Viewing right now</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</div> | ||
)} | ||
|
||
<TooltipProvider delayDuration={0}> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Avatar className="size-5 object-contain border border-border"> | ||
{customer?.website && ( | ||
<AvatarImage | ||
src={`https://img.logo.dev/${customer.website}?token=pk_X-1ZO13GSgeOoUrIuJ6GMQ&size=60`} | ||
alt={`${customer.name} logo`} | ||
/> | ||
)} | ||
<AvatarFallback className="text-[9px] font-medium"> | ||
{customer.name?.[0]} | ||
</AvatarFallback> | ||
</Avatar> | ||
</TooltipTrigger> | ||
<TooltipContent sideOffset={20} className="text-xs px-2 py-1"> | ||
<p>Last viewed 30m ago</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</motion.div> | ||
</AnimatedSizeContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.