Fix some any types
This commit is contained in:
parent
e79b98d3b0
commit
0b8a9b4310
|
@ -232,8 +232,8 @@ const renderItem = (
|
||||||
<div ref={provided.innerRef} {...provided.draggableProps} className="mb-1">
|
<div ref={provided.innerRef} {...provided.draggableProps} className="mb-1">
|
||||||
<div
|
<div
|
||||||
className={`${currentPath === `/collections/${collection.id}`
|
className={`${currentPath === `/collections/${collection.id}`
|
||||||
? "bg-primary/20 is-active"
|
? "bg-primary/20 is-active"
|
||||||
: "hover:bg-neutral/20"
|
: "hover:bg-neutral/20"
|
||||||
} duration-100 flex gap-1 items-center pr-2 pl-1 rounded-md`}
|
} duration-100 flex gap-1 items-center pr-2 pl-1 rounded-md`}
|
||||||
>
|
>
|
||||||
{Icon(item as ExtendedTreeItem, onExpand, onCollapse)}
|
{Icon(item as ExtendedTreeItem, onExpand, onCollapse)}
|
||||||
|
|
|
@ -4,17 +4,17 @@ import { useEffect, useState } from "react";
|
||||||
import { styles } from "./styles";
|
import { styles } from "./styles";
|
||||||
import { Options } from "./types";
|
import { Options } from "./types";
|
||||||
import CreatableSelect from "react-select/creatable";
|
import CreatableSelect from "react-select/creatable";
|
||||||
import Select from "react-select";
|
import Select, { ActionMeta } from "react-select";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onChange: any;
|
onChange: (newValue: unknown, actionMeta: ActionMeta<unknown>) => void;
|
||||||
showDefaultValue?: boolean;
|
showDefaultValue?: boolean;
|
||||||
defaultValue?:
|
defaultValue?:
|
||||||
| {
|
| {
|
||||||
label: string;
|
label: string;
|
||||||
value?: number;
|
value?: number;
|
||||||
}
|
}
|
||||||
| undefined;
|
| undefined;
|
||||||
creatable?: boolean;
|
creatable?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ export default function CollectionSelection({
|
||||||
components={{
|
components={{
|
||||||
Option: customOption,
|
Option: customOption,
|
||||||
}}
|
}}
|
||||||
// menuPosition="fixed"
|
// menuPosition="fixed"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,7 +123,7 @@ export default function CollectionSelection({
|
||||||
components={{
|
components={{
|
||||||
Option: customOption,
|
Option: customOption,
|
||||||
}}
|
}}
|
||||||
// menuPosition="fixed"
|
// menuPosition="fixed"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,10 @@ import { useEffect, useState } from "react";
|
||||||
import CreatableSelect from "react-select/creatable";
|
import CreatableSelect from "react-select/creatable";
|
||||||
import { styles } from "./styles";
|
import { styles } from "./styles";
|
||||||
import { Options } from "./types";
|
import { Options } from "./types";
|
||||||
|
import { ActionMeta } from "react-select";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onChange: any;
|
onChange: (newValue: unknown, actionMeta: ActionMeta<unknown>) => void;
|
||||||
defaultValue?: {
|
defaultValue?: {
|
||||||
value: number;
|
value: number;
|
||||||
label: string;
|
label: string;
|
||||||
|
|
|
@ -85,7 +85,7 @@ export default function LinkCard({ link, flipDropdown, editMode }: Props) {
|
||||||
const permissions = usePermissions(collection?.id as number);
|
const permissions = usePermissions(collection?.id as number);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let interval: any;
|
let interval: NodeJS.Timeout | null = null;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isVisible &&
|
isVisible &&
|
||||||
|
|
|
@ -84,7 +84,7 @@ export default function LinkMasonry({ link, flipDropdown, editMode }: Props) {
|
||||||
const permissions = usePermissions(collection?.id as number);
|
const permissions = usePermissions(collection?.id as number);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let interval: any;
|
let interval: NodeJS.Timeout | null = null;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isVisible &&
|
isVisible &&
|
||||||
|
|
|
@ -104,7 +104,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
|
||||||
);
|
);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
let interval: any;
|
let interval: NodeJS.Timeout | null = null;
|
||||||
|
|
||||||
if (!isReady()) {
|
if (!isReady()) {
|
||||||
interval = setInterval(async () => {
|
interval = setInterval(async () => {
|
||||||
|
|
|
@ -4,10 +4,8 @@ import {
|
||||||
ArchivedFormat,
|
ArchivedFormat,
|
||||||
LinkIncludingShortenedCollectionAndTags,
|
LinkIncludingShortenedCollectionAndTags,
|
||||||
} from "@/types/global";
|
} from "@/types/global";
|
||||||
import toast from "react-hot-toast";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useSession } from "next-auth/react";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -24,7 +22,6 @@ export default function PreservedFormatRow({
|
||||||
activeLink,
|
activeLink,
|
||||||
downloadable,
|
downloadable,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const session = useSession();
|
|
||||||
const { getLink } = useLinkStore();
|
const { getLink } = useLinkStore();
|
||||||
|
|
||||||
const [link, setLink] =
|
const [link, setLink] =
|
||||||
|
@ -36,19 +33,15 @@ export default function PreservedFormatRow({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const data = await getLink(link.id as number, isPublic);
|
const { data } = await getLink(link.id as number, isPublic);
|
||||||
setLink(
|
setLink(data as LinkIncludingShortenedCollectionAndTags);
|
||||||
(data as any).response as LinkIncludingShortenedCollectionAndTags
|
|
||||||
);
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
let interval: any;
|
let interval: NodeJS.Timeout | null = null;
|
||||||
if (link?.image === "pending" || link?.pdf === "pending") {
|
if (link?.image === "pending" || link?.pdf === "pending") {
|
||||||
interval = setInterval(async () => {
|
interval = setInterval(async () => {
|
||||||
const data = await getLink(link.id as number, isPublic);
|
const { data } = await getLink(link.id as number, isPublic);
|
||||||
setLink(
|
setLink(data as LinkIncludingShortenedCollectionAndTags);
|
||||||
(data as any).response as LinkIncludingShortenedCollectionAndTags
|
|
||||||
);
|
|
||||||
}, 5000);
|
}, 5000);
|
||||||
} else {
|
} else {
|
||||||
if (interval) {
|
if (interval) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default function ReadableView({ link }: Props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (link) getLink(link?.id as number);
|
if (link) getLink(link?.id as number);
|
||||||
|
|
||||||
let interval: any;
|
let interval: NodeJS.Timeout | null = null;
|
||||||
if (
|
if (
|
||||||
link &&
|
link &&
|
||||||
(link?.image === "pending" ||
|
(link?.image === "pending" ||
|
||||||
|
|
|
@ -2,19 +2,17 @@ import axios, { AxiosError } from "axios"
|
||||||
|
|
||||||
axios.defaults.baseURL = "http://localhost:3000"
|
axios.defaults.baseURL = "http://localhost:3000"
|
||||||
|
|
||||||
export async function seedUser (username?: string, password?: string, name?: string) {
|
export async function seedUser(username?: string, password?: string, name?: string) {
|
||||||
try {
|
try {
|
||||||
return await axios.post("/api/v1/users", {
|
return await axios.post("/api/v1/users", {
|
||||||
username: username || "test",
|
username: username || "test",
|
||||||
password: password || "password",
|
password: password || "password",
|
||||||
name: name || "Test User",
|
name: name || "Test User",
|
||||||
})
|
})
|
||||||
} catch (e: any) {
|
} catch (error) {
|
||||||
if (e instanceof AxiosError) {
|
const axiosError = error as AxiosError;
|
||||||
if (e.response?.status === 400) {
|
if (axiosError && axiosError.response?.status === 400) return
|
||||||
return
|
|
||||||
}
|
throw error
|
||||||
}
|
|
||||||
throw e
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
import { prisma } from "@/lib/api/db";
|
import { prisma } from "@/lib/api/db";
|
||||||
import { LinkRequestQuery, Sort } from "@/types/global";
|
import { LinkRequestQuery, Order, Sort } from "@/types/global";
|
||||||
|
|
||||||
export default async function getDashboardData(
|
export default async function getDashboardData(
|
||||||
userId: number,
|
userId: number,
|
||||||
query: LinkRequestQuery
|
query: LinkRequestQuery
|
||||||
) {
|
) {
|
||||||
let order: any;
|
let order: Order = { id: "desc" };
|
||||||
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
|
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
|
||||||
else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };
|
else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };
|
||||||
else if (query.sort === Sort.NameAZ) order = { name: "asc" };
|
else if (query.sort === Sort.NameAZ) order = { name: "asc" };
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import { prisma } from "@/lib/api/db";
|
import { prisma } from "@/lib/api/db";
|
||||||
import { LinkRequestQuery, Sort } from "@/types/global";
|
import { LinkRequestQuery, Order, Sort } from "@/types/global";
|
||||||
|
|
||||||
type Response<D> =
|
type Response<D> =
|
||||||
| {
|
| {
|
||||||
data: D;
|
data: D;
|
||||||
message: string;
|
message: string;
|
||||||
status: number;
|
status: number;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
data: D;
|
data: D;
|
||||||
message: string;
|
message: string;
|
||||||
status: number;
|
status: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function getDashboardData(
|
export default async function getDashboardData(
|
||||||
userId: number,
|
userId: number,
|
||||||
query: LinkRequestQuery
|
query: LinkRequestQuery
|
||||||
): Promise<Response<any>> {
|
): Promise<Response<any>> {
|
||||||
let order: any;
|
let order: Order = { id: "desc" };
|
||||||
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
|
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
|
||||||
else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };
|
else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };
|
||||||
else if (query.sort === Sort.NameAZ) order = { name: "asc" };
|
else if (query.sort === Sort.NameAZ) order = { name: "asc" };
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { prisma } from "@/lib/api/db";
|
import { prisma } from "@/lib/api/db";
|
||||||
import { LinkRequestQuery, Sort } from "@/types/global";
|
import { LinkRequestQuery, Order, Sort } from "@/types/global";
|
||||||
|
|
||||||
export default async function getLink(userId: number, query: LinkRequestQuery) {
|
export default async function getLink(userId: number, query: LinkRequestQuery) {
|
||||||
const POSTGRES_IS_ENABLED =
|
const POSTGRES_IS_ENABLED =
|
||||||
process.env.DATABASE_URL?.startsWith("postgresql");
|
process.env.DATABASE_URL?.startsWith("postgresql");
|
||||||
|
|
||||||
let order: any;
|
let order: Order = { id: "desc" };
|
||||||
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
|
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
|
||||||
else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };
|
else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };
|
||||||
else if (query.sort === Sort.NameAZ) order = { name: "asc" };
|
else if (query.sort === Sort.NameAZ) order = { name: "asc" };
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { prisma } from "@/lib/api/db";
|
import { prisma } from "@/lib/api/db";
|
||||||
import { LinkRequestQuery, Sort } from "@/types/global";
|
import { LinkRequestQuery, Order, Sort } from "@/types/global";
|
||||||
|
|
||||||
export default async function getLink(
|
export default async function getLink(
|
||||||
query: Omit<LinkRequestQuery, "tagId" | "pinnedOnly">
|
query: Omit<LinkRequestQuery, "tagId" | "pinnedOnly">
|
||||||
|
@ -7,7 +7,7 @@ export default async function getLink(
|
||||||
const POSTGRES_IS_ENABLED =
|
const POSTGRES_IS_ENABLED =
|
||||||
process.env.DATABASE_URL?.startsWith("postgresql");
|
process.env.DATABASE_URL?.startsWith("postgresql");
|
||||||
|
|
||||||
let order: any;
|
let order: Order = { id: "desc" };
|
||||||
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
|
if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };
|
||||||
else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };
|
else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };
|
||||||
else if (query.sort === Sort.NameAZ) order = { name: "asc" };
|
else if (query.sort === Sort.NameAZ) order = { name: "asc" };
|
||||||
|
|
|
@ -7,10 +7,10 @@ export function isPWA() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIphone() {
|
export function isIphone() {
|
||||||
return /iPhone/.test(navigator.userAgent) && !(window as any).MSStream;
|
return /iPhone/.test(navigator.userAgent) && !(window as unknown as { MSStream?: any }).MSStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function dropdownTriggerer(e: any) {
|
export function dropdownTriggerer(e: React.FocusEvent<HTMLElement> | React.MouseEvent<HTMLElement>) {
|
||||||
let targetEl = e.currentTarget;
|
let targetEl = e.currentTarget;
|
||||||
if (targetEl && targetEl.matches(":focus")) {
|
if (targetEl && targetEl.matches(":focus")) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
|
@ -39,7 +39,7 @@ export function monolithAvailable(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function previewAvailable(link: any) {
|
export function previewAvailable(link: LinkIncludingShortenedCollectionAndTags) {
|
||||||
return (
|
return (
|
||||||
link &&
|
link &&
|
||||||
link.preview &&
|
link.preview &&
|
||||||
|
|
|
@ -81,6 +81,8 @@ export enum Sort {
|
||||||
DescriptionZA,
|
DescriptionZA,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Order = { [key: string]: 'asc' | 'desc' };
|
||||||
|
|
||||||
export type LinkRequestQuery = {
|
export type LinkRequestQuery = {
|
||||||
sort: Sort;
|
sort: Sort;
|
||||||
cursor?: number;
|
cursor?: number;
|
||||||
|
|
Ŝarĝante…
Reference in New Issue