feat: remove appwrite and add nextjs backend
This commit is contained in:
6
frontend/src/utils/loading.util.ts
Normal file
6
frontend/src/utils/loading.util.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createContext, Dispatch, SetStateAction } from "react";
|
||||
|
||||
export const GlobalLoadingContext = createContext<{
|
||||
isLoading: boolean;
|
||||
setIsLoading: Dispatch<SetStateAction<boolean>>;
|
||||
}>({ isLoading: false, setIsLoading: () => {} });
|
||||
11
frontend/src/utils/math/byteStringToHumanSizeString.util.ts
Normal file
11
frontend/src/utils/math/byteStringToHumanSizeString.util.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function byteStringToHumanSizeString(bytes: string) {
|
||||
const bytesNumber = parseInt(bytes);
|
||||
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
||||
if (bytesNumber == 0) return "0 Byte";
|
||||
const i = parseInt(
|
||||
Math.floor(Math.log(bytesNumber) / Math.log(1024)).toString()
|
||||
);
|
||||
return (
|
||||
(bytesNumber / Math.pow(1024, i)).toFixed(1).toString() + " " + sizes[i]
|
||||
);
|
||||
}
|
||||
27
frontend/src/utils/toast.util.tsx
Normal file
27
frontend/src/utils/toast.util.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { showNotification } from "@mantine/notifications";
|
||||
import { Check, X } from "tabler-icons-react";
|
||||
|
||||
const error = (message: string) =>
|
||||
showNotification({
|
||||
icon: <X />,
|
||||
color: "red",
|
||||
radius: "md",
|
||||
title: "Error",
|
||||
|
||||
message: message,
|
||||
});
|
||||
|
||||
const success = (message: string) =>
|
||||
showNotification({
|
||||
icon: <Check />,
|
||||
color: "green",
|
||||
radius: "md",
|
||||
title: "Success",
|
||||
message: message,
|
||||
});
|
||||
|
||||
const toast = {
|
||||
error,
|
||||
success,
|
||||
};
|
||||
export default toast;
|
||||
Reference in New Issue
Block a user