Skip to content
Snippets Groups Projects
Commit fe30ce9d authored by Lukas's avatar Lukas
Browse files

Update DateTimePicker componet start date based on end date

parent 75311596
No related branches found
No related tags found
2 merge requests!481bring recent develop changes to mater to match the backend,!477Lbudginas/#374 calendar dates selection bug
Pipeline #109499 canceled
......@@ -102,27 +102,41 @@ const VotesHistoryDialog: React.FC<VotersDialogProps> = ({
useEffect(() => {
const fetchDynamicGlobalProperties = async () => {
const dynamicGlobalProperties =
await fetchingService.getDynamicGlobalProperties();
const _totalVestingfundHive =
dynamicGlobalProperties.total_vesting_fund_hive;
const _totalVestingShares = dynamicGlobalProperties.total_vesting_shares;
const dynamicGlobalProperties = await fetchingService.getDynamicGlobalProperties();
const _totalVestingfundHive = dynamicGlobalProperties.total_vesting_fund_hive;
const _totalVestingShares = dynamicGlobalProperties.total_vesting_shares;
setTotalVestingFundHive(_totalVestingfundHive);
setTotalVestingShares(_totalVestingShares);
}
setTotalVestingFundHive(_totalVestingfundHive);
setTotalVestingShares(_totalVestingShares);
};
fetchDynamicGlobalProperties();
}, []);
}, []);
const fetchHivePower = (value: string, isHP: boolean): string => {
if (isHP) {
if (!hiveChain) return "";
return convertVestsToHP(hiveChain,value,totalVestingFundHive,totalVestingShares);
const fetchHivePower = (value: string, isHP: boolean): string => {
if (isHP) {
if (!hiveChain) return "";
return convertVestsToHP(
hiveChain,
value,
totalVestingFundHive,
totalVestingShares
);
}
return formatNumber(parseInt(value),true,false)+ " Vests"; // Return raw vests if not toggled to HP
return formatNumber(parseInt(value), true, false) + " Vests"; // Return raw vests if not toggled to HP
};
useEffect(() => {
if (fromDate >= toDate) {
const date = new Date(toDate);
date.setHours(date.getHours() - 1);
setFromDate(date);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fromDate, toDate]);
return (
<Dialog
open={isVotesHistoryOpen}
......@@ -163,7 +177,7 @@ const VotesHistoryDialog: React.FC<VotersDialogProps> = ({
/>
<label>HP</label>
</div>
</div>
</div>
<div className="flex justify-around items-center bg-explorer-bg-start rounded text-text p-2">
<div>
<p>From: </p>
......@@ -171,7 +185,7 @@ const VotesHistoryDialog: React.FC<VotersDialogProps> = ({
date={fromDate}
setDate={setFromDate}
side="bottom"
disableFutureDates={true}
endDate={toDate}
/>
</div>
<div>
......
import React from "react";
import React, { useEffect } from "react";
import { SearchRangesResult } from "../../hooks/common/useSearchRanges";
import { Select, SelectContent, SelectTrigger, SelectItem } from "../ui/select";
......@@ -43,6 +43,16 @@ const SearchRanges: React.FC<SearchRangesProps> = ({
}
};
useEffect(() => {
if (!startDate || !endDate) return;
if (startDate >= endDate) {
const date = new Date(endDate);
date.setHours(date.getHours() - 1);
setStartDate(date);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [startDate, endDate]);
return (
<div className="py-2 flex flex-col gap-y-2">
<Select
......@@ -165,6 +175,7 @@ const SearchRanges: React.FC<SearchRangesProps> = ({
<DateTimePicker
date={startDate || new Date()}
setDate={setStartDate}
endDate={endDate}
/>
</div>
<div className="flex flex-col w-full">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment