Skip to content

Commit a73f87b

Browse files
committed
Lint clean
1 parent d7ea221 commit a73f87b

File tree

15 files changed

+76
-77
lines changed

15 files changed

+76
-77
lines changed

src/app/components/accordion-group/accordion-group.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ function Item({
109109

110110
type ItemType = {
111111
title: string;
112-
inline?: React.ReactNode;
113112
contentComponent: React.ReactNode;
113+
} | {
114+
inline: React.ReactNode;
114115
};
115116

116117
export default function AccordionGroup({
@@ -161,16 +162,15 @@ export default function AccordionGroup({
161162
preExpanded={preExpandedUuids}
162163
data-analytics-nav={analyticsNav}
163164
>
164-
{items.map(
165-
(item) =>
166-
item.inline || (
167-
<Item
168-
analytics={!!analyticsNav}
169-
key={item.title}
170-
{...item}
171-
checkChevronDirection={chevronDirection}
172-
/>
173-
)
165+
{items.filter((i) => 'title' in i).map(
166+
(item) => (
167+
<Item
168+
analytics={!!analyticsNav}
169+
key={item.title}
170+
{...item}
171+
checkChevronDirection={chevronDirection}
172+
/>
173+
)
174174
)}
175175
</Accordion>
176176
</div>

src/app/pages/details/common/get-this-title-files/options.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function WebviewOption({model}: {model: Model}) {
121121
const {GiveDialog, openGiveDialog} = useOpenGiveDialog();
122122
const trackDownload = React.useCallback(
123123
(event: TrackedMouseEvent) => {
124-
trackLink(event, model.id);
124+
trackLink(event, model.id.toString());
125125
},
126126
[model.id]
127127
);
@@ -140,10 +140,10 @@ export function WebviewOption({model}: {model: Model}) {
140140
<GiveDialog
141141
link={webviewLink}
142142
variant="View online"
143-
warning={model.contentWarningText}
143+
warning={model.contentWarningText ?? undefined}
144144
track="Online"
145145
onDownload={trackDownload}
146-
id={model.id}
146+
id={model.id.toString()}
147147
/>
148148
{showCallout && (
149149
<div className="callout recommended-callout">
@@ -173,12 +173,12 @@ export function PdfOption({model}: {model: Model}) {
173173
const {GiveDialog, openGiveDialog} = useOpenGiveDialog();
174174
const trackDownload = React.useCallback(
175175
(event: TrackedMouseEvent) => {
176-
trackLink(event, model.id);
176+
trackLink(event, model.id.toString());
177177
},
178178
[model.id]
179179
);
180180

181-
return (
181+
return pdfLink ? (
182182
<React.Fragment>
183183
<SimpleLinkOption
184184
link={pdfLink}
@@ -190,11 +190,11 @@ export function PdfOption({model}: {model: Model}) {
190190
link={pdfLink}
191191
track="PDF"
192192
onDownload={trackDownload}
193-
id={model.id}
194-
warning={model.contentWarningText}
193+
id={model.id.toString()}
194+
warning={model.contentWarningText ?? undefined}
195195
/>
196196
</React.Fragment>
197-
);
197+
) : null;
198198
}
199199

200200
export function usePrintCopyDialog() {
@@ -254,8 +254,8 @@ export function KindleOption({model}: {model: Model}) {
254254

255255
export function CheggOption({model}: {model: Model}) {
256256
return (
257-
<Option condition={model.cheggLink}>
258-
<a href={model.cheggLink} data-track="Chegg Reader">
257+
<Option condition={model.cheggLink ?? false}>
258+
<a href={model.cheggLink as string} data-track="Chegg Reader">
259259
<img
260260
className="logo-img"
261261
src="/dist/images/icons/Chegglogo.svg"

src/app/pages/details/common/get-this-title.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import './get-this-title-files/get-this-title.scss';
1414
import trackLink from './track-link';
1515

1616
export type Model = {
17-
id: string;
17+
id: number;
1818
slug: string;
1919
bookState: string;
2020
comingSoon: boolean;
@@ -23,13 +23,13 @@ export type Model = {
2323
kindleLink: string;
2424
webviewRexLink: string;
2525
webviewLink: string;
26-
contentWarningText?: string;
26+
contentWarningText: string | null;
2727
rexCalloutTitle?: string;
2828
rexCalloutBlurb?: string;
29-
highResolutionPdfUrl: string;
30-
lowResolutionPdfUrl: string;
31-
cheggLink: string; // These may not be supported at all anymore,
32-
cheggLinkText: string; // but the CMS is still serving them.
29+
highResolutionPdfUrl: string | null;
30+
lowResolutionPdfUrl: string | null;
31+
cheggLink: string | null; // These may not be supported at all anymore,
32+
cheggLinkText: string | null; // but the CMS is still serving them.
3333
};
3434
type ModelKey = 'bookshareLink' | 'kindleLink';
3535
type TrackedMouseEvent = Parameters<typeof trackLink>[0];
@@ -50,7 +50,7 @@ export default function GetThisTitle({model}: {model: Model}) {
5050
const [expanded, toggleExpanded] = useToggle(additionalOptions < 1);
5151
const interceptLinkClicks = React.useCallback<React.MouseEventHandler>(
5252
(event: TrackedMouseEvent) => {
53-
trackLink(event, model.id);
53+
trackLink(event, model.id.toString());
5454
},
5555
[model.id]
5656
);

src/app/pages/details/common/hooks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type PartnerData = {
4646
}
4747

4848
export function usePartnerFeatures(bookAbbreviation: string) {
49-
const [blurbs, setBlurbs] = useState<object[]>([]);
49+
const [blurbs, setBlurbs] = useState<ReturnType<typeof toBlurb>[]>([]);
5050
const [includePartners, setIncludePartners] = useState('');
5151

5252
useEffect(() => {
@@ -64,5 +64,5 @@ export function usePartnerFeatures(bookAbbreviation: string) {
6464
});
6565
}, [bookAbbreviation]);
6666

67-
return [blurbs, includePartners];
67+
return [blurbs, includePartners] as const;
6868
}

src/app/pages/details/common/publication-info.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import useDetailsContext, {ContextValues, IsbnType} from '../context';
77

88
function PdfUpdateInfo({updateDate, url}: {
99
updateDate?: string | null;
10-
url?: string;
10+
url: string | null;
1111
}) {
1212
if (!updateDate) {
1313
return null;
@@ -209,8 +209,8 @@ function LabeledDate({label, date, className}: {
209209
);
210210
}
211211

212-
export default function PublicationInfo({url, polish}: {
213-
url: string;
212+
export default function PublicationInfo({url = null, polish}: {
213+
url?: string | null;
214214
polish?: boolean;
215215
}) {
216216
const model = useDetailsContext();

src/app/pages/details/common/resource-box/left-content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function LeftButton({model}: {model: ResourceModel & LinkIsSet}) {
103103
const trackDownloadClick = React.useCallback(
104104
(event: TrackedMouseEvent) => {
105105
if (userStatus?.isInstructor) {
106-
trackLink(event, model.bookModel?.id.toString());
106+
trackLink(event, model.bookModel.id.toString());
107107
}
108108
},
109109
[model.bookModel, userStatus]

src/app/pages/details/common/resource-box/resource-box-utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type ResourceData = {
3131
resourceUnlocked: boolean;
3232
creatorFestResource: boolean;
3333
description: string;
34+
comingSoonText?: string;
3435
};
3536
comingSoonText: string | null;
3637
videoReferenceNumber?: number | null;

src/app/pages/details/desktop-view/desktop-view.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import JITLoad from '~/helpers/jit-load';
1111
import {findSelectedTab, replaceSearchTerm} from '../common/tab-utils';
1212
import './desktop-view.scss';
1313

14-
const importDetailsTab = () => import('./details-tab/details-tab');
14+
const importDetailsTab = () => import('./details-tab/import-details-tab');
1515
const importInstructorTab = () =>
1616
import('./instructor-resource-tab/import-instructor-resource-tab');
1717
const importStudentTab = () =>
@@ -70,10 +70,9 @@ function useSelectedLabelTiedToSearchString(labels: string[]) {
7070

7171
type StubUntilSeenProps = {
7272
active: boolean;
73-
importFn: () => Promise<{default: React.ComponentType<unknown>}>;
7473
polish?: boolean;
7574
model?: ContextValues;
76-
};
75+
} & Parameters<typeof JITLoad>[0]
7776

7877
function StubUntilSeen({active, ...JLParams}: StubUntilSeenProps) {
7978
const [seen, setSeen] = useState(false);
@@ -118,7 +117,7 @@ export default function DesktopView() {
118117
<ContentGroup activeIndex={activeIndex} labels={labels}>
119118
<StubUntilSeen
120119
active={activeIndex === 0}
121-
importFn={importDetailsTab}
120+
importFn={importDetailsTab as Parameters<typeof JITLoad>[0]['importFn']}
122121
polish={polish}
123122
model={model}
124123
/>

src/app/pages/details/desktop-view/details-tab/details-tab.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import Promo from '../promo';
99
import type {ContextValues} from '../../context';
1010
import './details-tab.scss';
1111

12+
export type DetailsTabArgs = {
13+
model: ContextValues;
14+
polish: boolean;
15+
}
16+
1217
function PolishTab({model}: {model: ContextValues}) {
1318
return (
1419
<div className="details-tab">
@@ -28,7 +33,7 @@ function PolishTab({model}: {model: ContextValues}) {
2833
</div>
2934
<Authors />
3035
<ErrataSection />
31-
<PublicationInfo model={model} polish={true} />
36+
<PublicationInfo polish={true} />
3237
</div>
3338
</div>
3439
);
@@ -65,7 +70,7 @@ function EnglishTab({model}: {model: ContextValues}) {
6570
<Authors />
6671
<ErrataSection />
6772
<div className="publication-info">
68-
<PublicationInfo model={model} url={null} />
73+
<PublicationInfo url={null} />
6974
</div>
7075
{model.adoptions && <SavingsBlurb />}
7176
</div>
@@ -76,10 +81,7 @@ function EnglishTab({model}: {model: ContextValues}) {
7681
export default function DetailsTab({
7782
model,
7883
polish
79-
}: {
80-
model: ContextValues;
81-
polish: boolean;
82-
}) {
84+
}: DetailsTabArgs) {
8385
const Child = polish ? PolishTab : EnglishTab;
8486

8587
return <Child model={model} />;

src/app/pages/details/desktop-view/instructor-resource-tab/partners/partners.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type PartnerBlurb = {
99
type: string;
1010
image: string;
1111
cost?: string;
12-
verifiedFeatures: string[];
12+
verifiedFeatures?: string[];
1313
};
1414

1515
type PartnersModel = {
@@ -47,7 +47,7 @@ export default function Partners({
4747
<div className="partners">
4848
<div className="callout"></div>
4949
<div className="title-bar" data-analytics-nav={title}>
50-
<span role="heading" aria-level="3">
50+
<span role="heading" aria-level={3}>
5151
{title}
5252
</span>
5353
<a
@@ -72,10 +72,10 @@ export default function Partners({
7272
logoUrl={blurb.image}
7373
tags={[blurb.cost, blurb.type].filter(
7474
(x) => x
75-
)}
75+
) as string[]}
7676
onClick={onClick}
7777
badgeImage={badgeImage}
78-
verifiedFeatures={blurb.verifiedFeatures}
78+
verifiedFeatures={blurb.verifiedFeatures?.join(', ')}
7979
analyticsContentType="Partner Profile"
8080
/>
8181
</li>

0 commit comments

Comments
 (0)