diff --git a/components/Input/index.tsx b/components/Input/index.tsx index ed3eade3..63eb6798 100644 --- a/components/Input/index.tsx +++ b/components/Input/index.tsx @@ -24,14 +24,6 @@ export function InputBase({ let textColor = `text-${fgColor}`; let backColor = `bg-${bgColor}`; - if (enabled === false) { - textColor = "text-gray-500"; - backColor = "bg-gray-100"; - } else if (enabled === true) { - textColor = `bg-${fgColor}`; - backColor = `bg-${bgColor}`; - } - return (
@@ -135,7 +145,7 @@ function Profile() { id="name" name="name" value={user.name || ""} - bgColor="white" + bgColor="primary" fgColor="white" enabled={false} /> @@ -144,11 +154,24 @@ function Profile() { id="username" name="username" value={username} - bgColor="white" + bgColor="primary" fgColor="white" enabled={editing} onChange={(e) => setUsername(e.currentTarget.value)} /> + ({ + key: course.id, + name: course.name, + }))} + onChange={(e) => updateCourse(e.currentTarget.value)} + /> + response.data.concat({ id: "", name: "None" }) + ); + + return { props: { courses: courses } }; +} + +export default Profile; diff --git a/pages/register/[uuid].js b/pages/register/[uuid].js index 265df8b3..c4021b34 100644 --- a/pages/register/[uuid].js +++ b/pages/register/[uuid].js @@ -1,20 +1,36 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import { useRouter } from "next/router"; import { motion as Motion } from "framer-motion"; import { withoutAuth, useAuth } from "@context/Auth"; +import { getCourses } from "@lib/api"; + import Button from "@components/Button"; import Card from "@components/Card"; import Return from "@components/Return"; import Form from "@components/Form"; import Input from "@components/Input"; +import Select from "@components/Select"; import PasswordInput from "@components/PasswordInput"; import Title from "@layout/moonstone/authentication/Title"; import Text from "@layout/moonstone/authentication/Text"; -function Register() { +export async function getServerSideProps(context) { + context.res.setHeader( + "Cache-Control", + "public, s-maxage=3600, stale-while-revalidate=3600" + ); + + const courses = await getCourses().then((response) => + response.data.concat({ id: "", name: "None" }) + ); + + return { props: { courses: courses } }; +} + +function Register({ courses }) { const { sign_up, errors, isLoading } = useAuth(); const router = useRouter(); const { uuid } = router.query; @@ -22,6 +38,7 @@ function Register() { const [name, updateName] = useState(""); const [email, updateEmail] = useState(""); const [nickname, updateNickname] = useState(""); + const [course, updateCourse] = useState("0"); const [password, updatePassword] = useState(""); const [password_confirmation, updatePasswordConfirmation] = useState(""); @@ -34,6 +51,7 @@ function Register() { password_confirmation, nickname, uuid, + course, }); }; @@ -69,6 +87,18 @@ function Register() { bgColor="primary" onChange={(e) => updateNickname(e.currentTarget.value)} /> +