2024-03-19 03:39:05 +01:00
|
|
|
import React, { useState } from "react";
|
|
|
|
import InputField from "./InputField";
|
|
|
|
|
|
|
|
function ChangeUsername(): JSX.Element {
|
|
|
|
const [newUsername, setNewUsername] = useState("");
|
|
|
|
|
|
|
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {
|
|
|
|
setNewUsername(e.target.value);
|
|
|
|
};
|
|
|
|
|
2024-03-20 14:20:09 +01:00
|
|
|
// 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
|
|
|
|
// }
|
|
|
|
// };
|
2024-03-19 03:39:05 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<InputField
|
|
|
|
label="New Username"
|
|
|
|
type="text"
|
|
|
|
value={newUsername}
|
|
|
|
onChange={handleChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ChangeUsername;
|