refactored/cleaned up API + added support for renaming tags

This commit is contained in:
daniel31x13
2023-10-23 00:28:39 -04:00
parent 24cced9dba
commit ed24685aaf
48 changed files with 603 additions and 305 deletions
+1 -3
View File
@@ -22,9 +22,7 @@ const addMemberToCollection = async (
memberUsername.trim().toLowerCase() !== ownerUsername.toLowerCase()
) {
// Lookup, get data/err, list ...
const user = await getPublicUserData({
username: memberUsername.trim().toLowerCase(),
});
const user = await getPublicUserData(memberUsername.trim().toLowerCase());
if (user.username) {
setMember({
+1 -1
View File
@@ -17,7 +17,7 @@ const getPublicCollectionData = async (
const encodedData = encodeURIComponent(JSON.stringify(requestBody));
const res = await fetch(
"/api/public/collections?body=" + encodeURIComponent(encodedData)
"/api/v1/public/collections?body=" + encodeURIComponent(encodedData)
);
const data = await res.json();
+2 -12
View File
@@ -1,17 +1,7 @@
import { toast } from "react-hot-toast";
export default async function getPublicUserData({
username,
id,
}: {
username?: string;
id?: number;
}) {
const response = await fetch(
`/api/users?id=${id}&${
username ? `username=${username?.toLowerCase()}` : undefined
}`
);
export default async function getPublicUserData(id: number | string) {
const response = await fetch(`/api/v1/users/${id}`);
const data = await response.json();