|
|
@@ -0,0 +1,90 @@
|
|
|
+import { NextPage } from "next/types";
|
|
|
+import Layout from "../components/Layout";
|
|
|
+import useForm from "../hooks/useForm";
|
|
|
+import { ApiPaths, ApiMethods } from "../utils/api";
|
|
|
+
|
|
|
+const Settings: NextPage = () => {
|
|
|
+ const user = {
|
|
|
+ id: 4,
|
|
|
+ name: "Monkey",
|
|
|
+ email: "monkey@gmail.com",
|
|
|
+ password: "123456",
|
|
|
+ team: "Admins",
|
|
|
+ };
|
|
|
+
|
|
|
+ const { error, submitHandler } = useForm({
|
|
|
+ path: ApiPaths.Settings,
|
|
|
+ query: JSON.stringify(user.id),
|
|
|
+ method: ApiMethods.PUT,
|
|
|
+ });
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Layout>
|
|
|
+ <form className="form" onSubmit={submitHandler}>
|
|
|
+ <div className="form-group">
|
|
|
+ <label htmlFor="name" className="form-label">
|
|
|
+ Name
|
|
|
+ </label>
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ name="name"
|
|
|
+ id="name"
|
|
|
+ className="form-input"
|
|
|
+ defaultValue={user.name}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className="form-group">
|
|
|
+ <label htmlFor="email" className="form-label">
|
|
|
+ Email
|
|
|
+ </label>
|
|
|
+ <input
|
|
|
+ type="email"
|
|
|
+ name="email"
|
|
|
+ id="email"
|
|
|
+ className="form-input"
|
|
|
+ defaultValue={user.email}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className="form-group">
|
|
|
+ <label htmlFor="password" className="form-label">
|
|
|
+ Password
|
|
|
+ </label>
|
|
|
+ <input
|
|
|
+ type="password"
|
|
|
+ id="password"
|
|
|
+ name="password"
|
|
|
+ className="form-input"
|
|
|
+ defaultValue={user.password}
|
|
|
+ minLength={6}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className="form-group">
|
|
|
+ <label htmlFor="team" className="form-label">
|
|
|
+ Team
|
|
|
+ </label>
|
|
|
+ <select
|
|
|
+ className="form-input"
|
|
|
+ id="team"
|
|
|
+ name="team"
|
|
|
+ defaultValue={user.team}
|
|
|
+ >
|
|
|
+ <option value="Admins">Admins</option>
|
|
|
+ <option value="Users">Users</option>
|
|
|
+ <option value="Viewers">Viewers</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <input type="hidden" id="id" name="id" value={user.id} />
|
|
|
+ <button type="submit" className="form-button">
|
|
|
+ Save
|
|
|
+ </button>
|
|
|
+ {error && (
|
|
|
+ <div role="alert" className="form-alert-msg">
|
|
|
+ {error.message}
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ </form>
|
|
|
+ </Layout>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default Settings;
|