-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⛪️🌴 ↝ Okay, so I think we've got a start on the UI, now to add the ba…
…ckend back
- Loading branch information
1 parent
cfd08dc
commit f82b452
Showing
38 changed files
with
1,777 additions
and
1,328 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,148 @@ | ||
import { AvatarFallback, Avatar, AvatarImage } from "../ui/Avatar"; | ||
import { Button } from "../ui/Button"; | ||
import { Card, CardContent, CardFooter, CardTitle } from "./PostCard"; | ||
// import { Input } from "@/components/ui/input"; | ||
import { Separator } from "@radix-ui/react-separator"; | ||
import { useToast } from "../ui/use-toast"; | ||
import { getMetaData } from "../../lib/helper/str.helper"; | ||
import { Megaphone, MessagesSquare, Share2 } from "lucide-react"; | ||
import Link from "next/link"; | ||
import React, { useEffect, useState } from "react"; | ||
|
||
type TProps = { | ||
public_id: string; | ||
content: string; | ||
created_at: string; | ||
user?: { | ||
name: string; | ||
username: string; | ||
image: string | null; | ||
} | null; | ||
anonymous?: { | ||
username: string; | ||
} | null; | ||
_count: { | ||
comments: number; | ||
}; | ||
}; | ||
|
||
const CardForum: React.FC<TProps> = ({ | ||
public_id, | ||
content, | ||
created_at, | ||
user, | ||
anonymous, | ||
_count, | ||
}) => { | ||
const [reason, setReason] = useState(""); | ||
const [openReason, setOpenReason] = useState(false); | ||
const [response, setResponse] = useState({ | ||
message: "", | ||
}); | ||
|
||
const { toast } = useToast(); | ||
|
||
// const { mutate: reportPost, isLoading } = trpc.post.reportPost.useMutation(); | ||
|
||
useEffect(() => { | ||
if (!!response.message) { | ||
toast({ | ||
title: "Notifikasi", | ||
description: response.message, | ||
}); | ||
|
||
setResponse({ | ||
message: "", | ||
}); | ||
} | ||
}, [response]); | ||
|
||
return ( | ||
<> | ||
<div | ||
className={`fixed inset-0 bg-white/80 backdrop-blur-md z-20 items-center justify-center ${openReason ? "flex" : "hidden" | ||
}`} | ||
> | ||
<Card> | ||
<CardTitle className="font-bold p-4">Apa alasan lo bre ?</CardTitle> | ||
<CardContent className="p-4 pt-0"> | ||
{/* <Input | ||
onChange={(e) => setReason(e.target.value)} | ||
required | ||
autoFocus={true} | ||
type="text" | ||
placeholder="Jangan panjang panjang..." | ||
/> */} | ||
</CardContent> | ||
<CardFooter className="p-4 pt-0 flex gap-2 justify-between"> | ||
<Button | ||
onClick={() => setOpenReason(false)} | ||
className="w-1/2" | ||
variant="outline" | ||
> | ||
Gak Jadi | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
</div> | ||
<Card> | ||
<Link href={`/profil/${user?.username}`}> | ||
<CardTitle | ||
className={`p-4 pb-0 group ${!anonymous && "cursor-pointer"}`} | ||
> | ||
<div className="flex items-start gap-4"> | ||
<Avatar className="rounded-md"> | ||
<AvatarImage src={(user && user.image) ?? ""} /> | ||
<AvatarFallback className="rounded-md"> | ||
{(user && user.name[0].toUpperCase()) ?? "A"} | ||
</AvatarFallback> | ||
</Avatar> | ||
<div className="space-y-1"> | ||
<h2 className={`${!anonymous && "group-hover:underline"}`}> | ||
{anonymous ? "Anonymous" : user && user.name} | ||
</h2> | ||
<p | ||
className={`text-foreground/60 ${!anonymous && "group-hover:underline" | ||
}`} | ||
> | ||
{anonymous ? anonymous.username : user && user.username} | ||
</p> | ||
</div> | ||
</div> | ||
</CardTitle> | ||
</Link> | ||
<CardContent className="p-4 pt-2"> | ||
<div> | ||
<small className="text-foreground/60 text-sm"> | ||
Metadata {getMetaData(created_at)} | ||
</small> | ||
</div> | ||
<p className="mt-1 break-all">{content}</p> | ||
</CardContent> | ||
<CardFooter className="p-0 flex-col items-start pb-2"> | ||
<Separator className="mb-2" /> | ||
<div className="space-x-2 px-4 py-2"> | ||
<Link href={`/forum/${public_id}`}> | ||
<Button variant="outline" size="default" className="space-x-2"> | ||
<MessagesSquare className="w-5 aspect-square" /> | ||
<span>{_count.comments}</span> | ||
</Button> | ||
</Link> | ||
<Button variant="outline" size="icon"> | ||
<Share2 className="w-5 aspect-square" /> | ||
</Button> | ||
<Button | ||
onClick={() => setOpenReason(true)} | ||
variant="destructive" | ||
size="icon" | ||
> | ||
<Megaphone className="w-5 aspect-square" /> | ||
</Button> | ||
</div> | ||
</CardFooter> | ||
</Card> | ||
</> | ||
); | ||
}; | ||
|
||
export default CardForum; |
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,83 @@ | ||
import * as React from "react"; | ||
|
||
import { cn } from "../../lib/uitls"; | ||
|
||
const Card = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"rounded-xl border bg-card text-card-foreground shadow", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
Card.displayName = "Card"; | ||
|
||
const CardHeader = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex flex-col space-y-1.5 p-6", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardHeader.displayName = "CardHeader"; | ||
|
||
const CardTitle = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLHeadingElement> | ||
>(({ className, ...props }, ref) => ( | ||
<h3 | ||
ref={ref} | ||
className={cn("font-semibold leading-none tracking-tight", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardTitle.displayName = "CardTitle"; | ||
|
||
const CardDescription = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLParagraphElement> | ||
>(({ className, ...props }, ref) => ( | ||
<p | ||
ref={ref} | ||
className={cn("text-sm text-muted-foreground", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardDescription.displayName = "CardDescription"; | ||
|
||
const CardContent = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> | ||
)); | ||
CardContent.displayName = "CardContent"; | ||
|
||
const CardFooter = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex items-center p-6 pt-0", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardFooter.displayName = "CardFooter"; | ||
|
||
export { | ||
Card, | ||
CardHeader, | ||
CardFooter, | ||
CardTitle, | ||
CardDescription, | ||
CardContent, | ||
}; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.