-
Couldn't load subscription status.
- Fork 5
CORE-1287: Port remaining book details page modules from JS to TS #2786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,7 +121,7 @@ export function WebviewOption({model}: {model: Model}) { | |
| const {GiveDialog, openGiveDialog} = useOpenGiveDialog(); | ||
| const trackDownload = React.useCallback( | ||
| (event: TrackedMouseEvent) => { | ||
| trackLink(event, model.id); | ||
| trackLink(event, model.id.toString()); | ||
| }, | ||
| [model.id] | ||
| ); | ||
|
|
@@ -140,10 +140,10 @@ export function WebviewOption({model}: {model: Model}) { | |
| <GiveDialog | ||
| link={webviewLink} | ||
| variant="View online" | ||
| warning={model.contentWarningText} | ||
| warning={model.contentWarningText ?? undefined} | ||
| track="Online" | ||
| onDownload={trackDownload} | ||
| id={model.id} | ||
| id={model.id.toString()} | ||
| /> | ||
| {showCallout && ( | ||
| <div className="callout recommended-callout"> | ||
|
|
@@ -173,12 +173,12 @@ export function PdfOption({model}: {model: Model}) { | |
| const {GiveDialog, openGiveDialog} = useOpenGiveDialog(); | ||
| const trackDownload = React.useCallback( | ||
| (event: TrackedMouseEvent) => { | ||
| trackLink(event, model.id); | ||
| trackLink(event, model.id.toString()); | ||
| }, | ||
| [model.id] | ||
| ); | ||
|
|
||
| return ( | ||
| return pdfLink ? ( | ||
| <React.Fragment> | ||
| <SimpleLinkOption | ||
| link={pdfLink} | ||
|
|
@@ -190,11 +190,11 @@ export function PdfOption({model}: {model: Model}) { | |
| link={pdfLink} | ||
| track="PDF" | ||
| onDownload={trackDownload} | ||
| id={model.id} | ||
| warning={model.contentWarningText} | ||
| id={model.id.toString()} | ||
| warning={model.contentWarningText ?? undefined} | ||
| /> | ||
| </React.Fragment> | ||
| ); | ||
| ) : null; | ||
| } | ||
|
|
||
| export function usePrintCopyDialog() { | ||
|
|
@@ -254,8 +254,8 @@ export function KindleOption({model}: {model: Model}) { | |
|
|
||
| export function CheggOption({model}: {model: Model}) { | ||
| return ( | ||
| <Option condition={model.cheggLink}> | ||
| <a href={model.cheggLink} data-track="Chegg Reader"> | ||
| <Option condition={model.cheggLink ?? false}> | ||
| <a href={model.cheggLink as string} data-track="Chegg Reader"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type for this property seems confusing - it could be null, but not here? Do we need an |
||
| <img | ||
| className="logo-img" | ||
| src="/dist/images/icons/Chegglogo.svg" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import {useState} from 'react'; | |
| import buildContext from '~/components/jsx-helpers/build-context'; | ||
| import type {ResourceData} from './common/resource-box/resource-box-utils'; | ||
| import type {PromoteData} from './desktop-view/promo'; | ||
| import type {Model as GetThisTitleModel} from './common/get-this-title'; | ||
|
|
||
| export type LocaleType = { | ||
| locale: string; | ||
|
|
@@ -24,7 +25,7 @@ type StuffContent = { | |
| heading: string; | ||
| }; | ||
| }; | ||
| type VideoContent = { | ||
| export type VideoContent = { | ||
| title: string; | ||
| description: string; | ||
| embed: string; | ||
|
|
@@ -37,13 +38,14 @@ type Author = { | |
|
|
||
| export type IsbnType = 'print' | 'printSoftcover' | 'digital' | 'assignable'; | ||
|
|
||
| export type ContextValues = { | ||
| export type ContextValues = GetThisTitleModel & { | ||
| id: number; | ||
| slug: string; | ||
| translations: Array<TranslationType>; | ||
| bookState: string; | ||
| comingSoon: boolean; | ||
| coverColor: string; | ||
| description: string; | ||
| meta: LocaleType; | ||
| reverseGradient: boolean; | ||
| title: string; | ||
|
|
@@ -59,7 +61,7 @@ export type ContextValues = { | |
| webinarContent?: WebinarContent; | ||
| freeStuffStudent: StuffContent; | ||
| freeStuffInstructor: StuffContent; | ||
| videos: VideoContent[]; | ||
| videos: [VideoContent[]] | never[]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type seems odd, but maybe only because the CMS data shape is odd? |
||
| setUseCardBackground?: React.Dispatch<React.SetStateAction<boolean>>; | ||
| authors: Author[]; | ||
| created: string; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first commit shows the JS->TS changes, and there are a few more changes in the 2nd commit. |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal but I wonder if it would be nice to align the component types to the model so we don't have to do this