Skip to content

Commit

Permalink
Added publisher field
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Oct 14, 2024
1 parent 9446a3e commit 8e7de71
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 206 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"@formkit/auto-animate": "^0.8.2",
"@heroicons/react": "^2.1.5",
"@mui/base": "5.0.0-beta.58",
"@next/third-parties": "^14.2.14",
"@next/third-parties": "^14.2.15",
"@tailwindcss/container-queries": "^0.1.1",
"@types/node": "^22.7.5",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@types/react-dom": "^18.3.1",
"algoliasearch": "5.8.0",
"autoprefixer": "^10.4.20",
"clsx": "^2.1.1",
Expand All @@ -32,7 +32,7 @@
"graphql-tag": "^2.12.6",
"html-entities": "^2.5.2",
"html-react-parser": "^5.1.18",
"next": "^14.2.14",
"next": "^14.2.15",
"plaiceholder": "^3.0.0",
"postcss": "^8.4.47",
"qs": "^6.13.0",
Expand All @@ -44,9 +44,9 @@
"react-slick": "^0.30.2",
"react-tiny-oembed": "^1.1.0",
"sharp": "^0.33.5",
"tailwind-merge": "^2.5.3",
"tailwind-merge": "^2.5.4",
"tailwindcss": "^3.4.13",
"typescript": "^5.6.2",
"typescript": "^5.6.3",
"usehooks-ts": "^3.1.0"
},
"devDependencies": {
Expand All @@ -55,7 +55,7 @@
"@graphql-codegen/import-types-preset": "^3.0.0",
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
"@graphql-codegen/typescript-operations": "^4.3.0",
"@next/bundle-analyzer": "^14.2.14",
"@next/bundle-analyzer": "^14.2.15",
"@storybook/addon-essentials": "^8.3.5",
"@storybook/addon-interactions": "^8.3.5",
"@storybook/addon-links": "^8.3.5",
Expand All @@ -68,7 +68,7 @@
"concurrently": "^9.0.1",
"encoding": "^0.1.13",
"eslint": "^8.57.1",
"eslint-config-next": "^14.2.14",
"eslint-config-next": "^14.2.15",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-prettier": "^5.2.1",
Expand Down
8 changes: 7 additions & 1 deletion src/components/nodes/pages/sup-book/book-page/book-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ const BookPage = async ({node, ...props}: Props) => {
</div>
)}

{node.supBookCopublisherName && <div className="text-press-sand-dark">{node.supBookCopublisherName}</div>}
{node.supBookPublisher && (
<div className="rs-pb-3 text-press-sand-dark">Published by {node.supBookPublisher}</div>
)}
{node.supBookCopublisherName && (
<div className="rs-pb-3 text-press-sand-dark">{node.supBookCopublisherName}</div>
)}

{node.supBookPubDateCloth?.time && (
<div className="text-18 text-press-sand-dark">
Expand Down Expand Up @@ -177,6 +182,7 @@ const BookPage = async ({node, ...props}: Props) => {
paperIsbn={node.supBookIsbn13Paper}
preorder={node.supBookPreorder}
comingSoon={node.supBookNoCart}
hasIntlCart={node.supBookIntlCart}
/>
</div>

Expand Down
10 changes: 5 additions & 5 deletions src/components/nodes/pages/sup-book/book-page/book-precart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Props = {
usPaperSaleDiscount?: Maybe<number>
clothIsbn?: Maybe<string>
paperIsbn?: Maybe<string>
hasIntlCart?: boolean
hasIntlCart?: Maybe<boolean>
preorder?: Maybe<boolean>
comingSoon?: Maybe<boolean>
}
Expand Down Expand Up @@ -145,10 +145,10 @@ const BookPreCart = ({
{!comingSoon && <ArrowRightIcon width={24} className="transition-all group-hocus:translate-x-2" />}
</Button>

{formatChoice === "cloth" && !isIntl && usClothPrice && usClothSalePrice && (
{!isIntl && usClothPrice && usClothSalePrice && (
<div className="rs-mt-1 text-18">
<div>
List Price: <del className="italic">{formatCurrency(usClothPrice)}</del>
Hardcover List Price: <del className="italic">{formatCurrency(usClothPrice)}</del>
</div>
<div>
Save&nbsp;
Expand All @@ -159,10 +159,10 @@ const BookPreCart = ({
</div>
)}

{formatChoice === "paper" && !isIntl && usPaperPrice && usPaperSalePrice && (
{!isIntl && usPaperPrice && usPaperSalePrice && (
<div className="rs-mt-1 text-18">
<div>
List Price: <del className="italic">{formatCurrency(usPaperPrice)}</del>
Paperback List Price: <del className="italic">{formatCurrency(usPaperPrice)}</del>
</div>
<div>
Save{" "}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const EntityParagraph = async ({paragraph, ...props}: Props) => {
}

const EntityCard = async ({path, headingLevel}: {path: string; headingLevel: "h3" | "h2"}) => {
const queryResponse = await getEntityFromPath<NodeUnion>(path)
const queryResponse = await getEntityFromPath<NodeUnion>(path, false, true)
if (!queryResponse.entity) return
return <NodeCard node={queryResponse.entity} headingLevel={headingLevel} />
}
Expand Down
57 changes: 11 additions & 46 deletions src/lib/gql/__generated__/drupal.d.ts

Large diffs are not rendered by default.

40 changes: 10 additions & 30 deletions src/lib/gql/__generated__/queries.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 3 additions & 25 deletions src/lib/gql/fragments-node.drupal.gql
Original file line number Diff line number Diff line change
Expand Up @@ -45,75 +45,53 @@ fragment FragmentNodeSupBook on NodeSupBook {
supBookAwards {
...FragmentSupAward
}
supBookCatalogMonth
supBookCatalogPage
supBookCatalogSeasonYyyy
supBookClothSalePercent
supBookClothSalePrice
supBookPublisher
supBookCopublisherName
supBookCopublisherYn
supBookCopyright
supBookDescription {
processed
}
supBookDigitalCompLink
supBookExcerpts {
...FragmentParagraphUnion
}
supBookHtmlPageTitle
supBookIllustrations
supBookImage {
...FragmentMediaImage
}
supBookImprint {
...FragmentTermInterface
}
supBookInPrintStatus
supBookInstructorRecommended
supBookIntlCart
supBookIsbn13Alt
supBookIsbn13Cloth
supBookIsbn13Digital
supBookIsbn13Isw
supBookIsbn13Paper
supBookLocalWebBlurb {
processed
}
supBookNewPaperbackYn
supBookPages
supBookPaperSalePercent
supBookPaperSalePrice
supBookPriceCloth
supBookPriceDigital
supBookPricePaper
supBookPrintDeskCopies
supBookPubDateCloth {
...FragmentDateTime
}
supBookPubDateDigital {
...FragmentDateTime
}
supBookPubDateFirst {
...FragmentDateTime
}
supBookPubDatePaper {
...FragmentDateTime
}
supBookPubYearFirst
supBookRelatedTitles {
...FragmentNodeInterface
}
supBookReviews {
processed
}
supBookRightsDescription
supBookSalesRank
supBookSeries {
...FragmentTermInterface
}
supBookStatusCloth
supBookStatusDigital
supBookStatusPaper
supBookSubjects {
__typename
id
Expand All @@ -128,8 +106,6 @@ fragment FragmentNodeSupBook on NodeSupBook {
}
supBookSubtitle
supBookUrlIsw
supBookWebCodeCloth
supBookWebCodePaper
supBookWorkIdNumber
supBookERetailers {
...FragmentLink
Expand Down Expand Up @@ -475,6 +451,8 @@ fragment FragmentNodeStanfordPageTeaser on NodeStanfordPage {
}
suPageBanner {
...FragmentParagraphStanfordBanner
...FragmentParagraphStanfordPageTitleBanner
...FragmentParagraphSupCarousel
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/lib/gql/gql-queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type DrupalClientError = GraphQLError & {
export const getEntityFromPath = cache(
async <T extends NodeUnion | TermUnion>(
path: string,
previewMode?: boolean
previewMode?: boolean,
teaser?: boolean
): Promise<{
entity?: T
redirect?: RouteRedirect["url"]
Expand All @@ -41,7 +42,7 @@ export const getEntityFromPath = cache(
if (path.startsWith("/node/")) return {}

try {
query = await graphqlClient({cache: "no-cache"}, previewMode).Route({path})
query = await graphqlClient({cache: "no-cache"}, previewMode).Route({path, teaser: !!teaser})
} catch (e) {
const messagePrefix = `Error fetching data for path ${path}: `
if (e instanceof ClientError) {
Expand All @@ -59,7 +60,7 @@ export const getEntityFromPath = cache(
query.route?.__typename === "RouteInternal" && query.route.entity ? (query.route.entity as T) : undefined
return {entity, redirect: undefined}
},
["entities", path, previewMode ? "preview" : "anonymous"],
[path, previewMode ? "preview" : "anonymous", teaser ? "teaser" : "full"],
{tags: ["all-entities", `paths:${path}`]}
)

Expand Down
6 changes: 3 additions & 3 deletions src/lib/gql/route-query.drupal.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Query based on the url path string to find the entity that matches. Return the redirect or the entity.
query Route($path: String!) {
query Route($path: String!, $teaser: Boolean = false) {
route(path: $path) {
__typename
... on RouteRedirect {
Expand All @@ -10,8 +10,8 @@ query Route($path: String!) {
}
... on RouteInternal {
entity {
...FragmentNodeUnion
...FragmentTermInterface
...FragmentNodeUnion @skip(if: $teaser)
...FragmentNodeTeaserUnion @include(if: $teaser)
}
}
}
Expand Down
Loading

0 comments on commit 8e7de71

Please sign in to comment.