Skip to content

Commit

Permalink
Merge pull request #143 from whyphi/dev/v1.0
Browse files Browse the repository at this point in the history
merge: `v2.0`
  • Loading branch information
wderocco8 authored Aug 16, 2024
2 parents fb7bcbe + 55361af commit e2f01be
Show file tree
Hide file tree
Showing 54 changed files with 2,661 additions and 955 deletions.
21 changes: 21 additions & 0 deletions app/admin/account-settings/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import '../../globals.css'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: 'Whyphi - Account Settings',
}

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (

<div className="flex flex-col mx-auto justify-center max-w-screen-lg">
{children}
</div>


)
}
184 changes: 184 additions & 0 deletions app/admin/account-settings/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
"use client"

import React, { useState, useEffect } from "react";
import { useRouter } from 'next/navigation';
import { useAuth, getUserId } from "@/app/contexts/AuthContext";
import { Button, Card, Select, Label, TextInput } from "flowbite-react";
import { Member } from "@/types/admin/account-settings/member";
import { AdminTextStyles } from "@/styles/TextStyles";

export default function AccountSettings() {
const { token } = useAuth();
const _id = getUserId();
const router = useRouter();

const [user, setUser] = useState<Member>({} as Member);

useEffect(() => {
const fetchUser = async () => {
try {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/member/${_id}`, {
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
}
});
const data = await response.json();
setUser(data);
} catch (error) {
console.error("Error fetching user:", error);
}
}
fetchUser();
}, [_id, token]); // Include _id and token in the dependency array

const handleInputChange = (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>) => {
setUser((prevUser) => ({
...prevUser,
[event.target.id]: event.target.value
}));
}

return (
<div>
<Card className="max-w">
<h1 className={AdminTextStyles.title}>Account Settings</h1>
<form className="flex flex-col gap-4" onSubmit={(e) => {
e.preventDefault();
console.log(user);
fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/member/${_id}`, {
method: "PUT",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify(user)
})
.then(() => router.push("/admin"))
.catch(console.error);
}}>

{/* Personal Information */}
<div className="border-b border-gray-200 pb-6">
<h4 className={AdminTextStyles.subtitle}>Personal Information</h4>

{/* Name and Email */}
<div className="flex flex-row mb-4">
<div className="w-1/2 pr-2">
<div className="mb-2 block">
<Label htmlFor="name" value="Name" />
</div>
<TextInput id="name" type="text" placeholder="John Doe" value={user?.name ?? ""} required onChange={handleInputChange} />
</div>
<div className="w-1/2 pl-2">
<div className="mb-2 block">
<Label htmlFor="email" value="Email" />
</div>
<TextInput disabled={true} id="email" type="email" placeholder="[email protected]" value={user?.email ?? ""} required />
</div>
</div>

{/* Graduation Year and College */}
<div className="flex flex-row mb-4">
<div className="w-1/2 pr-2">
<div className="mb-2 block">
<Label htmlFor="graduationYear" value="Graduation Year" />
</div>
<TextInput id="graduationYear" type="text" placeholder="Graduation Year" value={user?.graduationYear ?? ""} required onChange={handleInputChange} />
</div>
<div className="w-1/2 pl-2">
<div className="mb-2 block">
<Label htmlFor="college" value="College" />
</div>
<Select id="college" required onChange={handleInputChange} value={user?.college ?? ""}>
<option value="CAS">CAS – College of Arts & Sciences</option>
<option value="Pardee">Pardee - The Frederick S. Pardee School of Global Studies</option>
<option value="QST">QST - Questrom School of Business</option>
<option value="COM">COM - College of Communication</option>
<option value="ENG">ENG - College of Engineering</option>
<option value="CFA">CFA - College of Fine Arts</option>
<option value="CDS">CDS - Faculty of Computing & Data Sciences </option>
<option value="CGS">CGS - College of General Studies</option>
<option value="Sargent">Sargent - Sargent College of Health and Rehabilitation Sciences</option>
<option value="SHA">SHA - School of Hospitality Administration</option>
<option value="Wheelock">Wheelock - Wheelock College of Education and Human Development</option>
<option value="Other">Other</option>
</Select>
</div>
</div>

{/* Major and Minor */}
<div className="flex flex-row">
<div className="w-1/2 pr-2">
<div className="mb-2 block">
<Label htmlFor="major" value="Major" />
</div>
<TextInput id="major" type="text" placeholder="Major" value={user?.major ?? ""} required onChange={handleInputChange} />
</div>
<div className="w-1/2 pl-2">
<div className="mb-2 block">
<Label htmlFor="minor" value="Minor" />
</div>
<TextInput id="minor" type="text" placeholder="Minor" value={user?.minor ?? ""} onChange={handleInputChange} />
</div>
</div>


</div>

{/* PCT-related Information */}
<div className="border-b border-gray-200 pb-6">
<h4 className={AdminTextStyles.subtitle}>PCT-related Information</h4>

{/* Class and Family */}
<div className="flex flex-row mb-4">
<div className="w-1/2 pr-2">
<div className="mb-2 block">
<Label htmlFor="class" value="Class" />
</div>
<TextInput id="class" type="text" placeholder="Class" value={user?.class ?? ""} required onChange={handleInputChange} />
</div>

<div className="w-1/2 pl-2">
<div className="mb-2 block">
<Label htmlFor="family" value="Family" />
</div>
<TextInput id="family" type="text" placeholder="Family" value={user?.family ?? ""} required onChange={handleInputChange} />
</div>
</div>

{/* Team and Big */}
<div className="flex flex-row mb-4">
<div className="w-1/2 pr-2">
<div className="mb-2 block">
<Label htmlFor="team" value="Team" />
</div>
<Select id="team" required onChange={handleInputChange} value={user.team ?? ""}>
<option value="recruitment">Recruitment</option>
<option value="marketing">Marketing</option>
<option value="internal">Internal</option>
<option value="external">External</option>
<option value="fundraising">Fundraising</option>
<option value="finance">Finance</option>
<option value="technology">Technology</option>
<option value="operations">Operations</option>
<option value="other">Other</option>
</Select>

</div>

<div className="w-1/2 pl-2">
<div className="mb-2 block">
<Label htmlFor="big" value="Big" />
</div>
<TextInput id="big" type="text" placeholder="Big" value={user?.big ?? ""} required onChange={handleInputChange} />
</div>
</div>
</div>
<Button type="submit">Update</Button>
</form>
</Card>
</div>
)
}
8 changes: 2 additions & 6 deletions app/admin/accountability/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Loader from "@/components/Loader";
import { AgGridReact } from 'ag-grid-react'; // AG Grid Component
import "ag-grid-community/styles/ag-grid.css"; // Mandatory CSS required by the grid
import "ag-grid-community/styles/ag-theme-quartz.css"; // Optional Theme applied to the grid
import { AdminTextStyles } from "@/styles/TextStyles";


export default function Accountability() {
Expand Down Expand Up @@ -69,18 +70,13 @@ export default function Accountability() {
fetchData();
}, []);

const textStyles = {
title: "text-4xl font-bold dark:text-white mb-6 mt-4 ",
subtitle: "mb-4 text-lg font-normal text-gray-500 dark:text-gray-400",
};

if (isLoading) {
return <Loader />
}

return (
<div className="overflow-x-auto">
<h1 className={textStyles.title}>Accountability Tracker</h1>
<h1 className={AdminTextStyles.title}>Accountability Tracker</h1>
<div
className="ag-theme-quartz" // applying the grid theme
style={{ height: "80vh" }} // the grid will fill the size of the parent container
Expand Down
11 changes: 3 additions & 8 deletions app/admin/announcements/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
"use client"
import React, { useState } from "react";
import { Card } from 'flowbite-react';
import { AdminTextStyles } from "@/styles/TextStyles";

export default function Announcements() {

const textStyles = {
title: "text-4xl font-bold dark:text-white mb-6 mt-4 ",
subtitle: "mb-4 text-lg font-normal text-gray-500 dark:text-gray-400",
content: "font-normal text-gray-700 dark:text-gray-400 whitespace-pre-line", // Add this style
};

var dummyAnnouncements = [
{
title: "Title of the Announcement Post 1",
Expand Down Expand Up @@ -45,14 +40,14 @@ export default function Announcements() {

return (
<div className="overflow-x-auto">
<h1 className={textStyles.title}>Announcements</h1>
<h1 className={AdminTextStyles.title}>Announcements</h1>
{dummyAnnouncements.map((announcement, index) => (
<Card key={index} href="#" className="max-w mb-4">
<h5 className="text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
{announcement.title}
</h5>
<p className="text-xs">{announcement.date}</p>
<p className={textStyles.content}>
<p className={AdminTextStyles.content}>
{announcement.content}
</p>
</Card>
Expand Down
35 changes: 14 additions & 21 deletions app/admin/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import React, { useState } from "react";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import { useRouter } from 'next/navigation'
import { Checkbox, Label } from 'flowbite-react';
import { Checkbox, Label, TextInput } from 'flowbite-react';
import { useAuth } from "@/app/contexts/AuthContext";
import { AdminTextStyles } from "@/styles/TextStyles";



Expand Down Expand Up @@ -160,11 +161,10 @@ export default function Create() {
required: boolean = false
) => (
<div className="sm:w-full md:w-96 mb-6">
<label className="block mb-2 text-md font-medium text-gray-900">
<label className={AdminTextStyles.default}>
{label} {required && <span className="text-red-500">*</span>}
</label>
<input
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-purple-500 focus:border-purple-500 block w-full p-2.5"
<TextInput
id={id as string} // Convert the id to a string
type={type}
placeholder={label}
Expand All @@ -178,7 +178,7 @@ export default function Create() {
const renderQuestions = () => {
return (
<div>
<div className="flex flex-col border rounded mb-6 p-4">
<div className={`flex flex-col border rounded p-4 ${AdminTextStyles.default}`}>
{formData.questions.length === 0 ? (
"None"
) : (
Expand All @@ -204,11 +204,10 @@ export default function Create() {
</svg>
</div>
<div className="mb-6">
<label className="block mb-2 text-sm font-medium text-gray-900">
<label className={`block ${AdminTextStyles.subtext}`}>
Question <span className="text-red-500">*</span>
</label>
<input
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-purple-500 focus:border-purple-500 block w-full p-2.5"
<TextInput
id={`question-${index}`} // Set a unique id for each question input
type="text"
placeholder="Question"
Expand All @@ -219,11 +218,10 @@ export default function Create() {
/>
</div>
<div className="mb-6">
<label className="block mb-2 text-sm font-medium text-gray-900">
<label className={`block ${AdminTextStyles.subtext}`}>
Additional Context / Subheadings
</label>
<input
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-purple-500 focus:border-purple-500 block w-full p-2.5"
<TextInput
id={`additional-${index}`} // Set a unique id for each additional input
type="text"
placeholder="Add any additional text that explains the question here"
Expand Down Expand Up @@ -277,7 +275,7 @@ export default function Create() {
const renderDeadline = () => {
return (
<div className="w-full mb-6">
<label className="block mb-2 text-md font-medium text-gray-900">
<label className={`block ${AdminTextStyles.default}`}>
Deadline <span className="text-red-500">*</span>
</label>
<DatePicker
Expand All @@ -288,7 +286,7 @@ export default function Create() {
timeFormat="HH:mm"
timeIntervals={15}
dateFormat="MMMM d, yyyy h:mm aa"
className="w-full bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-purple-500 focus:border-purple-500 block p-2.5"
className={`w-full ${AdminTextStyles.datepicker}`}
wrapperClassName="w-64" // Add a custom class to make it full width
/>
</div>
Expand All @@ -298,7 +296,7 @@ export default function Create() {
const renderAdditionalSection = () => {
return (
<div className="w-full mb-6">
<label className="block mb-2 text-md font-medium text-gray-900">
<label className={`block ${AdminTextStyles.default}`}>
Additional
</label>
<div className="flex items-center gap-2">
Expand All @@ -313,18 +311,13 @@ export default function Create() {
)
}

const textStyles = {
title: "text-4xl font-bold dark:text-white mb-6 mt-4",
subtitle: "mb-4 text-lg font-normal text-gray-500 dark:text-gray-400",
};

return (
<form onSubmit={handleSubmit} className="flex flex-col mb-8">
<h1 className={textStyles.title}>Create a New Listing</h1>
<h1 className={AdminTextStyles.title}>Create a New Listing</h1>

{renderInput("title", "Title", "text", true)}

<label className="block mb-2 text-md font-medium text-gray-900">
<label className={AdminTextStyles.default}>
Questions
</label>

Expand Down
Loading

0 comments on commit e2f01be

Please sign in to comment.