@@ -3,7 +3,7 @@ import { useQueryAutomationPosts } from "@/hooks/user-queries";
3
3
import React from "react" ;
4
4
import TriggerButton from "../trigger-button" ;
5
5
import { InstagramPostProps } from "@/types/posts.type" ;
6
- import { CheckCircle } from "lucide-react" ;
6
+ import { CheckCircle , ImageIcon , Film } from "lucide-react" ;
7
7
import Image from "next/image" ;
8
8
import { cn } from "@/lib/utils" ;
9
9
import { Button } from "@/components/ui/button" ;
@@ -20,11 +20,11 @@ const PostButton = ({ id }: Props) => {
20
20
return (
21
21
< TriggerButton label = "Attach a post" >
22
22
{ data ?. status === 200 && data ?. data ?. data ?. length > 0 ? (
23
- < div className = "flex flex-col gap-y-3 w-full" >
24
- < div className = "flex flex-wrap w-full gap-3 " >
23
+ < div className = "flex flex-col gap-y-4 w-full max-h-[70vh] overflow-y-auto p-2 " >
24
+ < div className = "grid grid-cols-2 sm:grid-cols-3 gap-4 w-full " >
25
25
{ data ?. data ?. data ?. map ( ( post : InstagramPostProps ) => (
26
26
< div
27
- className = "relative w-4/12 aspect-square rounded-lg cursor-pointer overflow-hidden"
27
+ className = "relative aspect-square rounded-xl cursor-pointer overflow-hidden bg-gray-100 group "
28
28
key = { post . id }
29
29
onClick = { ( ) =>
30
30
onSelectPost ( {
@@ -35,36 +35,55 @@ const PostButton = ({ id }: Props) => {
35
35
} )
36
36
}
37
37
>
38
+ { post . media_type === "VIDEO" ? (
39
+ < div className = "w-full h-full" >
40
+ < video
41
+ src = { post . media_url }
42
+ className = "w-full h-full object-cover"
43
+ muted
44
+ playsInline
45
+ />
46
+ < Film className = "absolute top-2 right-2 text-white z-10" size = { 20 } />
47
+ </ div >
48
+ ) : (
49
+ < div className = "w-full h-full" >
50
+ < Image
51
+ fill
52
+ src = { post . media_url }
53
+ alt = { post . caption || "Instagram post" }
54
+ className = "object-cover transition-all duration-200 group-hover:scale-105"
55
+ sizes = "(max-width: 640px) 50vw, 33vw"
56
+ priority
57
+ />
58
+ { post . media_type === "CAROSEL_ALBUM" && (
59
+ < ImageIcon className = "absolute top-2 right-2 text-white z-10" size = { 20 } />
60
+ ) }
61
+ </ div >
62
+ ) }
38
63
{ posts . find ( ( p ) => p . postid === post . id ) && (
39
- < CheckCircle
40
- fill = "white"
41
- stroke = "black"
42
- className = "absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-50"
43
- />
64
+ < div className = "absolute inset-0 bg-black/50 flex items-center justify-center" >
65
+ < CheckCircle
66
+ className = "text-white"
67
+ size = { 24 }
68
+ />
69
+ </ div >
44
70
) }
45
- < Image
46
- fill
47
- sizes = "100vw"
48
- src = { post . media_url }
49
- alt = "post image"
50
- className = { cn (
51
- "hover:opacity-75 transition duration-100" ,
52
- posts . find ( ( p ) => p . postid === post . id ) && "opacity-75"
53
- ) }
54
- />
55
71
</ div >
56
72
) ) }
57
73
</ div >
58
74
< Button
59
75
onClick = { mutate }
60
76
disabled = { posts . length === 0 }
61
- className = "bg-gradient-to-br w-full from-[#3352CC] font-medium text-white to-[#1C2D70]"
77
+ className = "bg-gradient-to-br w-full from-[#3352CC] font-medium text-white to-[#1C2D70] hover:opacity-90 transition-opacity "
62
78
>
63
- < Loader state = { isPending } > Attach Post</ Loader >
79
+ < Loader state = { isPending } > Attach { posts . length } Post{ posts . length !== 1 ? 's' : '' } </ Loader >
64
80
</ Button >
65
81
</ div >
66
82
) : (
67
- < p className = "text-text-secondary text-center" > No posts found!</ p >
83
+ < div className = "p-8 text-center" >
84
+ < p className = "text-gray-500" > No Instagram posts found</ p >
85
+ < p className = "text-sm text-gray-400 mt-1" > Connect your Instagram account to see your posts</ p >
86
+ </ div >
68
87
) }
69
88
</ TriggerButton >
70
89
) ;
0 commit comments