Shop Update
This commit is contained in:
@@ -12,16 +12,43 @@ export async function POST(req: Request) {
|
||||
if (!userData) return NextResponse.json({ message: "User not found" }, { status: 404 });
|
||||
|
||||
const formData = await req.formData();
|
||||
|
||||
if (!formData) return NextResponse.json({ message: "No form data found" }, { status: 400 });
|
||||
|
||||
let bio = formData.get("bio");
|
||||
if(bio) {
|
||||
userData = await db.users.update(userData.id, { bio: bio.toString() });
|
||||
userData = await db.users.update(userData.id, { bio: bio });
|
||||
if (!userData) return NextResponse.json({ message: "Failed to update bio" }, { status: 500 });
|
||||
return NextResponse.json({ message: "Bio updated successfully" }, { status: 200 });
|
||||
}
|
||||
|
||||
let avatar = formData.get("avatar");
|
||||
if(avatar) {
|
||||
userData = await db.users.update(userData.id, { avatar: parseInt(avatar.toString()) });
|
||||
if (!userData) return NextResponse.json({ message: "Failed to update avatar" }, { status: 500 });
|
||||
}
|
||||
|
||||
let username = formData.get("username");
|
||||
if(username) {
|
||||
userData = await db.users.update(userData.id, { username: username });
|
||||
if (!userData) return NextResponse.json({ message: "Failed to update username" }, { status: 500 });
|
||||
}
|
||||
|
||||
let points = formData.get("points");
|
||||
if(points) {
|
||||
userData = await db.users.update(userData.id, { points: parseInt(points.toString()) });
|
||||
if (!userData) return NextResponse.json({ message: "Failed to update points" }, { status: 500 });
|
||||
}
|
||||
|
||||
let inventory = formData.get("inventory");
|
||||
if(inventory) {
|
||||
let inventoryData = userData.inventory;
|
||||
if (!inventoryData) inventoryData = [];
|
||||
inventoryData.push(inventory.toString());
|
||||
|
||||
userData = await db.users.update(userData.id, { inventory: inventoryData });
|
||||
if (!userData) return NextResponse.json({ message: "Failed to update inventory" }, { status: 500 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "No Update" }, { status: 400 });
|
||||
return NextResponse.json({ message: "User updated successfully", user: userData }, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error("Error updating user bio:", error);
|
||||
return NextResponse.json(
|
||||
|
||||
Reference in New Issue
Block a user