Skip to content

Commit

Permalink
fix: type errors with the router upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanCassiere committed Sep 6, 2024
1 parent af41548 commit a12f8bb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 81 deletions.
22 changes: 2 additions & 20 deletions src/routes/-components/auth/header/app-navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import React from "react";
import {
Link,
type AnyRouter,
type LinkProps,
type RegisteredRouter,
type RoutePaths,
} from "@tanstack/react-router";
import { Link, type LinkProps } from "@tanstack/react-router";

import { useLocalStorage } from "@/lib/hooks/useLocalStorage";

import { STORAGE_DEFAULTS, STORAGE_KEYS } from "@/lib/utils/constants";

import type { LinkComponentProps } from "@/lib/types/router";

import { cn } from "@/lib/utils";

const defaultActiveOptions: LinkProps["activeOptions"] = {
Expand Down Expand Up @@ -116,17 +108,7 @@ export const AppNavigation = (props: Props) => {
);
};

const AppNavigationLink = <
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
>(props: {
name: string;
props: LinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &
LinkComponentProps<"a">;
}) => {
const AppNavigationLink = (props: { name: string; props: LinkProps }) => {
const { name, props: linkProps } = props;
return (
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ function Component() {
asChild
>
<Link
from="/agreements/$agreementId/summary"
search={(s) => ({ ...s, summary_tab: tab.id })}
resetScroll={false}
>
Expand Down
21 changes: 3 additions & 18 deletions src/routes/_auth/(dashboard)/-components/stats-block-display.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import React from "react";
import {
Link,
type AnyRouter,
type LinkProps,
type RegisteredRouter,
type RoutePaths,
} from "@tanstack/react-router";
import { Link, type LinkProps } from "@tanstack/react-router";

import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { icons, type LucideIcon } from "@/components/ui/icons";
Expand All @@ -18,8 +12,6 @@ import type { TDashboardStats } from "@/lib/schemas/dashboard";
import { STORAGE_DEFAULTS, STORAGE_KEYS } from "@/lib/utils/constants";
import { localDateToQueryYearMonthDay } from "@/lib/utils/date";

import type { LinkComponentProps } from "@/lib/types/router";

function formatDisplayValue(value: number | null | undefined): string | null {
if (typeof value === "undefined") return null;
return Number(value ?? 0).toString();
Expand Down Expand Up @@ -137,18 +129,11 @@ const DashboardStatsBlock = ({
);
};

const StatBlock = <
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
>(props: {
const StatBlock = (props: {
title: string;
value: string | null;
icon: LucideIcon;
linkProps: LinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &
LinkComponentProps<"a">;
linkProps: LinkProps;
}) => {
const { title, value, icon: Icon, linkProps } = props;

Expand Down
21 changes: 3 additions & 18 deletions src/routes/_auth/(settings)/-components/sub-page-nav-item.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
import * as React from "react";
import {
Link,
type AnyRouter,
type LinkProps,
type RegisteredRouter,
type RoutePaths,
} from "@tanstack/react-router";
import { Link, type LinkProps } from "@tanstack/react-router";
import { useTranslation } from "react-i18next";

import { buttonVariants } from "@/components/ui/button";
import { icons } from "@/components/ui/icons";

import type { LinkComponentProps } from "@/lib/types/router";

import { cn } from "@/lib/utils";

export function SubPageNavItem<
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
>(props: {
export function SubPageNavItem(props: {
title: string;
description: string;
link: LinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &
LinkComponentProps<"a">;
link: LinkProps;
}) {
const { title, description, link } = props;
const { t } = useTranslation();
Expand Down
30 changes: 5 additions & 25 deletions src/routes/_auth/-modules/summary/common.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import * as React from "react";
import {
Link,
type AnyRouter,
type LinkProps,
type RegisteredRouter,
type RoutePaths,
} from "@tanstack/react-router";
import { Link, type LinkProps } from "@tanstack/react-router";
import { cva, type VariantProps } from "class-variance-authority";

import {
Expand All @@ -16,8 +10,6 @@ import {
} from "@/components/ui/accordion";
import { CardHeader, CardTitle } from "@/components/ui/card";

import type { LinkComponentProps } from "@/lib/types/router";

import { cn } from "@/lib/utils";

export const SummaryHeader = ({
Expand Down Expand Up @@ -75,29 +67,17 @@ const accordionValueVariants = cva("font-semibold", {
},
});

interface SummaryLineItemProps<
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
> extends VariantProps<typeof accordionVariants>,
interface SummaryLineItemProps
extends VariantProps<typeof accordionVariants>,
VariantProps<typeof accordionValueVariants> {
label: string;
value: React.ReactNode;
initialDropdownExpanded?: boolean;
children?: React.ReactNode | undefined;
linkOptions?: LinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &
LinkComponentProps<"a">;
linkOptions?: LinkProps;
}

export function SummaryLineItem<
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
>(props: SummaryLineItemProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) {
export function SummaryLineItem(props: SummaryLineItemProps) {
const {
// main
label,
Expand Down

0 comments on commit a12f8bb

Please sign in to comment.