diff --git a/src/assets/scss/components/_datatable.scss b/src/assets/scss/components/_datatable.scss index d5eabdd..a1caf42 100644 --- a/src/assets/scss/components/_datatable.scss +++ b/src/assets/scss/components/_datatable.scss @@ -270,9 +270,19 @@ table { } .actions { display: flex; - justify-content: end; + justify-content: space-between; column-gap: 10px; - padding: 20px; + padding: 20px 20px 20px 0; + + .left { + display: flex; + column-gap: 10px; + } + .right { + justify-self: end; + display: flex; + column-gap: 10px; + } } } @@ -285,7 +295,8 @@ table { background-color: transparent; } - .table-data-row:hover, .datatable-row-accordion:hover { + .table-data-row:hover, + .datatable-row-accordion:hover { background-color: $white; } diff --git a/src/assets/scss/components/_modal.scss b/src/assets/scss/components/_modal.scss index 6e4d0ee..f00136c 100644 --- a/src/assets/scss/components/_modal.scss +++ b/src/assets/scss/components/_modal.scss @@ -48,7 +48,7 @@ } &.lg { min-width: 40%; - max-width: 60%; + max-width: 50%; } .modal-header { diff --git a/src/components/modal/ChangeCollateralStatus.component.tsx b/src/components/modal/ChangeCollateralStatus.component.tsx new file mode 100644 index 0000000..79fe838 --- /dev/null +++ b/src/components/modal/ChangeCollateralStatus.component.tsx @@ -0,0 +1,110 @@ +/* eslint-disable @typescript-eslint/no-misused-promises */ +import { type FC, useMemo, useCallback, useState } from 'react' +import { Button, Modal, Icon } from '@/components' +import { TokenIconMapping } from '@/constants' +import { toast } from 'react-toastify' +import { cedroClient } from '@/configs/chainConfig' +import { type IProtocolActionModalProps, type IProtocolActionButtonProps } from '@/@types/misc.types' + +export const ChangeCollateralStatus: FC = ({ + poolId, + chain, + variant = 'primary', + icon +}) => { + const [isModalVisible, setIsModalVisible] = useState(false) + const onModalToggle = useCallback(() => { + setIsModalVisible((prev) => !prev) + }, [setIsModalVisible]) + + return ( + <> + {isModalVisible && ( + + )} + + + ) +} + +export const ChangeCollateralStatusModal: FC = ({ + poolId, + chain: selectedChain, + isModalVisible, + onModalToggle +}) => { + const [isBtnLoading, setIsBtnLoading] = useState(false) + const isTokenDisabled = false + + const token = useMemo(() => { + const { tokenConfig } = cedroClient.Config.getPoolTokenForChain(selectedChain, poolId) + return tokenConfig.symbol + }, [poolId, selectedChain]) + + const handleChangeStatus = useCallback(() => { + setIsBtnLoading(true) + try { + if (isTokenDisabled) { + toast.success(`${token} Enabled`) + } else { + toast.success(`${token} Disabled`) + } + } catch (error) { + toast.error(`Error while approving ${token}`) + } finally { + setIsBtnLoading(false) + onModalToggle() + } + }, [selectedChain, poolId]) + + return ( + +
+
+

Disable {token}

+
+
+
+ + + {/* TODO update description */} +
+ To Supply {token} to Cedro Protocol as + collateral, you need to enable it first. +
+
+ +
+ +
+ +
+
+
+ ) +} diff --git a/src/components/modal/index.tsx b/src/components/modal/index.tsx index f917de4..ac630fb 100644 --- a/src/components/modal/index.tsx +++ b/src/components/modal/index.tsx @@ -3,3 +3,4 @@ export { ModalHeader } from './ModalHeader.component' export { SwitchNetwork } from './SwitchNetwork.component' export { TestTokens } from './TestTokens.component' export { LiquidationList } from './LiquidationList.component' +export { ChangeCollateralStatus } from './ChangeCollateralStatus.component' diff --git a/src/containers/market.tsx b/src/containers/market.tsx index 70b0e83..3d3617d 100644 --- a/src/containers/market.tsx +++ b/src/containers/market.tsx @@ -134,7 +134,30 @@ export const MarketColumnDefinition: Array> = [ style: { display: 'flex', justifyContent: 'flex-end', - flex: 0.9 + flex: 1 + } + } + } + }, + sortingFn: floatSortingFn + }, + { + accessorKey: 'price', + header: 'Price', + cell: (props) => { + const price = props.getValue() + + return ( + + ) + }, + meta: { + getCellContext: () => { + return { + style: { + display: 'flex', + justifyContent: 'flex-end', + flex: 0.8 } } } @@ -155,7 +178,7 @@ export const MarketColumnDefinition: Array> = [ style: { display: 'flex', justifyContent: 'flex-end', - flex: 1 + flex: 0.9 } } } @@ -174,7 +197,7 @@ export const MarketColumnDefinition: Array> = [ style: { display: 'flex', justifyContent: 'flex-end', - flex: 0.8 + flex: 0.7 } } } @@ -195,7 +218,7 @@ export const MarketColumnDefinition: Array> = [ style: { display: 'flex', justifyContent: 'flex-end', - flex: 1 + flex: 0.9 } } } @@ -214,7 +237,7 @@ export const MarketColumnDefinition: Array> = [ style: { display: 'flex', justifyContent: 'flex-end', - flex: 0.8 + flex: 0.7 } } }