who am I
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@heroui/react": "^2.6.14",
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
"@tabler/icons-react": "^3.30.0",
|
||||
"@tauri-apps/api": "^2.2.0",
|
||||
"@tauri-apps/plugin-os": "^2.2.0",
|
||||
@@ -20,12 +21,16 @@
|
||||
"lodash": "^4.17.21",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-markdown": "^9.0.3",
|
||||
"react-router-dom": "^6.29.0",
|
||||
"react-toastify": "^11.0.3"
|
||||
"react-toastify": "^11.0.3",
|
||||
"remark-gfm": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@tauri-apps/cli": "^2.2.7",
|
||||
"@types/lodash": "^4.17.15",
|
||||
"@types/prismjs": "^1.26.5",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
|
||||
976
AceJobAgency.client/pnpm-lock.yaml
generated
976
AceJobAgency.client/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@ import { Route, Routes } from "react-router-dom";
|
||||
import DefaultLayout from "./layouts/DefaultLayout";
|
||||
import HomePage from "./pages/HomePage";
|
||||
import ErrorPage from "./pages/ErrorPage";
|
||||
import EditProfilePage from "./pages/EditProfilePage";
|
||||
import { getAccessToken } from "./http";
|
||||
import MemberPage from "./pages/MemberPage";
|
||||
|
||||
@@ -15,6 +16,8 @@ export default function App() {
|
||||
index
|
||||
element={getAccessToken() ? <MemberPage /> : <HomePage />}
|
||||
/>
|
||||
<Route path="edit" element={<EditProfilePage />} />
|
||||
<Route path="error" element={<ErrorPage />} />
|
||||
<Route path="*" element={<ErrorPage />} />
|
||||
</Route>
|
||||
</Route>
|
||||
|
||||
@@ -4,6 +4,8 @@ export interface UserProfile {
|
||||
nationalRegistrationIdentityCardNumber: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
gender: number;
|
||||
password: string | undefined;
|
||||
dateOfBirth: string;
|
||||
whoAmI: string;
|
||||
resumeName: string;
|
||||
|
||||
81
AceJobAgency.client/src/pages/EditProfilePage.tsx
Normal file
81
AceJobAgency.client/src/pages/EditProfilePage.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
import { Button, Card } from "@heroui/react";
|
||||
import { Editor } from "@monaco-editor/react";
|
||||
import { useEffect, useState } from "react";
|
||||
import http, { getAccessToken } from "../http";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { UserProfile } from "../models/user-profile";
|
||||
import Markdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
export default function EditProfilePage() {
|
||||
const [code, setCode] = useState("");
|
||||
const [userProfile, setUserProfile] = useState<UserProfile | null>(null);
|
||||
const navigate = useNavigate();
|
||||
useEffect(() => {
|
||||
const accessToken = getAccessToken();
|
||||
if (!accessToken) {
|
||||
navigate(-1);
|
||||
}
|
||||
http.get("/User/profile").then((response) => {
|
||||
if (response.status !== 200) {
|
||||
navigate("/error");
|
||||
}
|
||||
setCode((response.data as UserProfile).whoAmI);
|
||||
setUserProfile(response.data);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleSaveChanges = () => {
|
||||
var user = userProfile;
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
user.whoAmI = code;
|
||||
user.password = "0000000000000000";
|
||||
http
|
||||
.put("/User/profile", user)
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
navigate(-1);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
toast.error("Failed to save changes: " + error.message);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="absolute w-full flex flex-col">
|
||||
<div className="w-full h-[80vh] flex flex-row justify-evenly gap-2 p-2">
|
||||
<Card className="h-full w-1/2">
|
||||
<Editor
|
||||
className="h-full"
|
||||
defaultLanguage="markdown"
|
||||
theme="vs-dark"
|
||||
value={code}
|
||||
onChange={(value) => {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
setCode(value);
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
<Card className="h-full w-1/2 p-4">
|
||||
<Markdown
|
||||
className="prose dark:prose-invert prose-neutral overflow-auto w-full h-full"
|
||||
remarkPlugins={[remarkGfm]}
|
||||
>
|
||||
{code}
|
||||
</Markdown>
|
||||
</Card>
|
||||
</div>
|
||||
<div className="flex flex-row w-full justify-end">
|
||||
<Button color="primary" onPress={handleSaveChanges}>
|
||||
Save changes
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,8 @@ import http, { getAccessToken, logout } from "../http";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { UserProfile } from "../models/user-profile";
|
||||
import { Button, Card, Divider, Input } from "@heroui/react";
|
||||
import Markdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
export default function MemberPage() {
|
||||
const accessToken = getAccessToken();
|
||||
@@ -56,10 +58,17 @@ export default function MemberPage() {
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<p>Who am I</p>
|
||||
<Card className="p-4 bg-neutral-500/20 h-full">
|
||||
{userProfile.whoAmI.length > 0
|
||||
? userProfile.whoAmI
|
||||
: "You have not wrote anything about yourself."}
|
||||
<Card className="p-4 bg-neutral-500/20 h-full min-w-96">
|
||||
{userProfile.whoAmI.length > 0 ? (
|
||||
<Markdown
|
||||
className="prose dark:prose-invert prose-neutral overflow-auto w-full h-full"
|
||||
remarkPlugins={[remarkGfm]}
|
||||
>
|
||||
{userProfile.whoAmI}
|
||||
</Markdown>
|
||||
) : (
|
||||
"You have not wrote anything about yourself."
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
@@ -68,7 +77,14 @@ export default function MemberPage() {
|
||||
<Button variant="light" color="danger" onPress={logout}>
|
||||
Log out
|
||||
</Button>
|
||||
<Button color="primary">Edit profile</Button>
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={() => {
|
||||
navigate("edit");
|
||||
}}
|
||||
>
|
||||
Edit profile
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
@@ -11,5 +11,5 @@ export default {
|
||||
extend: {},
|
||||
},
|
||||
darkMode: "class",
|
||||
plugins: [heroui()],
|
||||
plugins: [heroui(),require('@tailwindcss/typography'),],
|
||||
};
|
||||
|
||||
@@ -98,6 +98,7 @@ namespace AceJobAgency.Controllers
|
||||
NationalRegistrationIdentityCardNumber = decryptedNric,
|
||||
user.FirstName,
|
||||
user.LastName,
|
||||
user.Gender,
|
||||
user.DateOfBirth,
|
||||
user.WhoAmI,
|
||||
user.ResumeName,
|
||||
@@ -120,7 +121,6 @@ namespace AceJobAgency.Controllers
|
||||
user.LastName = updatedUser.LastName;
|
||||
user.DateOfBirth = updatedUser.DateOfBirth;
|
||||
user.WhoAmI = updatedUser.WhoAmI;
|
||||
user.ResumeName = updatedUser.ResumeName;
|
||||
user.UpdatedAt = DateTime.Now;
|
||||
|
||||
_context.Users.Update(user);
|
||||
|
||||
Reference in New Issue
Block a user