Skip to content

Commit ffa1098

Browse files
committed
Revert "LocalDate and NoSSR components to render localized dates only on client"
This reverts commit b4ccd6d.
1 parent b4ccd6d commit ffa1098

File tree

11 files changed

+22
-72
lines changed

11 files changed

+22
-72
lines changed

frontends/main/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "PORT=${PORT:-8062} TZ=UTC next dev",
6+
"dev": "PORT=${PORT:-8062} next dev",
77
"build": "next build",
88
"build:no-lint": "next build --no-lint",
9-
"start": "TZ=UTC next start",
9+
"start": "next start",
1010
"lint": "next lint"
1111
},
1212
"dependencies": {

frontends/main/src/app-pages/HomePage/NewsEventsSection.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
NewsEventsListFeedTypeEnum,
1414
} from "api/hooks/newsEvents"
1515
import type { NewsFeedItem, EventFeedItem } from "api/v0"
16-
import { LocalDate } from "ol-utilities"
16+
import { formatDate } from "ol-utilities"
1717
import { RiArrowRightSLine } from "@remixicon/react"
1818
import Link from "next/link"
1919

@@ -196,7 +196,7 @@ const Story: React.FC<{ item: NewsFeedItem; mobile: boolean }> = ({
196196
{item.title}
197197
</Card.Title>
198198
<Card.Footer>
199-
Published: <LocalDate date={item.news_details?.publish_date} />
199+
Published: {formatDate(item.news_details?.publish_date)}
200200
</Card.Footer>
201201
</StoryCard>
202202
)
@@ -226,16 +226,16 @@ const NewsEventsSection: React.FC = () => {
226226
<Card.Content>
227227
<EventDate>
228228
<EventDay>
229-
<LocalDate
230-
date={(item as EventFeedItem).event_details?.event_datetime}
231-
format="D"
232-
/>
229+
{formatDate(
230+
(item as EventFeedItem).event_details?.event_datetime,
231+
"D",
232+
)}
233233
</EventDay>
234234
<EventMonth>
235-
<LocalDate
236-
date={(item as EventFeedItem).event_details?.event_datetime}
237-
format="MMM"
238-
/>
235+
{formatDate(
236+
(item as EventFeedItem).event_details?.event_datetime,
237+
"MMM",
238+
)}
239239
</EventMonth>
240240
</EventDate>
241241
<Link href={item.url} data-card-link>

frontends/ol-components/src/components/LearningResourceCard/LearningResourceCard.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "@remixicon/react"
1010
import { LearningResource } from "api"
1111
import {
12-
LocalDate,
12+
formatDate,
1313
getReadableResourceType,
1414
DEFAULT_RESOURCE_IMG,
1515
getLearningResourcePrices,
@@ -149,8 +149,7 @@ const StartDate: React.FC<{ resource: LearningResource; size?: Size }> = ({
149149
const format = size === "small" ? "MMM DD, YYYY" : "MMMM DD, YYYY"
150150
const formatted = anytime
151151
? "Anytime"
152-
: startDate && <LocalDate date={startDate} format={format} />
153-
152+
: startDate && formatDate(startDate, format)
154153
if (!formatted) return null
155154

156155
const showLabel = size !== "small" || anytime

frontends/ol-components/src/components/LearningResourceCard/LearningResourceListCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "@remixicon/react"
1010
import { ResourceTypeEnum, LearningResource } from "api"
1111
import {
12-
LocalDate,
12+
formatDate,
1313
getReadableResourceType,
1414
DEFAULT_RESOURCE_IMG,
1515
pluralize,
@@ -151,7 +151,7 @@ export const StartDate: React.FC<{ resource: LearningResource }> = ({
151151
const startDate = getResourceDate(resource)
152152
const formatted = anytime
153153
? "Anytime"
154-
: startDate && <LocalDate date={startDate} format="MMMM DD, YYYY" />
154+
: startDate && formatDate(startDate, "MMMM DD, YYYY")
155155
if (!formatted) return null
156156

157157
return (

frontends/ol-components/src/components/LearningResourceExpanded/DifferingRunsTable.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
getDisplayPrice,
99
getRunPrices,
1010
showStartAnytime,
11-
NoSSR,
1211
} from "ol-utilities"
1312

1413
const DifferingRuns = styled.div({
@@ -104,9 +103,7 @@ const DifferingRunsTable: React.FC<{ resource: LearningResource }> = ({
104103
</DifferingRunHeader>
105104
{resource.runs?.map((run, index) => (
106105
<DifferingRun key={index}>
107-
<DateData>
108-
<NoSSR>{formatRunDate(run, asTaughtIn)}</NoSSR>
109-
</DateData>
106+
<DateData>{formatRunDate(run, asTaughtIn)}</DateData>
110107
{run.resource_prices && (
111108
<PriceData>
112109
<span>{getDisplayPrice(getRunPrices(run)["course"])}</span>

frontends/ol-components/src/components/LearningResourceExpanded/InfoSectionV2.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
formatRunDate,
2525
getLearningResourcePrices,
2626
showStartAnytime,
27-
NoSSR,
2827
} from "ol-utilities"
2928
import { theme } from "../ThemeProvider/ThemeProvider"
3029
import DifferingRunsTable from "./DifferingRunsTable"
@@ -256,11 +255,7 @@ const INFO_ITEMS: InfoItemConfig = [
256255
const totalDatesWithRuns =
257256
resource.runs?.filter((run) => run.start_date !== null).length || 0
258257
if (allRunsAreIdentical(resource) && totalDatesWithRuns > 0) {
259-
return (
260-
<NoSSR>
261-
<RunDates resource={resource} />
262-
</NoSSR>
263-
)
258+
return <RunDates resource={resource} />
264259
} else return null
265260
},
266261
},

frontends/ol-components/src/components/LearningResourceExpanded/LearningResourceExpandedV1.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { ButtonLink } from "../Button/Button"
77
import type { LearningResource, LearningResourceRun } from "api"
88
import { ResourceTypeEnum, PlatformEnum } from "api"
99
import {
10-
NoSSR,
1110
formatDate,
1211
capitalize,
1312
DEFAULT_RESOURCE_IMG,
@@ -300,7 +299,7 @@ const ResourceDescription = ({ resource }: { resource?: LearningResource }) => {
300299
return (
301300
<Description
302301
/**
303-
* Resource descriptions can contain HTML. They are sanitized on the
302+
* Resource descriptions can contain HTML. They are santiized on the
304303
* backend during ETL. This is safe to render.
305304
*/
306305
dangerouslySetInnerHTML={{ __html: resource.description || "" }}
@@ -385,7 +384,7 @@ const LearningResourceExpandedV1: React.FC<LearningResourceExpandedV1Props> = ({
385384
.map((run) => {
386385
return {
387386
value: run.id.toString(),
388-
label: <NoSSR>{formatRunDate(run, asTaughtIn)}</NoSSR>,
387+
label: formatRunDate(run, asTaughtIn),
389388
}
390389
}) ?? []
391390

@@ -416,7 +415,7 @@ const LearningResourceExpandedV1: React.FC<LearningResourceExpandedV1Props> = ({
416415
return (
417416
<DateSingle>
418417
<DateLabel>{label}</DateLabel>
419-
<NoSSR>{formatted ?? ""}</NoSSR>
418+
{formatted ?? ""}
420419
</DateSingle>
421420
)
422421
}

frontends/ol-utilities/src/date/LocalDate.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

frontends/ol-utilities/src/date/format.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import moment from "moment"
22

3-
/* Instances must be wrapped in <NoSSR> to avoid SSR hydration mismatches.
4-
*/
53
export const formatDate = (
64
/**
75
* Date string or date.
86
*/
97
date: string | Date,
108
/**
11-
* A Moment.js format string. See https://momentjs.com/docs/#/displaying/format/
9+
* A momentjs format string. See https://momentjs.com/docs/#/displaying/format/
1210
*/
1311
format = "MMM D, YYYY",
1412
) => {

frontends/ol-utilities/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
export * from "./styles"
77

88
export * from "./date/format"
9-
export * from "./date/LocalDate"
109
export * from "./learning-resources/learning-resources"
1110
export * from "./learning-resources/pricing"
1211
export * from "./strings/html"
@@ -15,4 +14,3 @@ export * from "./hooks"
1514
export * from "./querystrings"
1615
export * from "./lib"
1716
export * from "./images/backgroundImages"
18-
export * from "./ssr/NoSSR"

0 commit comments

Comments
 (0)