Skip to content

Commit

Permalink
Update styling and logic for subjects page, appointment modal, and si…
Browse files Browse the repository at this point in the history
…debar
  • Loading branch information
bartosz-skejcik committed Jan 2, 2024
1 parent 674452c commit a4f3b54
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 40 deletions.
6 changes: 3 additions & 3 deletions app/dashboard/subjects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ function DashboardSubjects({}: Props) {
Dodaj przedmiot
</button>
</div>
<div className="flex flex-wrap items-start justify-start gap-10 w-full">
<div className="flex flex-wrap items-start justify-start gap-5 w-full">
{subjects.map((subject) => (
<div
className="py-2 px-4 flex justify-between items-center rounded-lg border text-lg bg-neutral-50 border-neutral-200 max-w-[11rem] w-full"
className="py-2 px-4 flex justify-between items-center rounded-lg border text-lg bg-neutral-50 border-neutral-200 w-fit gap-x-5"
key={subject.id}
>
<p>{subject.name}</p>
<p className="whitespace-nowrap">{subject.name}</p>
<button
onClick={async () =>
await handleDelete(subject.id)
Expand Down
3 changes: 2 additions & 1 deletion app/panel/myAppointments/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ export const AppointmentModal = ({
("poprawa_kartkówki" ||
"poprawa_sprawdzianu" ||
"nauka")
? studentAppointment
? studentAppointment.topic &&
studentAppointment
.topic
.length > 25
? studentAppointment.topic.substring(
Expand Down
51 changes: 34 additions & 17 deletions components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function Sidebar({
setNotifications,
}: SidebarProps) {
const userRole = user?.role;
const userId = user?.id;
const [fillColor, setFillColor] = useState("");

useEffect(() => {
Expand All @@ -117,8 +118,11 @@ export function Sidebar({
useState(notifications);

const [unreadNotifications, setUnreadNotifications] = useState(
notifications.filter((notification) => notification.read == false)
.length
notifications.filter(
(notification) =>
notification.read == false &&
notification.userId == Number(userId)
).length
);

useEffect(() => {
Expand All @@ -128,17 +132,21 @@ export function Sidebar({
) {
setFilteredNotifications(
notifications.filter(
(notification) => notification.read == false
(notification) =>
notification.read == false &&
notification.userId == Number(userId)
)
);
}

setUnreadNotifications(
filteredNotifications.filter(
(notification) => notification.read == false
(notification) =>
notification.read == false &&
notification.userId == Number(userId)
).length
);
}, [notifications]);
}, [notifications, userId]);

async function handleNotificationRead(id: number) {
await fetch(`/api/notifications`, {
Expand All @@ -150,7 +158,11 @@ export function Sidebar({
});

const newNotifications = notifications
.filter((notification) => notification.read == false)
.filter(
(notification) =>
notification.read == false &&
notification.userId == Number(userId)
)
.map((notification: any) => {
if (notification.id == id) {
notification.read = true;
Expand Down Expand Up @@ -198,19 +210,24 @@ export function Sidebar({
pathname == item.href
? "bg-neutral-50 text-green-600"
: "text-neutral-700 hover:text-green-600 hover:bg-neutral-50",
"group flex items-center gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold w-full"
"group flex items-center gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold w-full",
item.count &&
"justify-between"
)}
>
<item.icon
className={clsx(
pathname == item.href
? "text-green-600"
: "text-neutral-400 group-hover:text-green-600",
"h-8 w-8 shrink-0"
)}
aria-hidden="true"
/>
<p>{item.name}</p>
<div className="flex items-center justify-center gap-x-3">
<item.icon
className={clsx(
pathname ==
item.href
? "text-green-600"
: "text-neutral-400 group-hover:text-green-600",
"h-8 w-8 shrink-0"
)}
aria-hidden="true"
/>
<p>{item.name}</p>
</div>
{item.count && (
<div className="py-1 flex items-center justify-center w-1/6 h-fit bg-neutral-50 border border-neutral-200 rounded-xl">
<p className="text-xs font-semibold text-neutral-400 text-center">
Expand Down
22 changes: 3 additions & 19 deletions components/panel/appointmentRegisteration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { Input } from "@/components/ui/input";
import { useSubjects } from "@/hooks/useSubjects";

type Appointment = {
subject: string;
Expand All @@ -26,25 +27,8 @@ interface Props {
studentId?: string;
}

const options = [
{ id: 1, name: "Matematyka" },
{ id: 2, name: "Fizyka" },
{ id: 3, name: "Chemia" },
{ id: 4, name: "Biologia" },
{ id: 5, name: "Geografia" },
{ id: 6, name: "Historia" },
{ id: 7, name: "Wiedza o społeczeństwie" },
{ id: 8, name: "Język polski" },
{ id: 9, name: "Język angielski" },
{ id: 10, name: "Język niemiecki" },
{ id: 13, name: "Język rosyjski" },
{ id: 17, name: "Informatyka" },
{ id: 18, name: "Wychowanie fizyczne" },
{ id: 19, name: "Edukacja dla bezpieczeństwa" },
{ id: 21, name: "Religia" },
];

export const SubjectSelection = ({ appointment, setAppointment }: Props) => {
const { subjects } = useSubjects();
const { teachers } = useTeacher();
const filteredTeachers =
appointment.subject != ""
Expand Down Expand Up @@ -81,7 +65,7 @@ export const SubjectSelection = ({ appointment, setAppointment }: Props) => {
<SelectValue placeholder="Wybierz przedmiot" />
</SelectTrigger>
<SelectContent>
{options.map((option) => (
{subjects.map((option) => (
<SelectItem key={option.id} value={option.name}>
{option.name}
</SelectItem>
Expand Down

0 comments on commit a4f3b54

Please sign in to comment.