added table filtering & searching, added large view for folders, urls, users and invites, fixed ScrollView cutting on the end (caused by padding), added dropdown component, updated table to handle sort & search

This commit is contained in:
Stef-00012 2025-02-17 00:56:57 +01:00
parent b2b22c6bb8
commit 06b5c3bfe9
No known key found for this signature in database
GPG key ID: 28BE9A9E4EF0E6BF
30 changed files with 2946 additions and 1112 deletions

View file

@ -13,6 +13,11 @@ import type {
export interface GetFilesOptions {
id?: string;
favorite?: boolean;
sortBy?: "name" | "type" | "size" | "createdAt" | "favorite";
order?: "asc" | "desc";
perPage?: number;
searchField?: "name" | "tags" | "type" | "id";
searchQuery?: string;
}
// GET /api/user/files
export async function getFiles(
@ -26,10 +31,16 @@ export async function getFiles(
const params = new URLSearchParams({
page: page,
sortBy: options.sortBy || "createdAt",
order: options.order || "desc",
});
if (options.id) params.append("id", options.id);
if (options.favorite) params.append("favorite", "true");
if (options.perPage) params.append("perpage", String(options.perPage));
if (options.searchField) params.append("searchField", options.searchField);
if (options.searchQuery)
params.append("searchQuery", encodeURIComponent(options.searchQuery));
try {
const res = await axios.get(`${url}/api/user/files?${params}`, {

View file

@ -2,15 +2,28 @@ import type { APIURLs, APIURL } from "@/types/zipline";
import axios, { type AxiosError } from "axios";
import * as db from "@/functions/database";
interface GetURLsOptions {
searchField?: "code" | "vanity" | "destination";
searchQuery?: string;
}
// GET /user/urls
export async function getURLs(): Promise<APIURLs | string> {
export async function getURLs(
options?: GetURLsOptions,
): Promise<APIURLs | string> {
const token = db.get("token");
const url = db.get("url");
if (!url || !token) return "Invalid token or URL";
const searchParams = new URLSearchParams();
if (options?.searchField && options?.searchQuery) {
searchParams.append("searchField", options.searchField);
searchParams.append("searchQuery", options.searchQuery);
}
try {
const res = await axios.get(`${url}/api/user/urls`, {
const res = await axios.get(`${url}/api/user/urls?${searchParams}`, {
headers: {
Authorization: token,
},