Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Fix merchant pages when there are 0 items
Browse files Browse the repository at this point in the history
  • Loading branch information
0xBuzzLightyear committed Sep 27, 2023
1 parent 9d3d73b commit 973b8e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
10 changes: 3 additions & 7 deletions ui-dashboard/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,16 @@ const App: React.FC = () => {
};

const listMerchant = async () => {
if (!user) {
return;
if (user && newMerchantId) {
await getMerchant(newMerchantId);
}

if (!newMerchantId) return;

await getMerchant(newMerchantId);
setIsLoading(false);
};

await getCookie();
await getMe();
await listMerchants();
await listMerchant();
setIsLoading(false);
};

useMount(async () => {
Expand Down
2 changes: 2 additions & 0 deletions ui-dashboard/src/hooks/use-merchant-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const useMerchantId = (): MerchantIdState => {
setMerchantId(merchantId);
if (merchantId) {
localStorage.set("merchantId", merchantId);
} else {
localStorage.remove("merchantId");
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ const ManageMerchantsPage: React.FC = () => {
await getMerchants();

const nextMerchant = merchants?.find((merchantItem) => merchantItem.id !== merchant.id);

if (nextMerchant) {
setMerchantId(nextMerchant.id);
}
setMerchantId(nextMerchant ? nextMerchant.id : null);

openNotification(`Merchant ${merchant.name} has been deleted`, "Thank you for being with us");
} catch (error) {
Expand Down

0 comments on commit 973b8e9

Please sign in to comment.