Skip to content

Commit

Permalink
routes types
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed May 17, 2024
1 parent 31e16e4 commit ad5465b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/components/adminPage/users/userInvitation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const InvitationLink = () => {
});

const showInviationDetails = (invite: InvitationLinkType) => {
const expired = new Date(invite.expires) < new Date() || invite?.used;
const expired = new Date(invite.expiresAt) < new Date() || invite?.used;
callModal({
title: t("admin.users.authentication.generateInvitation.invitationModal.header"),
rootStyle: "text-left",
Expand Down Expand Up @@ -67,7 +67,7 @@ const InvitationLink = () => {
<span className="text-error">Expired</span>
) : (
<span>
Expires in <TimeAgo date={invite.expires} />
Expires in <TimeAgo date={invite.expiresAt} />
</span>
)}
</p>
Expand Down Expand Up @@ -134,7 +134,7 @@ const InvitationLink = () => {
</p>
<div className="flex flex-wrap gap-3">
{invitationData?.map((invite) => {
const expired = new Date(invite.expires) < new Date() || invite?.used;
const expired = new Date(invite.expiresAt) < new Date() || invite?.used;
return (
<div
key={invite.id}
Expand All @@ -154,7 +154,7 @@ const InvitationLink = () => {
{`${expired ? " Expired" : " Expires in"}`}
{!expired && (
<span className="pl-1">
<TimeAgo date={invite.expires} />
<TimeAgo date={invite.expiresAt} />
</span>
)}
</p>
Expand Down
11 changes: 9 additions & 2 deletions src/components/networkByIdPage/memberOptionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
useTrpcApiErrorHandler,
useTrpcApiSuccessHandler,
} from "~/hooks/useTrpcApiHandler";
import { RoutesEntity } from "~/types/local/network";

interface ModalContentProps {
nwid: string;
Expand Down Expand Up @@ -96,7 +97,10 @@ export const MemberOptionsModal: React.FC<ModalContentProps> = ({
// };

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const subnetMatch = isIPInSubnet(e.target.value, networkById?.network?.routes);
const subnetMatch = isIPInSubnet(
e.target.value,
networkById?.network?.routes as RoutesEntity[],
);
setState((prevState) => ({
...prevState,
[e.target.name]: e.target.value,
Expand Down Expand Up @@ -250,7 +254,10 @@ export const MemberOptionsModal: React.FC<ModalContentProps> = ({
</div>
<div className="flex flex-wrap gap-3 text-center">
{ipAssignments.map((assignedIp) => {
const subnetMatch = isIPInSubnet(assignedIp, networkById?.network?.routes);
const subnetMatch = isIPInSubnet(
assignedIp,
networkById?.network?.routes as RoutesEntity[],
);
return (
<div
key={assignedIp}
Expand Down
8 changes: 4 additions & 4 deletions src/components/networkByIdPage/networkRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const NettworkRoutes = ({ central = false, organizationId }: IProp) => {
});

const deleteRoute = (route: RoutesEntity) => {
const _routes = [...network.routes];
const _routes = [...(network.routes as RoutesEntity[])];
const newRouteArr = _routes.filter((r) => r.target !== route.target);

updateManageRoutes({
Expand All @@ -70,7 +70,7 @@ export const NettworkRoutes = ({ central = false, organizationId }: IProp) => {
updateManageRoutes(
{
updateParams: {
routes: [...network.routes, { ...routeInput }],
routes: [...(network.routes as RoutesEntity[]), { ...routeInput }],
},
organizationId,
nwid: query.id as string,
Expand All @@ -93,7 +93,7 @@ export const NettworkRoutes = ({ central = false, organizationId }: IProp) => {
<input type="checkbox" />
<div className="collapse-title">{t("nettworkRoutes.managedRoutesTitle")}</div>
<div className="collapse-content" style={{ width: "100%" }}>
{network?.routes.length === 0 ? (
{(network?.routes as RoutesEntity[]).length === 0 ? (
<div className="alert alert-warning p-2">
<svg
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -118,7 +118,7 @@ export const NettworkRoutes = ({ central = false, organizationId }: IProp) => {
</div>
) : null}
<div className="grid grid-cols-1 pt-3">
{network?.routes.map((route) => {
{(network?.routes as RoutesEntity[]).map((route) => {
return (
<div
key={route.target}
Expand Down
6 changes: 5 additions & 1 deletion src/components/networkByIdPage/table/memberEditCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
useTrpcApiErrorHandler,
useTrpcApiSuccessHandler,
} from "~/hooks/useTrpcApiHandler";
import { RoutesEntity } from "~/types/local/network";

interface IProp {
nwid: string;
Expand Down Expand Up @@ -175,7 +176,10 @@ const MemberEditCell = ({ nwid, central = false, organizationId }: IProp) => {
</div>

{original?.ipAssignments?.map((assignedIp) => {
const subnetMatch = isIPInSubnet(assignedIp, networkById.network?.routes);
const subnetMatch = isIPInSubnet(
assignedIp,
networkById.network?.routes as RoutesEntity[],
);
return (
<div key={assignedIp} className="flex">
<div
Expand Down
4 changes: 2 additions & 2 deletions src/types/invitation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { UserInvitation } from "@prisma/client";
import { Invitation } from "@prisma/client";

export type InvitationLinkType = UserInvitation & { groupName: string | null };
export type InvitationLinkType = Invitation & { groupName: string | null };

0 comments on commit ad5465b

Please sign in to comment.