Skip to content

Commit

Permalink
fix(STK-252): Update My Stack tabs after stack cancellation (#209)
Browse files Browse the repository at this point in the history
* fix: add optional chaning for safety navigation in stack order edge case
* fix: make the stack modal re-fetch all stack orders after it closes
  • Loading branch information
ElRodrigote authored Oct 22, 2024
1 parent 6c41cdd commit 6c4db33
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/app/app/stacks/stacksOrders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const StackOrders = ({ chainId, address }: StackOrdersProps) => {
stacks.orders,
stacks.sort
)}
fetchAllOrders={fetchAllOrders}
refetchStacks={() =>
fetchStacks(index as StackStateIndex)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/app/components/StacksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { ModalId, useModalContext } from "@/contexts";

interface StacksTableProps {
stackOrders: StackOrder[];
fetchAllOrders: () => void;
refetchStacks: () => void;
hasMorePages: boolean;
hasLessPages: boolean;
Expand All @@ -46,6 +47,7 @@ interface StacksTableProps {

export const StacksTable = ({
stackOrders,
fetchAllOrders,
refetchStacks,
hasMorePages,
hasLessPages,
Expand Down Expand Up @@ -165,6 +167,7 @@ export const StacksTable = ({
{stackOrder && (
<StackModal
refetchStacks={refetchStacks}
fetchAllOrders={fetchAllOrders}
isOpen={isModalOpen(ModalId.STACK)}
closeAction={() => closeModal(ModalId.STACK)}
stackOrder={stackOrder}
Expand Down
3 changes: 3 additions & 0 deletions packages/app/components/stack-modal/StackModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { Transaction } from "@/models/stack";

interface StackModalProps extends ModalBaseProps {
stackOrder: StackOrder;
fetchAllOrders: () => void;
refetchStacks: () => void;
}

Expand All @@ -66,6 +67,7 @@ type Content = {
export const StackModal = ({
stackOrder,
isOpen,
fetchAllOrders,
refetchStacks,
closeAction,
}: StackModalProps) => {
Expand Down Expand Up @@ -245,6 +247,7 @@ export const StackModal = ({
<DialogFooterActions
primaryAction={() => {
refetchStacks();
fetchAllOrders();
closeModal(ModalId.CANCEL_STACK_PROCESSING);
closeModal(ModalId.CANCEL_STACK_SUCCESS);
closeAction();
Expand Down
2 changes: 1 addition & 1 deletion packages/app/models/stack-order/stack-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const stackHasRemainingFunds = (stackOrder: StackOrder) =>

export const stackRemainingFunds = (stackOrder: StackOrder) => {
if (
stackOrder.cowOrders.length &&
stackOrder.cowOrders?.length &&
totalFundsUsed(stackOrder) === 0 &&
totalStackOrdersDone(stackOrder) > 0
)
Expand Down

0 comments on commit 6c4db33

Please sign in to comment.