11import { Box , Button , Chip , CircularProgress , Stack , styled , Typography } from "@mui/material" ;
22import { ErrorBoundary , Suspense } from "@suspensive/react" ;
33import * as React from "react" ;
4+ import { Link } from "react-router-dom" ;
45import * as R from "remeda" ;
56
67import PyCon2025Logo from "../../assets/pyconkr2025_logo.png" ;
@@ -10,18 +11,17 @@ import { ErrorFallback } from "../error_handler";
1011import { FallbackImage } from "../fallback_image" ;
1112import { StyledDivider } from "./styled_divider" ;
1213
13- const SessionItem : React . FC < { session : BackendAPISchemas . SessionSchema } > = Suspense . with ( { fallback : < CircularProgress /> } , ( { session } ) => {
14- const sessionTitle = session . title . replace ( "\\n" , "\n" ) ;
15- const speakerImgSrc = session . image || ( R . isArray ( session . speakers ) && ! R . isEmpty ( session . speakers ) && session . speakers [ 0 ] . image ) || "" ;
16- // const urlSafeTitle = session.title
17- // .replace(/ /g, "-")
18- // .replace(/([.])/g, "_")
19- // .replace(/(?![0-9A-Za-zㄱ-ㅣ가-힣-_])./g, "");
20- // const sessionDetailedUrl = `/session/${session.id}#${urlSafeTitle}`;
21-
22- return (
23- < >
24- { /* <Link to={sessionDetailedUrl} style={{ textDecoration: "none" }}> */ }
14+ const SessionItem : React . FC < { session : BackendAPISchemas . SessionSchema ; enableLink ?: boolean } > = Suspense . with (
15+ { fallback : < CircularProgress /> } ,
16+ ( { session, enableLink } ) => {
17+ const sessionTitle = session . title . replace ( "\\n" , "\n" ) ;
18+ const speakerImgSrc = session . image || ( R . isArray ( session . speakers ) && ! R . isEmpty ( session . speakers ) && session . speakers [ 0 ] . image ) || "" ;
19+ const urlSafeTitle = session . title
20+ . replace ( / / g, "-" )
21+ . replace ( / ( [ . ] ) / g, "_" )
22+ . replace ( / (? ! [ 0 - 9 A - Z a - z ㄱ - ㅣ 가 - 힣 - _ ] ) ./ g, "" ) ;
23+ const sessionDetailedUrl = `/presentations/${ session . id } #${ urlSafeTitle } ` ;
24+ const result = (
2525 < SessionItemContainer direction = "row" >
2626 < SessionImageContainer
2727 children = { < SessionImage src = { speakerImgSrc } alt = "Session Image" loading = "lazy" errorFallback = { < SessionImageErrorFallback /> } /> }
@@ -40,20 +40,25 @@ const SessionItem: React.FC<{ session: BackendAPISchemas.SessionSchema }> = Susp
4040 </ Stack >
4141 </ Stack >
4242 </ SessionItemContainer >
43- { /* </Link> */ }
44- < StyledDivider />
45- </ >
46- ) ;
47- } ) ;
43+ ) ;
44+ return (
45+ < >
46+ { enableLink ? < Link to = { sessionDetailedUrl } style = { { textDecoration : "none" } } children = { result } /> : result }
47+ < StyledDivider />
48+ </ >
49+ ) ;
50+ }
51+ ) ;
4852
4953type SessionListPropType = {
5054 event ?: string ;
5155 types ?: string | string [ ] ;
56+ enableLink ?: boolean ;
5257} ;
5358
5459export const SessionList : React . FC < SessionListPropType > = ErrorBoundary . with (
5560 { fallback : ErrorFallback } ,
56- Suspense . with ( { fallback : < CircularProgress /> } , ( { event, types } ) => {
61+ Suspense . with ( { fallback : < CircularProgress /> } , ( { event, types, enableLink } ) => {
5762 const { language } = Hooks . Common . useCommonContext ( ) ;
5863 const backendAPIClient = Hooks . BackendAPI . useBackendClient ( ) ;
5964 const params = { ...( event && { event } ) , ...( types && { types : R . isString ( types ) ? types : types . join ( "," ) } ) } ;
@@ -103,7 +108,7 @@ export const SessionList: React.FC<SessionListPropType> = ErrorBoundary.with(
103108 ) }
104109 </ Box >
105110 { filteredSessions . map ( ( s ) => (
106- < SessionItem key = { s . id } session = { s } />
111+ < SessionItem key = { s . id } session = { s } enableLink = { enableLink } />
107112 ) ) }
108113 </ Box >
109114 ) ;
0 commit comments