Skip to content
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

url for workids - not pid yet #938

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/profile/materialRow/MaterialRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useMutate } from "@/lib/api/api";
import PropTypes from "prop-types";
import Icon from "@/components/base/icon";
import IconButton from "@/components/base/iconButton";
import { getWorkUrl } from "@/lib/utils";
import { getBookmarkMaterialUrl } from "@/lib/utils";
import ErrorRow from "../errorRow/ErrorRow";
import useBreakpoint from "@/components/hooks/useBreakpoint";
import { useModal } from "@/components/_modal";
Expand Down Expand Up @@ -394,6 +394,8 @@ const MaterialRow = (props) => {
const orderMutation = useMutate();
const loanMutation = useMutate();

const urlToMaterial = getBookmarkMaterialUrl(creator, title, materialId);

const isMobileSize =
breakpoint === "xs" || breakpoint === "sm" || breakpoint === "md";

Expand Down Expand Up @@ -660,7 +662,7 @@ const MaterialRow = (props) => {
keepVisible: true,
},
}}
href={getWorkUrl(title, creators, workId)}
href={urlToMaterial}
className={styles.blackUnderline}
>
{children}
Expand Down
8 changes: 7 additions & 1 deletion src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function extractCreatorsPrioritiseCorporation(creatorsBeforeFilter) {
creatorsBeforeFilter = [creatorsBeforeFilter];
}
const corporations = creatorsBeforeFilter?.filter(
(creator) => creator.__typename === "Corporation"
(creator) => creator?.__typename === "Corporation"
);

return corporations?.length > 0 ? corporations : creatorsBeforeFilter;
Expand All @@ -61,6 +61,12 @@ export function encodeTitleCreator(title = "", creators = []) {
: encodeString(title);
}

export function getBookmarkMaterialUrl(creatorAsString, title, materialId) {
const creatorsObject = [{ display: creatorAsString }];
// @TODO materialId may be a pid (not workid) - get a pid and url to specific edition
return getWorkUrl(title, creatorsObject, materialId);
}

/**
*
* @param {string} fullTitle
Expand Down