correct exchange rate
This commit is contained in:
@@ -167,7 +167,7 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
||||
Echange rate
|
||||
Exchange rate
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/create-io"):
|
||||
|
||||
@@ -221,7 +221,7 @@ const InvestorDetails = () => {
|
||||
variant={"solid"}
|
||||
>
|
||||
{/* {item.KYCStatus ? "Completed" : "Not complete"} */}
|
||||
{item?.KYCStatus === true ? "Completed" : "NotCompleted"}
|
||||
{item?.KYCStatus === true ? "Completed" : "Not Completed"}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
@@ -321,7 +321,7 @@ const InvestorDetails = () => {
|
||||
KYC Status
|
||||
</option>
|
||||
<option value="">KYC Status</option>
|
||||
<option value="0">Incompleted</option>
|
||||
<option value="0">Not Completed</option>
|
||||
<option value="1">Completed</option>
|
||||
</Select>
|
||||
|
||||
@@ -337,7 +337,7 @@ const InvestorDetails = () => {
|
||||
Country
|
||||
</option>
|
||||
<option value="">All</option>
|
||||
<option value="1">Behrain</option>
|
||||
<option value="1">Bahrain</option>
|
||||
<option value="2">Kuwait</option>
|
||||
<option value="3">Oman</option>
|
||||
<option value="4">Qatar</option>
|
||||
|
||||
@@ -48,14 +48,16 @@ import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders";
|
||||
|
||||
const editExchange = yup.object().shape({
|
||||
rate: yup
|
||||
.number()
|
||||
.string()
|
||||
.required("Rate is required")
|
||||
.positive("Rate must be greater than 0")
|
||||
.matches(
|
||||
/^\d+\.\d{8}$/,
|
||||
"Rate must have exactly 8 decimal places"
|
||||
)
|
||||
.test(
|
||||
"is-decimal",
|
||||
"Rate must have exactly 8 decimal places",
|
||||
(value) =>
|
||||
value !== undefined && value.toString().match(/^\d+(\.\d{8})?$/)
|
||||
"is-positive",
|
||||
"Rate must be greater than 0",
|
||||
(value) => parseFloat(value) > 0
|
||||
),
|
||||
});
|
||||
|
||||
@@ -86,7 +88,7 @@ const EditExchangeRate = ({
|
||||
const [isBtnLoading, setIsBtnLoading] = useState(false);
|
||||
const [rateError, setRateError] = useState("");
|
||||
|
||||
const { data, isLoading, errors,refetch } = useGetExchangeRateByIdQuery(id, {
|
||||
const { data, isLoading, errors,refetch, isFetching } = useGetExchangeRateByIdQuery(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
@@ -95,17 +97,23 @@ const EditExchangeRate = ({
|
||||
const [rate, setRate] = useState("");
|
||||
const [alert, setAlert] = useState(false);
|
||||
|
||||
console.log(rate);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (id) {refetch()}
|
||||
if (foundObject) {
|
||||
setRate(foundObject.rate);
|
||||
const numericRate = parseFloat(foundObject.rate) || 0; // Convert to number or default to 0 if invalid
|
||||
setRate(numericRate.toFixed(8)); // Set rate with exactly 8 decimal places
|
||||
}
|
||||
}, [foundObject, isOpen]);
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if (id) {
|
||||
refetch()
|
||||
}
|
||||
},[isOpen])
|
||||
// useEffect(()=>{
|
||||
// if (id) {
|
||||
// refetch()
|
||||
// }
|
||||
// },[isOpen])
|
||||
|
||||
const validateRate = async () => {
|
||||
try {
|
||||
@@ -178,7 +186,7 @@ const EditExchangeRate = ({
|
||||
<DrawerCloseButton />
|
||||
<DrawerHeader fontSize={"md"}>Edit rate</DrawerHeader>
|
||||
|
||||
{isLoading ? (
|
||||
{isFetching ? (
|
||||
<FullscreenLoaders />
|
||||
) : (
|
||||
<>
|
||||
@@ -228,8 +236,11 @@ const EditExchangeRate = ({
|
||||
size={"sm"}
|
||||
value={rate}
|
||||
onChange={(e) => {
|
||||
return setRate(e.target.value);
|
||||
// validateRate()
|
||||
const value = e.target.value;
|
||||
// Match numbers with at most 8 decimal places
|
||||
if (/^\d*\.?\d{0,8}$/.test(value)) {
|
||||
setRate(value);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{rateError && (
|
||||
|
||||
Reference in New Issue
Block a user