Skip to content

Commit

Permalink
WEB-26: Update icons and add end announcement route
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnie4k committed Dec 12, 2024
1 parent 5aef4e4 commit c225e03
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 141 deletions.
4 changes: 2 additions & 2 deletions src/components/announcement/announcementBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CrossThick from "@/icons/crossThickIcon";
import { Announcement } from "@/models/announcement";
import { X } from "lucide-react";

interface Props {
announcement: Announcement;
Expand All @@ -16,7 +16,7 @@ export default function AnnouncementBanner({ announcement }: Props) {
<h6 className="text-neutral-800 line-clamp-1 break-words">{announcement.title}</h6>
<p className="label text-neutral-600 line-clamp-3 md:line-clamp-2 break-words">{announcement.body}</p>
</div>
<CrossThick className="size-[20px] fill-neutral-400" />
<X className="size-[20px] stroke-neutral-400" />
</div>
);
}
24 changes: 20 additions & 4 deletions src/components/announcement/announcementForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ApiClient from "@/services/apiClient";
import { useUserStore } from "@/stores/useUserStore";
import { formatDate } from "@/utils/utils";
import { addDays } from "date-fns";
import { Speaker, X } from "lucide-react";
import { Megaphone, X } from "lucide-react";
import { useMemo, useState } from "react";
import AlertPopup from "../system/alertPopup";
import ButtonPrimary1 from "../system/button/buttonPrimary1";
Expand Down Expand Up @@ -131,7 +131,7 @@ export default function AnnouncementForm({ onClose, editingAnnouncement }: Props
{/* Header */}
<div className="flex flex-row justify-between items-start gap-8">
<div className="flex flex-row items-center gap-4">
<Speaker className="size-[40px] stroke-neutral-800" />
<Megaphone className="size-[40px] stroke-neutral-800" />
<div className="flex flex-col gap-1">
<h4 className="text-neutral-800">Create Announcement</h4>
<p className="b1 text-neutral-600">Schedule an announcement to our apps with this form.</p>
Expand Down Expand Up @@ -170,8 +170,24 @@ export default function AnnouncementForm({ onClose, editingAnnouncement }: Props
to: new Date(announcement.endDate),
}}
setDateRange={(dateRange) => {
handleChange("startDate", dateRange?.from ?? "");
handleChange("endDate", dateRange?.to ?? "");
const startDate = dateRange?.from;
const endDate = dateRange?.to;

if (!startDate) {
handleChange("startDate", "");
return;
}
if (!endDate) {
handleChange("endDate", "");
return;
}

// Beginning of start date to end of end date
startDate.setHours(0, 0, 0, 0);
endDate.setHours(23, 59, 59, 999);

handleChange("startDate", startDate);
handleChange("endDate", endDate);
}}
/>
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/components/announcement/announcementModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,18 @@ export default function AnnouncementModal({ onClose, announcement }: Props) {
if (!user) return;

try {
console.log("Ending", announcement);
setIsLoading(true);
ApiClient.setAuthToken(apiClient, user.idToken);

await ApiClient.put(apiClient, `/announcements/${announcement.id}`, { endDate: new Date() });

// Successful
setIsLoading(false);
onClose(true);
} catch (err) {
console.error(err);
errorToast();
setIsLoading(false);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/landing/landingActiveSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Announcement } from "@/models/announcement";
import { Constants } from "@/utils/constants";
import { filterActiveAnnouncements, sortAnnouncementsByStartDate } from "@/utils/utils";
import { CalendarArrowUp } from "lucide-react";
import { CalendarCheck2 } from "lucide-react";
import { useState } from "react";
import AnnouncementCell from "../announcement/announcementCell";
import AnnouncementModal from "../announcement/announcementModal";
Expand All @@ -26,7 +26,7 @@ export default function LandingActiveSection({ announcements, onEditClick, onRef
return (
<div className="flex flex-col p-6 items-start gap-6 rounded-lg bg-neutral-white">
<div className="flex items-center gap-4 self-stretch">
<CalendarArrowUp className="size-[32px] md:size-[40px] stroke-neutral-800" />
<CalendarCheck2 className="size-[32px] md:size-[40px] stroke-neutral-800" />
<div className="flex flex-col">
<h4 className="self-stretch text-neutral-800">Active Announcements</h4>
<p className="b1 self-stretch text-neutral-600">Current and upcoming announcements.</p>
Expand Down
4 changes: 2 additions & 2 deletions src/components/landing/landingCreateAnnouncement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SpeakerIcon from "@/icons/speakerIcon";
import { Megaphone } from "lucide-react";
import ButtonPrimary1 from "../system/button/buttonPrimary1";

interface Props {
Expand All @@ -9,7 +9,7 @@ export default function LandingCreateAnnouncement({ action }: Props) {
return (
<div className="flex flex-col p-6 items-start gap-6 rounded-lg bg-neutral-white">
<div className="flex items-center gap-4 self-stretch">
<SpeakerIcon className="min-w-[32px] w-[32px] h-[32px] md:w-[40px] md:h-[40px] fill-neutral-800" />
<Megaphone className="size-[32px] md:size-[40px] stroke-neutral-800" />
<div className="flex flex-col gap-1">
<h4 className="text-neutral-800">Have something to say?</h4>
<p className="b1 text-neutral-600">Schedule an announcement to our apps with this form.</p>
Expand Down
6 changes: 3 additions & 3 deletions src/components/landing/landingPastSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CalendarPlainIcon from "@/icons/calendarPlainIcon";
import { Announcement } from "@/models/announcement";
import { Constants } from "@/utils/constants";
import { filterPastAnnouncements, sortAnnouncementsByStartDate } from "@/utils/utils";
import { CalendarX2 } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import AnnouncementCell from "../announcement/announcementCell";
Expand All @@ -16,7 +16,7 @@ interface Props {
export default function LandingPastSection({ announcements, onEditClick }: Props) {
const router = useRouter();

const pastAnnouncements = sortAnnouncementsByStartDate(filterPastAnnouncements(announcements ?? []));
const pastAnnouncements = sortAnnouncementsByStartDate(filterPastAnnouncements(announcements ?? [])).reverse();
const [selectedAnnouncement, setSelectedAnnouncement] = useState<Announcement | null>(null);

const openModal = (announcement: Announcement) => {
Expand All @@ -33,7 +33,7 @@ export default function LandingPastSection({ announcements, onEditClick }: Props
return (
<div className="flex flex-col p-6 items-start gap-6 rounded-lg bg-neutral-white">
<div className="flex items-center gap-4 self-stretch">
<CalendarPlainIcon className="w-[32px] md:w-[40px] h-[32px] md:h-[40px] stroke-neutral-800" />
<CalendarX2 className="size-[32px] md:size-[40px] stroke-neutral-800" />
<div className="flex flex-col">
<h4 className="self-stretch text-neutral-800">Past Announcements</h4>
<p className="b1 self-stretch text-neutral-600">Previous inactive announcements.</p>
Expand Down
10 changes: 5 additions & 5 deletions src/components/landing/landingUpcomingSection.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useState, useEffect, useMemo } from "react";
import HourglassIcon from "@/icons/hourglassIcon";
import AnnouncementBanner from "../announcement/announcementBanner";
import { Announcement } from "@/models/announcement";
import { calculateTimeRemaining, filterFutureAnnouncements, getEarliestAnnouncements } from "@/utils/utils";
import { Constants } from "@/utils/constants";
import { calculateTimeRemaining, filterFutureAnnouncements, getEarliestAnnouncements } from "@/utils/utils";
import { Timer } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import AnnouncementBanner from "../announcement/announcementBanner";

interface Props {
announcements?: Announcement[];
Expand Down Expand Up @@ -38,7 +38,7 @@ export default function LandingUpcomingSection({ announcements }: Props) {
return (
<div className="flex flex-col p-6 items-start gap-6 rounded-lg bg-neutral-white">
<div className="flex items-center gap-4 self-stretch">
<HourglassIcon className="w-[32px] h-[32px] md:w-[40px] md:h-[40px] stroke-neutral-800 fill-neutral-800" />
<Timer className="size-[32px] md:size-[40px] stroke-neutral-800" />
<div className="flex flex-col gap-1">
<h4 className="text-neutral-800">Up Next</h4>
<p className="b1 text-neutral-600">Countdown to the next announcement.</p>
Expand Down
4 changes: 2 additions & 2 deletions src/components/past/past.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import FilterIcon from "@/icons/filterIcon";
import { Announcement } from "@/models/announcement";
import { AppName } from "@/models/enums/appName";
import { SortType } from "@/models/enums/sortType";
import { createDummyAnnouncement } from "@/utils/dummy";
import { dateInRange } from "@/utils/utils";
import { ListFilter } from "lucide-react";
import { ChangeEvent, useEffect, useState } from "react";
import { DateRange } from "react-day-picker";
import Footer from "../common/footer";
Expand Down Expand Up @@ -139,7 +139,7 @@ export default function Past() {
className="flex flex-row gap-3 items-center px-4 py-3 rounded-md bg-neutral-white border border-other-stroke opacity-hover"
onClick={() => setShowFilters(true)}
>
<FilterIcon className="size-[16px] fill-neutral-400" />
<ListFilter className="size-[16px] stroke-neutral-400" />
<p className="b1 text-neutral-500">
{filterDateRange && filterApps.length !== 0
? "Filter - 2"
Expand Down
4 changes: 2 additions & 2 deletions src/components/system/input/inputDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export default function InputDatePicker({ value, setDateRange }: Props) {
{date?.from ? (
date.to ? (
<>
{format(date.from, "LLL dd, y")} - {format(date.to, "LLL dd, y")}
{format(date.from, "LLL d, hh:mm aa")} - {format(date.to, "LLL d, hh:mm aa")}
</>
) : (
format(date.from, "LLL dd, y")
format(date.from, "LLL d, hh:mm aa")
)
) : (
<span>Pick a date</span>
Expand Down
4 changes: 2 additions & 2 deletions src/components/system/input/inputSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { Input } from "@/components/ui/input";
import SearchIcon from "@/icons/searchIcon";
import { Search } from "lucide-react";
import { ChangeEvent } from "react";

interface Props {
Expand All @@ -13,7 +13,7 @@ interface Props {
export default function InputSearch({ text, placeholder, onChange }: Props) {
return (
<div className="relative flex items-center md:w-[320px] lg:w-[400px]">
<SearchIcon className="w-[16px] h-[16px] fill-neutral-300 absolute left-4" />
<Search className="size-[16px] stroke-neutral-300 absolute left-4" />
<Input
value={text}
onChange={onChange}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import * as React from "react";
import { ChevronLeft, ChevronRight } from "lucide-react";
import * as React from "react";
import { DayPicker } from "react-day-picker";

import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";

export type CalendarProps = React.ComponentProps<typeof DayPicker>;

Expand Down
15 changes: 0 additions & 15 deletions src/icons/CalendarPlainIcon.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions src/icons/CrossThickIcon.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions src/icons/CrossThinIcon.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/icons/EditIcon.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions src/icons/HourglassIcon.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/icons/SpeakerIcon.tsx

This file was deleted.

File renamed without changes.
Loading

0 comments on commit c225e03

Please sign in to comment.