-
Notifications
You must be signed in to change notification settings - Fork 2
Add block filtering to store pages #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
ae4f740
605489f
ae95ed8
4c0b9fc
a518f94
b8cda89
292685f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,8 @@ import { | |
| ChatBubbleLeftIcon, | ||
| MapPinIcon, | ||
| ShoppingCartIcon, | ||
| StarIcon | ||
| StarIcon, | ||
| NoSymbolIcon | ||
| } from '@heroicons/react/24/outline' | ||
| import { StarIcon as StarIconSolid } from '@heroicons/react/24/solid' | ||
| import { Sidebar } from '@/components/layout/sidebar' | ||
|
|
@@ -25,6 +26,7 @@ import { storeItemService } from '@/lib/services/store-item-service' | |
| import { storeReviewService } from '@/lib/services/store-review-service' | ||
| import { cartService } from '@/lib/services/cart-service' | ||
| import { parseStorePolicies } from '@/lib/utils/policies' | ||
| import { useBlock } from '@/hooks/use-block' | ||
| import type { Store, StoreItem, StoreReview, StoreRatingSummary, StorePolicy } from '@/lib/types' | ||
|
|
||
| function LoadingFallback() { | ||
|
|
@@ -68,6 +70,9 @@ function StoreDetailContent() { | |
| const [ownerDisplayName, setOwnerDisplayName] = useState<string | null>(null) | ||
| const [ownerUsername, setOwnerUsername] = useState<string | null>(null) | ||
|
|
||
| // Check if store owner is blocked | ||
| const { isBlocked: isOwnerBlocked, isLoading: isBlockLoading, toggleBlock } = useBlock(store?.ownerId ?? '') | ||
|
|
||
| // Subscribe to cart changes | ||
| useEffect(() => { | ||
| const unsubscribe = cartService.subscribe(() => { | ||
|
|
@@ -301,6 +306,32 @@ function StoreDetailContent() { | |
| </div> | ||
| </div> | ||
|
|
||
| {/* Blocked Store Banner */} | ||
| {isOwnerBlocked && ( | ||
| <div className="mx-4 mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg"> | ||
| <div className="flex items-center gap-3"> | ||
| <NoSymbolIcon className="h-6 w-6 text-red-500" /> | ||
| <div className="flex-1"> | ||
| <p className="font-medium text-red-700 dark:text-red-400"> | ||
| You have blocked this store owner | ||
| </p> | ||
| <p className="text-sm text-red-600 dark:text-red-400/80"> | ||
| This store's products won't appear in browse listings. | ||
| </p> | ||
| </div> | ||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| onClick={() => toggleBlock()} | ||
| disabled={isBlockLoading} | ||
| className="border-red-300 dark:border-red-700 text-red-700 dark:text-red-400 hover:bg-red-100 dark:hover:bg-red-900/40" | ||
| > | ||
| Unblock | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Blocking: Do not treat inherited blocks as directly unblockable
source: ['codex'] |
||
| </Button> | ||
| </div> | ||
| </div> | ||
| )} | ||
|
|
||
| {/* Tabs */} | ||
| <div className="flex border-b border-gray-200 dark:border-gray-800"> | ||
| <button | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Blocking: Wait for block status before rendering stores
blockedOwnersis initially empty, and the independent block-status effect does not participate inisLoading. Consequently, when ratings finish before the block query—or the authenticated identity changes after the list is visible—these lines treat unresolved status as if no owners were blocked and render every store as clickable. Keep the list loading or hidden until the block check for the current identity and store set completes.source: ['codex']