mirror of
https://github.com/Stef-00012/Zipline-Android-App.git
synced 2025-05-11 02:15:49 +02:00
finish sidebar, some fixes
This commit is contained in:
parent
3c0909c1ab
commit
fdb827a1f1
18 changed files with 507 additions and 135 deletions
|
@ -20,7 +20,14 @@ export async function getUserExports(): Promise<APIExports | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +49,14 @@ export async function createUserExport(): Promise<{ running: boolean } | string>
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +80,13 @@ export async function deleteUserExport(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,14 @@ export async function getFiles(page: string, options: GetFilesOptions = {}): Pro
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +66,14 @@ export async function getFile(id: string): Promise<APIFile | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +95,14 @@ export async function deleteFile(id: string): Promise<APIFile | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,6 +123,8 @@ export async function updateFileTags(
|
|||
try {
|
||||
const file = await getFile(id);
|
||||
|
||||
if (typeof file === "string") return file;
|
||||
|
||||
let newTags = (file?.tags || []).map((tag) => tag.id);
|
||||
|
||||
if (options.remove)
|
||||
|
@ -124,7 +147,14 @@ export async function updateFileTags(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +186,14 @@ export async function editFile(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,6 +257,13 @@ export async function uploadFiles(
|
|||
} catch(e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import axios, { type AxiosError } from "axios";
|
|||
// GET /api/user/folders
|
||||
export async function getFolders<T extends boolean | undefined = undefined>(
|
||||
noIncl?: T,
|
||||
): Promise<T extends true ? APIFoldersNoIncl | null : APIFolders | string> {
|
||||
): Promise<T extends true ? APIFoldersNoIncl | string : APIFolders | string> {
|
||||
const token = db.get("token");
|
||||
const url = db.get("url");
|
||||
|
||||
|
@ -26,7 +26,14 @@ export async function getFolders<T extends boolean | undefined = undefined>(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +55,14 @@ export async function getFolder(id: string): Promise<APIFolder | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +94,14 @@ export async function createFolder(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +132,14 @@ export async function editFolder(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +164,14 @@ export async function deleteFolder(id: string): Promise<APIFolder | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +200,14 @@ export async function removeFileFromFolder(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,6 +238,13 @@ export async function addFileToFolder(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,14 @@ export async function getInvites(): Promise<APIInvites | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +55,14 @@ export async function createInvite(expiresAt?: string, maxUses?: number): Promis
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +86,13 @@ export async function deleteInvite(code: string): Promise<APIInvite | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
|
@ -20,7 +20,14 @@ export async function getSettings(): Promise<APISettings | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +51,13 @@ export async function updateSettings(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,14 @@ export async function getStats(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +57,13 @@ export async function getUserStats(): Promise<APIUserStats | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,14 @@ export async function getTags(): Promise<APITags | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +59,14 @@ export async function createTag(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +88,14 @@ export async function deleteTag(id: string): Promise<APITag | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +127,13 @@ export async function editTag(id: string, options: EditTagOptions = {}) {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,14 @@ export async function getURLs(): Promise<APIURLs | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +49,14 @@ export async function getURL(id: string): Promise<APIURL | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +104,14 @@ export async function createURL({
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +133,14 @@ export async function deleteURL(id: string): Promise<APIURL | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,6 +171,13 @@ export async function editURL(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,14 @@ export async function getCurrentUser(): Promise<APISelfUser | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +49,14 @@ export async function getRecentFiles(): Promise<APIRecentFiles | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import type {
|
|||
// GET /api/users(?noincl=true)
|
||||
export async function getUsers<T extends boolean | undefined = undefined>(
|
||||
noIncl?: T,
|
||||
): Promise<T extends true ? APIUsersNoIncl | null : APIUsers | string> {
|
||||
): Promise<T extends true ? APIUsersNoIncl | string : APIUsers | string> {
|
||||
const token = db.get("token");
|
||||
const url = db.get("url");
|
||||
|
||||
|
@ -31,7 +31,14 @@ export async function getUsers<T extends boolean | undefined = undefined>(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +59,14 @@ export async function getUser(id: string): Promise<APIUser | string> {
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +102,14 @@ export async function createUser(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +137,14 @@ export async function deleteUser(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,6 +195,13 @@ export async function editUser(
|
|||
} catch (e) {
|
||||
const error = e as AxiosError;
|
||||
|
||||
return error.response.error;
|
||||
const data = error.response?.data as {
|
||||
error: string;
|
||||
statusCode: number;
|
||||
} | undefined;
|
||||
|
||||
if (data) return data.error
|
||||
|
||||
return "Something went wrong..."
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue