|
1 | | -import { Calendar, Hash, Library, Star } from 'lucide-react' |
| 1 | +import { |
| 2 | + ArrowRight, |
| 3 | + Calendar, |
| 4 | + Hash, |
| 5 | + Library, |
| 6 | + MessageSquare, |
| 7 | + Star, |
| 8 | +} from 'lucide-react' |
2 | 9 | import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' |
3 | 10 | import { Badge } from '@/components/ui/badge' |
4 | 11 | import { formatDate, getBookStatus } from '@/lib/utils' |
@@ -130,62 +137,72 @@ export default async function BookDetailsPage({ |
130 | 137 | </div> |
131 | 138 | </CardHeader> |
132 | 139 | <CardContent> |
133 | | - <div className="space-y-6"> |
134 | | - {reviewsRes.data.map((review) => ( |
135 | | - <div |
136 | | - key={review.id} |
137 | | - className="border-b last:border-b-0 pb-6 last:pb-0" |
138 | | - > |
139 | | - <div className="flex items-start justify-between mb-2"> |
140 | | - <div className="flex items-center gap-2"> |
141 | | - <Avatar className="h-8 w-8"> |
142 | | - <AvatarFallback className="text-xs bg-primary/10"> |
143 | | - {review.user.name.slice(0, 2)} |
144 | | - </AvatarFallback> |
145 | | - </Avatar> |
146 | | - <div className="flex flex-col"> |
147 | | - <h4 className="font-medium">{review.user.name}</h4> |
148 | | - <DateTime |
149 | | - dateTime={review.created_at} |
150 | | - className="text-xs text-muted-foreground" |
151 | | - > |
152 | | - {formatDate(review.created_at)} |
153 | | - </DateTime> |
| 140 | + {reviewsRes.meta.total === 0 ? ( |
| 141 | + <div className="text-center py-8 text-muted-foreground"> |
| 142 | + <MessageSquare className="h-12 w-12 mx-auto mb-3 opacity-50" /> |
| 143 | + <p>No reviews yet</p> |
| 144 | + </div> |
| 145 | + ) : ( |
| 146 | + <> |
| 147 | + <div className="space-y-6"> |
| 148 | + {reviewsRes.data.map((review) => ( |
| 149 | + <div |
| 150 | + key={review.id} |
| 151 | + className="border-b last:border-b-0 pb-6 last:pb-0" |
| 152 | + > |
| 153 | + <div className="flex items-start justify-between mb-2"> |
| 154 | + <div className="flex items-center gap-2"> |
| 155 | + <Avatar className="h-8 w-8"> |
| 156 | + <AvatarFallback className="text-xs bg-primary/10"> |
| 157 | + {review.user.name.slice(0, 2)} |
| 158 | + </AvatarFallback> |
| 159 | + </Avatar> |
| 160 | + <div className="flex flex-col"> |
| 161 | + <h4 className="font-medium">{review.user.name}</h4> |
| 162 | + <DateTime |
| 163 | + dateTime={review.created_at} |
| 164 | + className="text-xs text-muted-foreground" |
| 165 | + > |
| 166 | + {formatDate(review.created_at)} |
| 167 | + </DateTime> |
| 168 | + </div> |
| 169 | + </div> |
| 170 | + <div className="flex items-center gap-1"> |
| 171 | + {[1, 2, 3, 4, 5].map((star) => ( |
| 172 | + <Star |
| 173 | + key={star} |
| 174 | + className={`h-4 w-4 ${ |
| 175 | + star <= review.rating |
| 176 | + ? 'fill-(--color-vibrant,var(--color-yellow-400)) text-(--color-vibrant,var(--color-yellow-400))' |
| 177 | + : 'text-gray-300' |
| 178 | + }`} |
| 179 | + /> |
| 180 | + ))} |
| 181 | + </div> |
154 | 182 | </div> |
| 183 | + <p className="text-sm leading-relaxed text-foreground"> |
| 184 | + {review.comment} |
| 185 | + </p> |
155 | 186 | </div> |
156 | | - <div className="flex items-center gap-1"> |
157 | | - {[1, 2, 3, 4, 5].map((star) => ( |
158 | | - <Star |
159 | | - key={star} |
160 | | - className={`h-4 w-4 ${ |
161 | | - star <= review.rating |
162 | | - ? 'fill-(--color-vibrant,var(--color-yellow-400)) text-(--color-vibrant,var(--color-yellow-400))' |
163 | | - : 'text-gray-300' |
164 | | - }`} |
165 | | - /> |
166 | | - ))} |
167 | | - </div> |
168 | | - </div> |
169 | | - <p className="text-sm leading-relaxed text-foreground"> |
170 | | - {review.comment} |
171 | | - </p> |
| 187 | + ))} |
172 | 188 | </div> |
173 | | - ))} |
174 | | - </div> |
175 | | - <div className="mt-6 pt-6 border-t"> |
176 | | - <Link |
177 | | - href={`/books/${id}/reviews`} |
178 | | - aria-disabled={reviewsRes.meta.total === 0} |
179 | | - > |
180 | | - <Button |
181 | | - variant="outline" |
182 | | - className="w-full bg-transparent" |
183 | | - disabled={reviewsRes.meta.total === 0} |
184 | | - > |
185 | | - View All Reviews ({reviewsRes.meta.total}) |
186 | | - </Button> |
187 | | - </Link> |
188 | | - </div> |
| 189 | + <div className="mt-6 pt-6 border-t"> |
| 190 | + <Link |
| 191 | + href={`/books/${id}/reviews`} |
| 192 | + aria-disabled={reviewsRes.meta.total === 0} |
| 193 | + > |
| 194 | + <Button |
| 195 | + variant="ghost" |
| 196 | + className="w-full bg-transparent" |
| 197 | + disabled={reviewsRes.meta.total === 0} |
| 198 | + > |
| 199 | + View All Reviews ({reviewsRes.meta.total}) |
| 200 | + <ArrowRight /> |
| 201 | + </Button> |
| 202 | + </Link> |
| 203 | + </div>{' '} |
| 204 | + </> |
| 205 | + )} |
189 | 206 | </CardContent> |
190 | 207 | </Card> |
191 | 208 | </div> |
|
0 commit comments