11import Empty from "../../../components/Empty" ;
22import { NoticeYear , TimetablNotice } from "../../../consumers/sbhsApi/schemas" ;
3- // import { useTimetablNews } from "../../../services/timetablCms/useTimetablNews";
43import { useDailyNotices } from "../../../consumers/sbhsApi/useDailyNotices" ;
54import { Search2Icon } from "@chakra-ui/icons" ;
65import {
@@ -10,11 +9,6 @@ import {
109 Flex ,
1110 Heading ,
1211 Skeleton ,
13- Tab ,
14- TabList ,
15- TabPanel ,
16- TabPanels ,
17- Tabs ,
1812 useDisclosure ,
1913 Text ,
2014 Input ,
@@ -25,12 +19,15 @@ import {
2519 FormLabel ,
2620 Highlight ,
2721 FormControl ,
22+ Alert ,
23+ AlertDescription ,
24+ AlertTitle ,
25+ Box ,
2826} from "@chakra-ui/react" ;
2927import { Prose } from "@nikolovlazar/chakra-ui-prose" ;
3028import DOMPurify from "dompurify" ;
3129import linkifyHtml from "linkify-html" ;
3230import { DateTime } from "luxon" ;
33- import { micromark } from "micromark" ;
3431import { MegaphoneSimple } from "phosphor-react" ;
3532import { useState } from "react" ;
3633import { create } from "zustand" ;
@@ -74,14 +71,12 @@ function Announcement({
7471 authorName,
7572 date,
7673 query,
77- markdown,
7874} : {
7975 title : string ;
8076 content : string ;
8177 authorName ?: string ;
8278 date ?: string ;
8379 query : string ;
84- markdown ?: boolean ;
8580} ) {
8681 const { isOpen, onToggle } = useDisclosure ( ) ;
8782 const [ showShowMoreBtn , setShowShowMoreBtn ] = useState ( true ) ;
@@ -100,15 +95,12 @@ function Announcement({
10095 < Prose >
10196 < div
10297 ref = { ( content ) =>
103- setShowShowMoreBtn ( ( content ?. offsetHeight ?? 0 / 24 ) > 1 )
98+ setShowShowMoreBtn ( ( content ?. offsetHeight ?? 0 ) / 24 > 1 )
10499 }
105100 dangerouslySetInnerHTML = { {
106- __html : linkifyHtml (
107- DOMPurify . sanitize ( markdown ? micromark ( content ) : content ) ,
108- {
109- defaultProtocol : "https" ,
110- }
111- ) ,
101+ __html : linkifyHtml ( DOMPurify . sanitize ( content ) , {
102+ defaultProtocol : "https" ,
103+ } ) ,
112104 } }
113105 />
114106 </ Prose >
@@ -138,44 +130,22 @@ function Announcement({
138130function DailyNotices ( {
139131 filter,
140132 query,
141- tab,
142133 dailyNoticesLoading,
143- timetablNewsLoading,
144134 dailyNotices,
145- timetablNews,
146135} : {
147136 filter : NoticeYear ;
148137 query : string ;
149- tab : number ;
150- timetablNewsLoading : boolean ;
151138 dailyNoticesLoading : boolean ;
152139 dailyNotices ?: TimetablNotice [ ] ;
153- timetablNews ?: TimetablNotice [ ] ;
154140} ) {
155- const notices = filterNotices (
156- tab ? timetablNews : dailyNotices ,
157- filter ,
158- query
159- ) ;
141+ const notices = filterNotices ( dailyNotices , filter , query ) ;
160142
161143 return (
162- < Skeleton
163- isLoaded = { tab ? ! timetablNewsLoading : ! dailyNoticesLoading }
164- rounded = { 5 }
165- minH = { 10 }
166- minW = { 40 }
167- >
144+ < Skeleton isLoaded = { ! dailyNoticesLoading } rounded = { 5 } minH = { 10 } minW = { 40 } >
168145 < Flex direction = { "column" } align = "center" gap = { 8 } >
169146 { notices ?. length ? (
170147 notices ?. map ( ( notice , index ) => {
171- return (
172- < Announcement
173- key = { index }
174- query = { query }
175- markdown = { ! ! tab }
176- { ...notice }
177- />
178- ) ;
148+ return < Announcement key = { index } query = { query } { ...notice } /> ;
179149 } )
180150 ) : (
181151 < Empty
@@ -194,30 +164,39 @@ function DailyNotices({
194164export default function Announcements ( ) {
195165 const { year, setYear } = useAnnouncementStore ( ) ;
196166
197- const timetablNews = undefined ;
198- const timetablNewsLoaded = false ;
199-
200167 const { data : dailyNotices , isLoading : dailyNoticesLoading } =
201168 useDailyNotices ( ) ;
202169
203- const [ tabIndex , setTabIndex ] = useState ( 0 ) ;
204- const handleTabsChange = ( index : number ) => {
205- setTabIndex ( index ) ;
206- } ;
207-
208170 const [ query , setQuery ] = useState ( "" ) ;
171+ const [ isDownloading , setIsDownloading ] = useState ( false ) ;
209172
210173 return (
211- < Flex w = "full" direction = { "column" } >
212- < Flex align = "left" w = "full" zIndex = { 1 } p = { "5px" } >
174+ < Flex w = "full" direction = { "column" } px = { "30px" } gap = { "20px" } >
175+ < Alert status = "info" rounded = { "md" } >
176+ < Box >
177+ < AlertTitle mb = { 2 } fontFamily = { "Poppins, sans-serif" } >
178+ Read the latest edition of the High Notes
179+ </ AlertTitle >
180+ < AlertDescription >
181+ < Button
182+ as = "a"
183+ href = "https://sbhs.co/hnpdf"
184+ onClick = { ( ) => setIsDownloading ( true ) }
185+ isLoading = { isDownloading }
186+ loadingText = "Downloading PDF..."
187+ >
188+ Download High Notes PDF
189+ </ Button >
190+ </ AlertDescription >
191+ </ Box >
192+ </ Alert >
193+ < Flex align = "" w = "full" zIndex = { 1 } >
213194 < InputGroup maxW = "fit-content" >
214195 < InputLeftElement pointerEvents = "none" >
215196 < Search2Icon color = "gray.300" />
216197 </ InputLeftElement >
217198 < Input
218- placeholder = { `Search ${
219- tabIndex ? "Timetabl News" : "Daily Notices"
220- } `}
199+ placeholder = { "Search Daily Notices" }
221200 value = { query }
222201 variant = "filled"
223202 onChange = { ( event ) => setQuery ( event . target . value ) }
@@ -247,32 +226,12 @@ export default function Announcements() {
247226 </ Select >
248227 </ FormControl >
249228 </ Flex >
250- < Tabs
251- variant = "solid-rounded"
252- mt = { "10px" }
253- index = { tabIndex }
254- onChange = { handleTabsChange }
255- >
256- < TabList >
257- < Tab > Daily Notices</ Tab >
258- < Tab > Timetabl News</ Tab >
259- </ TabList >
260- < TabPanels >
261- { [ 0 , 1 ] . map ( ( tab ) => (
262- < TabPanel key = { tab } >
263- < DailyNotices
264- filter = { year }
265- query = { query }
266- tab = { tab }
267- timetablNews = { timetablNews }
268- dailyNotices = { dailyNotices }
269- timetablNewsLoading = { timetablNewsLoaded }
270- dailyNoticesLoading = { dailyNoticesLoading }
271- />
272- </ TabPanel >
273- ) ) }
274- </ TabPanels >
275- </ Tabs >
229+ < DailyNotices
230+ filter = { year }
231+ query = { query }
232+ dailyNotices = { dailyNotices }
233+ dailyNoticesLoading = { dailyNoticesLoading }
234+ />
276235 </ Flex >
277236 ) ;
278237}
0 commit comments