@kodiak-finance/orderly-portfolio 2.8.22-beta.0 → 2.8.22-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -6566,6 +6566,13 @@ var PortfolioLayoutMobile = (props) => {
6566
6566
  ...props.mainNavProps,
6567
6567
  current: props?.current,
6568
6568
  subItems: props?.items,
6569
+ leftNav: {
6570
+ ...props.mainNavProps?.leftNav,
6571
+ menus: [
6572
+ ...props.mainNavProps?.leftNav?.menus || [],
6573
+ ...props?.items || []
6574
+ ]
6575
+ },
6569
6576
  routerAdapter: props.routerAdapter
6570
6577
  }
6571
6578
  ) }),
@@ -9604,10 +9611,23 @@ var formatDateRange = (date) => {
9604
9611
  return void 0;
9605
9612
  return format(date, "yyyy-MM-dd");
9606
9613
  };
9607
- var normalizeDateToUTC = (date) => {
9608
- const dateStr = format(date, "yyyy-MM-dd");
9609
- const [year, month, day] = dateStr.split("-").map(Number);
9610
- return new Date(Date.UTC(year, month - 1, day));
9614
+ var getUtcStartOfDay = (date) => {
9615
+ return new Date(
9616
+ Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
9617
+ );
9618
+ };
9619
+ var getUtcEndOfDay = (date) => {
9620
+ return new Date(
9621
+ Date.UTC(
9622
+ date.getFullYear(),
9623
+ date.getMonth(),
9624
+ date.getDate(),
9625
+ 23,
9626
+ 59,
9627
+ 59,
9628
+ 999
9629
+ )
9630
+ );
9611
9631
  };
9612
9632
  var useSymbolPerformanceScript = (symbol) => {
9613
9633
  const { wrongNetwork, disabledConnect } = useAppContext();
@@ -9624,34 +9644,26 @@ var useSymbolPerformanceScript = (symbol) => {
9624
9644
  const [dateRange, setDateRange] = useState(() => {
9625
9645
  const range = getDateRange("7D" /* WEEK */, today);
9626
9646
  return {
9627
- from: normalizeDateToUTC(range.from),
9628
- to: normalizeDateToUTC(range.to)
9647
+ from: range.from,
9648
+ to: range.to
9629
9649
  };
9630
9650
  });
9631
9651
  const onPeriodChange = (value) => {
9632
9652
  const newRange = getDateRange(value, today);
9633
9653
  setPeriod(value);
9634
9654
  setDateRange({
9635
- from: normalizeDateToUTC(newRange.from),
9636
- to: normalizeDateToUTC(newRange.to)
9655
+ from: newRange.from,
9656
+ to: newRange.to
9637
9657
  });
9638
9658
  };
9639
9659
  const onFilter = (filter) => {
9640
9660
  if (filter.name === "dateRange") {
9641
9661
  const newDateRange = filter.value;
9642
- const normalizedRange = {
9643
- from: normalizeDateToUTC(newDateRange.from),
9644
- to: normalizeDateToUTC(newDateRange.to)
9645
- };
9646
- setDateRange(normalizedRange);
9647
- if (normalizedRange.from && normalizedRange.to) {
9648
- const offsetDay = Math.abs(differenceInDays(normalizedRange.from, normalizedRange.to)) + 1;
9662
+ setDateRange(newDateRange);
9663
+ if (newDateRange.from && newDateRange.to) {
9664
+ const offsetDay = Math.abs(differenceInDays(newDateRange.from, newDateRange.to)) + 1;
9649
9665
  const range = getDateRange(offsetDay, today);
9650
- const normalizedRangeForComparison = {
9651
- from: normalizeDateToUTC(range.from),
9652
- to: normalizeDateToUTC(range.to)
9653
- };
9654
- if (formatDateRange(normalizedRangeForComparison.from) === formatDateRange(normalizedRange.from) && formatDateRange(normalizedRangeForComparison.to) === formatDateRange(normalizedRange.to)) {
9666
+ if (formatDateRange(range.from) === formatDateRange(newDateRange.from) && formatDateRange(range.to) === formatDateRange(newDateRange.to)) {
9655
9667
  setPeriod(
9656
9668
  Object.keys(PRESET_DAYS).find(
9657
9669
  (key) => PRESET_DAYS[key] === offsetDay
@@ -9665,10 +9677,15 @@ var useSymbolPerformanceScript = (symbol) => {
9665
9677
  };
9666
9678
  const startDate = dateRange.from;
9667
9679
  const endDate = dateRange.to;
9680
+ const startDateForAPI = useMemo(() => {
9681
+ if (!startDate)
9682
+ return startDate;
9683
+ return getUtcStartOfDay(startDate);
9684
+ }, [startDate]);
9668
9685
  const endDateForAPI = useMemo(() => {
9669
9686
  if (!endDate)
9670
9687
  return endDate;
9671
- return endOfDay(endDate);
9688
+ return getUtcEndOfDay(endDate);
9672
9689
  }, [endDate]);
9673
9690
  const filterItems = useMemo(() => {
9674
9691
  return [
@@ -9682,12 +9699,12 @@ var useSymbolPerformanceScript = (symbol) => {
9682
9699
  }, [dateRange]);
9683
9700
  const { trades, isLoading, error } = useTrades({
9684
9701
  symbol: selectedSymbol === "ALL_SYMBOLS" ? void 0 : selectedSymbol,
9685
- start_t: startDate ? startDate.getTime() : void 0,
9702
+ start_t: startDateForAPI ? startDateForAPI.getTime() : void 0,
9686
9703
  end_t: endDateForAPI ? endDateForAPI.getTime() : void 0
9687
9704
  });
9688
9705
  const performanceData = useSymbolPerformanceData(
9689
9706
  trades,
9690
- startDate,
9707
+ startDateForAPI,
9691
9708
  endDateForAPI,
9692
9709
  true
9693
9710
  );