From 0925ea8c104240af8e1deb2ef6fef1e4c26261ab Mon Sep 17 00:00:00 2001 From: Damian <37555910+DCRepublic@users.noreply.github.com> Date: Thu, 7 Nov 2024 12:19:50 -0500 Subject: [PATCH] Format time --- components/CourseCard.tsx | 22 ++++++++++++------- components/Search.tsx | 8 +++++-- docker-compose.debug.yml | 2 +- .../migration.sql | 10 +++++++++ 4 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 prisma/migrations/20241107165826_courseplanner1_1/migration.sql diff --git a/components/CourseCard.tsx b/components/CourseCard.tsx index 75d0d1b..555b483 100644 --- a/components/CourseCard.tsx +++ b/components/CourseCard.tsx @@ -15,6 +15,7 @@ import { generateColorFromName } from "../components/primitives"; import { InstructorCard } from "./InstructorCard"; import AddIcon from "@mui/icons-material/Add"; +import moment from "moment"; import axios from "axios"; export const card = tv({ slots: { @@ -142,14 +143,19 @@ export default function CourseCard(props: any) {

Time

- {" "} - {props.course.facultyMeet.meetingTimes.beginTime.slice(0, 2) + - ":" + - props.course.facultyMeet.meetingTimes.beginTime.slice(2)}{" "} - -{" "} - {props.course.facultyMeet.meetingTimes.endTime.slice(0, 2) + - ":" + - props.course.facultyMeet.meetingTimes.endTime.slice(2)} + {moment( + props.course.facultyMeet.meetingTimes.beginTime.slice(0, 2) + + ":" + + props.course.facultyMeet.meetingTimes.beginTime.slice(2), + "HH:mm" + ).format("hh:mm a")} + - + {moment( + props.course.facultyMeet.meetingTimes.endTime.slice(0, 2) + + ":" + + props.course.facultyMeet.meetingTimes.endTime.slice(2), + "HH:mm" + ).format("hh:mm a")}
) : null} diff --git a/components/Search.tsx b/components/Search.tsx index c562940..688e4d2 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -5,7 +5,7 @@ import { useSearchParams, usePathname, useRouter } from "next/navigation"; import { useDebouncedCallback } from "use-debounce"; import { Select, SelectItem } from "@nextui-org/react"; import { useEffect, useState } from "react"; - +import moment from "moment"; export default function Search(props: any) { let router = useRouter(); const searchParams = useSearchParams(); @@ -159,9 +159,13 @@ export default function Search(props: any) { onSelectionChange={handleSTimeChange} > {props.times.startTimes.map((startTime: any) => { + var time = startTime.slice(0, 2) + ":" + startTime.slice(2); + var daTime = moment(time, "HH:mm").format("hh:mm A"); + + console.log(daTime); return ( - {startTime.slice(0, 2) + ":" + startTime.slice(2)} + {daTime} ); })} diff --git a/docker-compose.debug.yml b/docker-compose.debug.yml index 35d5fdb..533f81a 100644 --- a/docker-compose.debug.yml +++ b/docker-compose.debug.yml @@ -17,7 +17,7 @@ services: - 9229:9229 networks: - internal - command: sh -c "npm install --silent && npx prisma migrate dev && npm run dev " + command: sh -c "npm install --silent && npx prisma generate && npm run dev " postgres: image: postgres:16.4-bullseye diff --git a/prisma/migrations/20241107165826_courseplanner1_1/migration.sql b/prisma/migrations/20241107165826_courseplanner1_1/migration.sql new file mode 100644 index 0000000..f2724ea --- /dev/null +++ b/prisma/migrations/20241107165826_courseplanner1_1/migration.sql @@ -0,0 +1,10 @@ +/* + Warnings: + + - Made the column `beginTime` on table `MeetingTime` required. This step will fail if there are existing NULL values in that column. + - Made the column `endTime` on table `MeetingTime` required. This step will fail if there are existing NULL values in that column. + +*/ +-- AlterTable +ALTER TABLE "MeetingTime" ALTER COLUMN "beginTime" SET NOT NULL, +ALTER COLUMN "endTime" SET NOT NULL;