Skip to content

Commit

Permalink
preselect repay type
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhochu committed Dec 29, 2023
1 parent 2baca0c commit c34fe7f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/Modal/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ export function useBorrowTrigger(tokenId: string) {
};
}

export function useRepayTrigger(tokenId: string) {
export function useRepayTrigger(tokenId: string, position?: string) {
const dispatch = useAppDispatch();
return () => {
dispatch(showModal({ action: "Repay", tokenId, amount: "0" }));
dispatch(showModal({ action: "Repay", tokenId, amount: "0", position }));
};
}
1 change: 1 addition & 0 deletions redux/appSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const appSlice = createSlice({
action: TokenAction;
amount: string;
tokenId: string;
position?: string;
}>,
) {
state.selected = { ...state.selected, isMax: false, ...action.payload };
Expand Down
2 changes: 2 additions & 0 deletions redux/selectors/getPortfolioAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const getPortfolioAssets = createSelector(
totalBorrowedUSD += borrowedUSD;
return standardizeAsset({
tokenId,
shadow_id: DEFAULT_POSITION,
collateralType: CONST_COLLATERAL_TYPE.SINGLE_TOKEN,
metadata: asset.metadata,
symbol: asset.metadata.symbol,
Expand Down Expand Up @@ -170,6 +171,7 @@ export const getPortfolioAssets = createSelector(
totalBorrowedUSD += borrowedUSD;
return standardizeAsset({
tokenId,
shadow_id,
collateralType: CONST_COLLATERAL_TYPE.LP_TOKEN,
metadata: asset.metadata,
metadataLP: lpAsset.metadata,
Expand Down
3 changes: 2 additions & 1 deletion screens/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ type TableRowSelect = {
data: {
tokenId: string | null | undefined;
canUseAsCollateral: boolean | undefined;
shadow_id?: string | null | undefined;
} | null;
index: number | null | undefined;
};
Expand Down Expand Up @@ -377,7 +378,7 @@ const YourBorrowed = ({ borrowedRows, accountId, total }) => {
actionRow={
<div className="flex gap-2 pb-6 table-action-row">
<MarketButton tokenId={selected?.data?.tokenId} />
<RepayButton tokenId={selected?.data?.tokenId} />
<RepayButton tokenId={selected?.data?.tokenId} position={selected?.data?.shadow_id} />
</div>
}
/>
Expand Down
4 changes: 2 additions & 2 deletions screens/Dashboard/supplyBorrowButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const AdjustButton = ({ tokenId }) => {
);
};

export const RepayButton = ({ tokenId }) => {
const handleRepayClick = useRepayTrigger(tokenId);
export const RepayButton = ({ tokenId, position }) => {
const handleRepayClick = useRepayTrigger(tokenId, position);
return (
<div
role="button"
Expand Down
2 changes: 1 addition & 1 deletion screens/Dashboard/supplyBorrowListMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const BorrowItem = ({ data }) => {
</ItemRow>

<div className="">
<RepayButton tokenId={data?.tokenId} />
<RepayButton tokenId={data?.tokenId} position={data?.shadow_id} />
</div>
</div>
</div>
Expand Down

0 comments on commit c34fe7f

Please sign in to comment.