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

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.js CHANGED
@@ -6573,6 +6573,13 @@ var PortfolioLayoutMobile = (props) => {
6573
6573
  ...props.mainNavProps,
6574
6574
  current: props?.current,
6575
6575
  subItems: props?.items,
6576
+ leftNav: {
6577
+ ...props.mainNavProps?.leftNav,
6578
+ menus: [
6579
+ ...props.mainNavProps?.leftNav?.menus || [],
6580
+ ...props?.items || []
6581
+ ]
6582
+ },
6576
6583
  routerAdapter: props.routerAdapter
6577
6584
  }
6578
6585
  ) }),
@@ -9611,10 +9618,23 @@ var formatDateRange = (date) => {
9611
9618
  return void 0;
9612
9619
  return dateFns.format(date, "yyyy-MM-dd");
9613
9620
  };
9614
- var normalizeDateToUTC = (date) => {
9615
- const dateStr = dateFns.format(date, "yyyy-MM-dd");
9616
- const [year, month, day] = dateStr.split("-").map(Number);
9617
- return new Date(Date.UTC(year, month - 1, day));
9621
+ var getUtcStartOfDay = (date) => {
9622
+ return new Date(
9623
+ Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
9624
+ );
9625
+ };
9626
+ var getUtcEndOfDay = (date) => {
9627
+ return new Date(
9628
+ Date.UTC(
9629
+ date.getFullYear(),
9630
+ date.getMonth(),
9631
+ date.getDate(),
9632
+ 23,
9633
+ 59,
9634
+ 59,
9635
+ 999
9636
+ )
9637
+ );
9618
9638
  };
9619
9639
  var useSymbolPerformanceScript = (symbol) => {
9620
9640
  const { wrongNetwork, disabledConnect } = orderlyReactApp.useAppContext();
@@ -9631,34 +9651,26 @@ var useSymbolPerformanceScript = (symbol) => {
9631
9651
  const [dateRange, setDateRange] = React12.useState(() => {
9632
9652
  const range = getDateRange("7D" /* WEEK */, today);
9633
9653
  return {
9634
- from: normalizeDateToUTC(range.from),
9635
- to: normalizeDateToUTC(range.to)
9654
+ from: range.from,
9655
+ to: range.to
9636
9656
  };
9637
9657
  });
9638
9658
  const onPeriodChange = (value) => {
9639
9659
  const newRange = getDateRange(value, today);
9640
9660
  setPeriod(value);
9641
9661
  setDateRange({
9642
- from: normalizeDateToUTC(newRange.from),
9643
- to: normalizeDateToUTC(newRange.to)
9662
+ from: newRange.from,
9663
+ to: newRange.to
9644
9664
  });
9645
9665
  };
9646
9666
  const onFilter = (filter) => {
9647
9667
  if (filter.name === "dateRange") {
9648
9668
  const newDateRange = filter.value;
9649
- const normalizedRange = {
9650
- from: normalizeDateToUTC(newDateRange.from),
9651
- to: normalizeDateToUTC(newDateRange.to)
9652
- };
9653
- setDateRange(normalizedRange);
9654
- if (normalizedRange.from && normalizedRange.to) {
9655
- const offsetDay = Math.abs(dateFns.differenceInDays(normalizedRange.from, normalizedRange.to)) + 1;
9669
+ setDateRange(newDateRange);
9670
+ if (newDateRange.from && newDateRange.to) {
9671
+ const offsetDay = Math.abs(dateFns.differenceInDays(newDateRange.from, newDateRange.to)) + 1;
9656
9672
  const range = getDateRange(offsetDay, today);
9657
- const normalizedRangeForComparison = {
9658
- from: normalizeDateToUTC(range.from),
9659
- to: normalizeDateToUTC(range.to)
9660
- };
9661
- if (formatDateRange(normalizedRangeForComparison.from) === formatDateRange(normalizedRange.from) && formatDateRange(normalizedRangeForComparison.to) === formatDateRange(normalizedRange.to)) {
9673
+ if (formatDateRange(range.from) === formatDateRange(newDateRange.from) && formatDateRange(range.to) === formatDateRange(newDateRange.to)) {
9662
9674
  setPeriod(
9663
9675
  Object.keys(PRESET_DAYS).find(
9664
9676
  (key) => PRESET_DAYS[key] === offsetDay
@@ -9672,10 +9684,15 @@ var useSymbolPerformanceScript = (symbol) => {
9672
9684
  };
9673
9685
  const startDate = dateRange.from;
9674
9686
  const endDate = dateRange.to;
9687
+ const startDateForAPI = React12.useMemo(() => {
9688
+ if (!startDate)
9689
+ return startDate;
9690
+ return getUtcStartOfDay(startDate);
9691
+ }, [startDate]);
9675
9692
  const endDateForAPI = React12.useMemo(() => {
9676
9693
  if (!endDate)
9677
9694
  return endDate;
9678
- return dateFns.endOfDay(endDate);
9695
+ return getUtcEndOfDay(endDate);
9679
9696
  }, [endDate]);
9680
9697
  const filterItems = React12.useMemo(() => {
9681
9698
  return [
@@ -9689,12 +9706,12 @@ var useSymbolPerformanceScript = (symbol) => {
9689
9706
  }, [dateRange]);
9690
9707
  const { trades, isLoading, error } = useTrades({
9691
9708
  symbol: selectedSymbol === "ALL_SYMBOLS" ? void 0 : selectedSymbol,
9692
- start_t: startDate ? startDate.getTime() : void 0,
9709
+ start_t: startDateForAPI ? startDateForAPI.getTime() : void 0,
9693
9710
  end_t: endDateForAPI ? endDateForAPI.getTime() : void 0
9694
9711
  });
9695
9712
  const performanceData = useSymbolPerformanceData(
9696
9713
  trades,
9697
- startDate,
9714
+ startDateForAPI,
9698
9715
  endDateForAPI,
9699
9716
  true
9700
9717
  );