who am I
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@heroui/react": "^2.6.14",
|
"@heroui/react": "^2.6.14",
|
||||||
|
"@monaco-editor/react": "^4.6.0",
|
||||||
"@tabler/icons-react": "^3.30.0",
|
"@tabler/icons-react": "^3.30.0",
|
||||||
"@tauri-apps/api": "^2.2.0",
|
"@tauri-apps/api": "^2.2.0",
|
||||||
"@tauri-apps/plugin-os": "^2.2.0",
|
"@tauri-apps/plugin-os": "^2.2.0",
|
||||||
@@ -20,12 +21,16 @@
|
|||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
|
"react-markdown": "^9.0.3",
|
||||||
"react-router-dom": "^6.29.0",
|
"react-router-dom": "^6.29.0",
|
||||||
"react-toastify": "^11.0.3"
|
"react-toastify": "^11.0.3",
|
||||||
|
"remark-gfm": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@tailwindcss/typography": "^0.5.16",
|
||||||
"@tauri-apps/cli": "^2.2.7",
|
"@tauri-apps/cli": "^2.2.7",
|
||||||
"@types/lodash": "^4.17.15",
|
"@types/lodash": "^4.17.15",
|
||||||
|
"@types/prismjs": "^1.26.5",
|
||||||
"@types/react": "^18.3.18",
|
"@types/react": "^18.3.18",
|
||||||
"@types/react-dom": "^18.3.5",
|
"@types/react-dom": "^18.3.5",
|
||||||
"@vitejs/plugin-react": "^4.3.4",
|
"@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 DefaultLayout from "./layouts/DefaultLayout";
|
||||||
import HomePage from "./pages/HomePage";
|
import HomePage from "./pages/HomePage";
|
||||||
import ErrorPage from "./pages/ErrorPage";
|
import ErrorPage from "./pages/ErrorPage";
|
||||||
|
import EditProfilePage from "./pages/EditProfilePage";
|
||||||
import { getAccessToken } from "./http";
|
import { getAccessToken } from "./http";
|
||||||
import MemberPage from "./pages/MemberPage";
|
import MemberPage from "./pages/MemberPage";
|
||||||
|
|
||||||
@@ -15,6 +16,8 @@ export default function App() {
|
|||||||
index
|
index
|
||||||
element={getAccessToken() ? <MemberPage /> : <HomePage />}
|
element={getAccessToken() ? <MemberPage /> : <HomePage />}
|
||||||
/>
|
/>
|
||||||
|
<Route path="edit" element={<EditProfilePage />} />
|
||||||
|
<Route path="error" element={<ErrorPage />} />
|
||||||
<Route path="*" element={<ErrorPage />} />
|
<Route path="*" element={<ErrorPage />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ export interface UserProfile {
|
|||||||
nationalRegistrationIdentityCardNumber: string;
|
nationalRegistrationIdentityCardNumber: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
|
gender: number;
|
||||||
|
password: string | undefined;
|
||||||
dateOfBirth: string;
|
dateOfBirth: string;
|
||||||
whoAmI: string;
|
whoAmI: string;
|
||||||
resumeName: 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 { useNavigate } from "react-router-dom";
|
||||||
import { UserProfile } from "../models/user-profile";
|
import { UserProfile } from "../models/user-profile";
|
||||||
import { Button, Card, Divider, Input } from "@heroui/react";
|
import { Button, Card, Divider, Input } from "@heroui/react";
|
||||||
|
import Markdown from "react-markdown";
|
||||||
|
import remarkGfm from "remark-gfm";
|
||||||
|
|
||||||
export default function MemberPage() {
|
export default function MemberPage() {
|
||||||
const accessToken = getAccessToken();
|
const accessToken = getAccessToken();
|
||||||
@@ -56,10 +58,17 @@ export default function MemberPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<p>Who am I</p>
|
<p>Who am I</p>
|
||||||
<Card className="p-4 bg-neutral-500/20 h-full">
|
<Card className="p-4 bg-neutral-500/20 h-full min-w-96">
|
||||||
{userProfile.whoAmI.length > 0
|
{userProfile.whoAmI.length > 0 ? (
|
||||||
? userProfile.whoAmI
|
<Markdown
|
||||||
: "You have not wrote anything about yourself."}
|
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>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -68,7 +77,14 @@ export default function MemberPage() {
|
|||||||
<Button variant="light" color="danger" onPress={logout}>
|
<Button variant="light" color="danger" onPress={logout}>
|
||||||
Log out
|
Log out
|
||||||
</Button>
|
</Button>
|
||||||
<Button color="primary">Edit profile</Button>
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onPress={() => {
|
||||||
|
navigate("edit");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Edit profile
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ export default {
|
|||||||
extend: {},
|
extend: {},
|
||||||
},
|
},
|
||||||
darkMode: "class",
|
darkMode: "class",
|
||||||
plugins: [heroui()],
|
plugins: [heroui(),require('@tailwindcss/typography'),],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ namespace AceJobAgency.Controllers
|
|||||||
NationalRegistrationIdentityCardNumber = decryptedNric,
|
NationalRegistrationIdentityCardNumber = decryptedNric,
|
||||||
user.FirstName,
|
user.FirstName,
|
||||||
user.LastName,
|
user.LastName,
|
||||||
|
user.Gender,
|
||||||
user.DateOfBirth,
|
user.DateOfBirth,
|
||||||
user.WhoAmI,
|
user.WhoAmI,
|
||||||
user.ResumeName,
|
user.ResumeName,
|
||||||
@@ -120,7 +121,6 @@ namespace AceJobAgency.Controllers
|
|||||||
user.LastName = updatedUser.LastName;
|
user.LastName = updatedUser.LastName;
|
||||||
user.DateOfBirth = updatedUser.DateOfBirth;
|
user.DateOfBirth = updatedUser.DateOfBirth;
|
||||||
user.WhoAmI = updatedUser.WhoAmI;
|
user.WhoAmI = updatedUser.WhoAmI;
|
||||||
user.ResumeName = updatedUser.ResumeName;
|
|
||||||
user.UpdatedAt = DateTime.Now;
|
user.UpdatedAt = DateTime.Now;
|
||||||
|
|
||||||
_context.Users.Update(user);
|
_context.Users.Update(user);
|
||||||
|
|||||||
Reference in New Issue
Block a user