Skip to content

Commit

Permalink
QOL improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
shahank42 committed Jan 2, 2024
1 parent 88621c7 commit 7c4754c
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 23 deletions.
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const nextConfig = {
reactStrictMode: true,
images: {
domains: ['media.licdn.com'],
domains: ['media.licdn.com', "res.cloudinary.com", "ui-avatars.com"],
},

}
Expand Down
52 changes: 46 additions & 6 deletions src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ interface FormType {
}

function Login() {
const [errorMessage, setErrorMessage] = useState<string>("");

async function onSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
const formData = Object.fromEntries(new FormData(event.currentTarget));
Expand All @@ -24,7 +26,7 @@ function Login() {
{
method: "POST",
body: JSON.stringify(formObj),
}
},
);

// console.log(await response.json());
Expand All @@ -36,6 +38,8 @@ function Login() {
localStorage.setItem("signed-in-user", JSON.stringify(user));
window.location.reload();
}
} else {
setErrorMessage(await response.text());
}
}

Expand All @@ -46,8 +50,8 @@ function Login() {
if (window.localStorage.getItem("signed-in-user") !== "")
setSignedInUser(
JSON.parse(
window.localStorage.getItem("signed-in-user") as string
) as UserType
window.localStorage.getItem("signed-in-user") as string,
) as UserType,
);
}, []);

Expand All @@ -63,12 +67,48 @@ function Login() {
Log In to the KGEC Alumni Portal
</h2>

{errorMessage !== "" ? (
<div
className="max-w-xs bg-red-500 text-sm text-white rounded-xl shadow-lg"
role="alert"
>
<div className="flex p-4">
{errorMessage}
<div className="ms-auto">
<button
type="button"
className="inline-flex flex-shrink-0 justify-center items-center h-5 w-5 rounded-lg text-white hover:text-white opacity-50 hover:opacity-100 focus:outline-none focus:opacity-100"
>
<span className="sr-only">Close</span>
<svg
className="flex-shrink-0 w-4 h-4"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M18 6 6 18" />
<path d="m6 6 12 12" />
</svg>
</button>
</div>
</div>
</div>
) : (
<></>
)}

{signedInUser && signedInUser?.verified ? (
<div className="mt-10 text-center text-xl leading-9 tracking-tight text-zinc-100">
<div className="mt-10 text-center text-xl leading-9 tracking-tight">
You&apos;re logged in! Check out our Alumnibase.
</div>
) : signedInUser && !signedInUser?.verified ? (
<div className="mt-10 text-center text-xl leading-9 tracking-tight text-zinc-100">
<div className="mt-10 text-center text-xl leading-9 tracking-tight">
Seems like you haven&apos;t been verified yet. Kindly have
patience.
</div>
Expand Down Expand Up @@ -134,7 +174,7 @@ function Login() {
</div>
)}
</div>
<div className="w-full bg-[url('/old_campus.jpg')] bg-no-repeat bg-cover"></div>
<div className="hidden md:block w-full bg-[url('/old_campus.jpg')] bg-no-repeat bg-cover"></div>
</section>
</Layout>
);
Expand Down
30 changes: 19 additions & 11 deletions src/pages/register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Register() {
{
method: "POST",
body: formData,
}
},
);

const data = await response.json();
Expand Down Expand Up @@ -92,7 +92,7 @@ function Register() {
{
method: "POST",
body: JSON.stringify(formObj),
}
},
);

console.log(response);
Expand All @@ -115,7 +115,7 @@ function Register() {
if (typeof window !== "undefined")
if (window.localStorage.getItem("signed-in-user") !== "")
setSignedInUser(
window.localStorage.getItem("signed-in-user") as string
window.localStorage.getItem("signed-in-user") as string,
);
}, []);

Expand All @@ -126,18 +126,21 @@ function Register() {
<h2 className="text-[2.5rem] text-indigo-700 lg:text-[3rem] font-black mb-0 leading-none">
Register into the KGEC Alumni Portal
</h2>

<span className="leading-9 tracking-tight">Fill in the fields below and send your alumni or student application to be verified. The more accurate information you provide, the better the chances of being verified!</span>


{signedInUser ? (
<div className="mt-10 text-center text-xl leading-9 tracking-tight text-zinc-100">
<div className="mt-10 text-center text-xl leading-9 tracking-tight">
You are already signed in. Log out to register again
</div>
) : registered ? (
<div className="mt-10 text-center text-xl leading-9 tracking-tight text-zinc-100">
<div className="mt-10 text-center text-xl leading-9 tracking-tight">
Your application has been sent for verification! Once verified,
you may{" "}
<Link
href="/login"
className="pl-1 font-semibold leading-6 text-yellow-300 hover:text-yellow-200"
className="pl-1 font-semibold leading-6 text-sky-400 hover:text-sky-500"
>
Log In
</Link>{" "}
Expand Down Expand Up @@ -241,6 +244,7 @@ function Register() {
<div className="mt-1">
<input
name="linkedin"
type="url"
required
className="block w-full rounded-md border-0 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-500 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm sm:leading-6 outline-none focus:outline-none px-3 py-2"
placeholder="Enter your LinkedIn profile URL"
Expand Down Expand Up @@ -281,7 +285,10 @@ function Register() {
onChange={(e) => setDegree(e.target.value)}
className="block w-full rounded-md border-0 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-500 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm sm:leading-6 outline-none focus:outline-none px-3 py-2"
>


{DEGREES.map((degree) => (

<option key={degree} value={degree}>
{degree}
</option>
Expand All @@ -305,10 +312,10 @@ function Register() {
{(degree === "B.Tech"
? BTECH_DEPARTMENTS
: degree === "M.Tech"
? MTECH_DEPARTMENTS
: degree === "MCA"
? MCA_DEPARTMENTS
: []
? MTECH_DEPARTMENTS
: degree === "MCA"
? MCA_DEPARTMENTS
: []
).map((dept) => (
<option key={dept} value={dept}>
{dept}
Expand Down Expand Up @@ -372,6 +379,7 @@ function Register() {
</label>
<input
name="proofOfGrad"
type="url"
placeholder="Enter Google Drive link ONLY..."
required
value={proofOfGrad}
Expand Down Expand Up @@ -473,7 +481,7 @@ function Register() {
</div>
)}
</div>
<div className="w-full bg-[url('/old_campus.jpg')] bg-no-repeat bg-cover"></div>
<div className="hidden md:block w-full bg-[url('/old_campus.jpg')] bg-no-repeat bg-cover"></div>
</section>
</Layout>
);
Expand Down
15 changes: 10 additions & 5 deletions src/pages/verify/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { Alumni, UserType } from "@/types/types";

export async function getServerSideProps() {
const result_alumnis = await fetch(
"https://kgec-alumni-backend.onrender.com/users/alumni"
"https://kgec-alumni-backend.onrender.com/users/alumni",
);
const alumnis = await result_alumnis.json();
const result_students = await fetch(
"https://kgec-alumni-backend.onrender.com/users/students"
"https://kgec-alumni-backend.onrender.com/users/students",
);
const students = await result_students.json();
return {
Expand All @@ -31,6 +31,11 @@ function Verify({ alumnis, students }: Props) {
const [selectedTab, setSelectedTab] = useState<string>("student");
const [token, setToken] = useState<string>("");

useEffect(() => {
if (typeof window !== "undefined")
setToken(window.localStorage.getItem("alumni-admin-token") as string);
}, []);

return (
<Layout>
<h2 className="text-[2.5rem] px-10 text-indigo-500 lg:text-[3rem] font-black mb-0 leading-none">
Expand Down Expand Up @@ -150,7 +155,7 @@ function Verify({ alumnis, students }: Props) {
id: user.id,
token: token,
}),
}
},
);

window.location.reload();
Expand All @@ -176,9 +181,9 @@ function Verify({ alumnis, students }: Props) {
method: "POST",
body: JSON.stringify({
id: user.id,
token: token
token: token,
}),
}
},
);

window.location.reload();
Expand Down

0 comments on commit 7c4754c

Please sign in to comment.