-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from ArhanAnsari/ArhanAnsari-patch-1
Update page.tsx
- Loading branch information
Showing
6 changed files
with
110 additions
and
192 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//app/api/getUserData/route.ts | ||
import { NextResponse } from "next/server"; | ||
import { adminDb } from "@/firebaseAdmin"; | ||
|
||
export async function GET(req: Request) { | ||
const { searchParams } = new URL(req.url); | ||
const email = searchParams.get("email"); | ||
|
||
if (!email) { | ||
return NextResponse.json({ message: "Invalid email parameter" }, { status: 400 }); | ||
} | ||
|
||
try { | ||
const userDoc = await adminDb.collection("users").doc(email).get(); | ||
if (!userDoc.exists) { | ||
return NextResponse.json({ message: "User not found" }, { status: 404 }); | ||
} | ||
return NextResponse.json(userDoc.data(), { status: 200 }); | ||
} catch (error) { | ||
console.error("Error fetching user data:", error); | ||
return NextResponse.json({ message: "Internal Server Error" }, { status: 500 }); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//app/api/updateUserData/route.ts | ||
import { NextResponse } from "next/server"; | ||
import { adminDb } from "@/firebaseAdmin"; | ||
|
||
export async function POST(req: Request) { | ||
try { | ||
const { email, userData } = await req.json(); | ||
|
||
if (!email || !userData) { | ||
return NextResponse.json({ message: "Invalid request data" }, { status: 400 }); | ||
} | ||
|
||
await adminDb.collection("users").doc(email).set(userData, { merge: true }); | ||
return NextResponse.json({ message: "User data updated successfully" }, { status: 200 }); | ||
} catch (error) { | ||
console.error("Error updating user data:", error); | ||
return NextResponse.json({ message: "Internal Server Error" }, { status: 500 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters