Skip to content

Commit 259b717

Browse files
feat: add a button to refresh data in the CMS pages
1 parent a9ed685 commit 259b717

File tree

1 file changed

+21
-7
lines changed
  • app/(builder)/ycode/components

1 file changed

+21
-7
lines changed

app/(builder)/ycode/components/CMS.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,8 +2035,8 @@ const CMS = React.memo(function CMS() {
20352035

20362036
<div className="p-4 flex items-center justify-between border-b">
20372037

2038-
<div className="relative w-full max-w-72">
2039-
<InputGroup>
2038+
<div className="flex items-center gap-1.5">
2039+
<InputGroup className="w-full max-w-72">
20402040
<InputGroupInput
20412041
placeholder="Search..."
20422042
value={searchQuery}
@@ -2047,11 +2047,25 @@ const CMS = React.memo(function CMS() {
20472047
<Icon name="search" className="size-3" />
20482048
</InputGroupAddon>
20492049
</InputGroup>
2050-
{isLoading && !showSkeleton && (
2051-
<div className="absolute -right-6 top-1/2 -translate-y-1/2">
2052-
<Spinner className="size-4 opacity-50" />
2053-
</div>
2054-
)}
2050+
<Button
2051+
size="sm"
2052+
variant="ghost"
2053+
disabled={isLoading || showSkeleton}
2054+
aria-label="Refresh items"
2055+
onClick={() => {
2056+
if (!selectedCollectionId) return;
2057+
if (searchQuery.trim()) {
2058+
searchItems(selectedCollectionId, searchQuery, currentPage, pageSize, currentSortBy, currentSortOrder);
2059+
} else {
2060+
loadItems(selectedCollectionId, currentPage, pageSize, currentSortBy, currentSortOrder);
2061+
}
2062+
}}
2063+
>
2064+
<Icon
2065+
name="refresh"
2066+
className={cn('size-3', isLoading && !showSkeleton && 'animate-spin')}
2067+
/>
2068+
</Button>
20552069
</div>
20562070

20572071
<div className="flex gap-2">

0 commit comments

Comments
 (0)