Merge remote-tracking branch 'origin/gruppPP' into frontend
This commit is contained in:
commit
3df9ddcd4b
3 changed files with 45 additions and 3 deletions
38
frontend/src/Components/ChangeUsername.tsx
Normal file
38
frontend/src/Components/ChangeUsername.tsx
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { api } from "../API/API";
|
||||||
|
import InputField from "./InputField";
|
||||||
|
import BackButton from "./BackButton";
|
||||||
|
import Button from "./Button";
|
||||||
|
|
||||||
|
|
||||||
|
function ChangeUsername(): JSX.Element {
|
||||||
|
const [newUsername, setNewUsername] = useState("");
|
||||||
|
|
||||||
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {
|
||||||
|
setNewUsername(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async (): Promise<void> => {
|
||||||
|
try {
|
||||||
|
// Call the API function to update the username
|
||||||
|
await api.updateUsername(newUsername);
|
||||||
|
// Optionally, add a success message or redirect the user
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating username:", error);
|
||||||
|
// Optionally, handle the error
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<InputField
|
||||||
|
label="New Username"
|
||||||
|
type="text"
|
||||||
|
value={newUsername}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ChangeUsername;
|
|
@ -1,9 +1,14 @@
|
||||||
import BackButton from "../../Components/BackButton";
|
import BackButton from "../../Components/BackButton";
|
||||||
import BasicWindow from "../../Components/BasicWindow";
|
import BasicWindow from "../../Components/BasicWindow";
|
||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
|
import ChangeUsername from "../../Components/ChangeUsername";
|
||||||
|
|
||||||
function AdminChangeUsername(): JSX.Element {
|
function AdminChangeUsername(): JSX.Element {
|
||||||
const content = <></>;
|
const content = (
|
||||||
|
<>
|
||||||
|
<ChangeUsername />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
const buttons = (
|
const buttons = (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { useState, createContext, useEffect } from "react";
|
import { useState, createContext } from "react";
|
||||||
import { Project } from "../Types/goTypes";
|
import { Project } from "../Types/goTypes";
|
||||||
import { api } from "../API/API";
|
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import BasicWindow from "../Components/BasicWindow";
|
import BasicWindow from "../Components/BasicWindow";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue