-
Notifications
You must be signed in to change notification settings - Fork 0
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 #33 from rapidosaas/develop
added username and profile
- Loading branch information
Showing
10 changed files
with
143 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { connectDB } from "@/lib/db"; | ||
import Profile from "@/lib/models/Profile"; | ||
import { NextResponse, NextRequest } from "next/server"; | ||
|
||
export async function POST(request: NextRequest) { | ||
try { | ||
await connectDB(); | ||
const body = await request.json(); | ||
console.log(body); | ||
const profile = await Profile.findOne({ ...body }); | ||
console.log(profile); | ||
return NextResponse.json({ profile }, { status: 200 }); | ||
|
||
} catch (error) { | ||
console.log(error); | ||
return NextResponse.json({ message: "Error", 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ProfilePage from '@/components/ProfilePage'; | ||
|
||
export default async function Page({ | ||
params, | ||
}: Readonly<{ | ||
params: Promise<{ username: string }> | ||
}>) { | ||
|
||
const username = (await params).username; | ||
|
||
return ( | ||
<main className="m-auto my-10 flex max-w-5xl flex-col items-center gap-5 px-3 md:flex-row md:items-start"> | ||
<ProfilePage username={username} /> | ||
</main> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use client"; | ||
|
||
import { formatMoney } from "@/lib/utils"; | ||
import { Banknote } from "lucide-react"; | ||
import { useEffect, useState } from "react"; | ||
import Badge from "./Badge"; | ||
import Profile from "@/lib/types/profile"; | ||
|
||
interface JobPageProps { | ||
readonly username: string; | ||
} | ||
|
||
export default function JobPage({ | ||
username, | ||
}: JobPageProps) { | ||
|
||
const [profile, setProfile] = useState<Profile | undefined>(); | ||
|
||
useEffect(() => { | ||
fetch("/api/username", { | ||
method: "POST", | ||
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify({ username }), | ||
}) | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
console.log(data); | ||
setProfile(data.profile); | ||
}) | ||
.catch((err) => console.log(err)); | ||
}, [username]); | ||
|
||
return ( | ||
<section className="w-full grow space-y-5"> | ||
<div className="flex items-center gap-3"> | ||
<div> | ||
<div> | ||
<h1 className="text-xl font-bold">{profile?.username}</h1> | ||
<p className="font-semibold"> | ||
<span>{profile?.name}</span> | ||
</p> | ||
</div> | ||
<div className="text-muted-foreground"> | ||
<p className="flex items-center gap-1.5"> | ||
<Banknote size={16} className="shrink-0" /> | ||
{formatMoney(profile?.salary ?? 0)} | ||
</p> | ||
<p className="flex items-center gap-1"> | ||
{profile?.skills.map((skill: string) => ( | ||
<Badge key={skill}>{skill}</Badge> | ||
))} | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div>{profile?.bio}</div> | ||
</section> | ||
); | ||
} |
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
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