Skip to content

Commit

Permalink
Merge pull request #1830 from ResearchHub/bounties
Browse files Browse the repository at this point in the history
Bounties page
  • Loading branch information
yattias authored Sep 13, 2024
2 parents 9a0ef95 + 5bf6f01 commit 722d1c5
Show file tree
Hide file tree
Showing 6 changed files with 501 additions and 11 deletions.
2 changes: 1 addition & 1 deletion components/Author/AuthorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const CondensedAuthorList = ({
) : (
<span>{authorName}</span>
)}
{idx < primaryAuthors.length - 1 && <>,</>}
{idx < primaryAuthors.length - 1 && <>, </>}
</>
))}
{showEtAllText && <>, et al.</>}
Expand Down
21 changes: 12 additions & 9 deletions components/Bounty/api/fetchBountiesAPI.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import API from "~/config/api";
import { buildApiUri } from "~/config/utils/buildApiUri";
import API, { generateApiUrl } from "~/config/api";
import { Helpers } from "@quantfive/js-web-config";
import { PaginatedApiResponse } from "~/config/types/root_types";

type Args = {
onError: (error: Error) => void;
onSuccess: (response: any) => void;
personalized?: boolean;
page?: number;
};

export const fetchBounties = ({ onError, onSuccess, page }: Args): void => {
fetch(buildApiUri({ apiPath: "bounty/get_bounties" }), API.GET_CONFIG())
export const fetchBounties = ({ personalized = true, page }: Args): Promise<PaginatedApiResponse> => {
const url = generateApiUrl(`bounty`) + (personalized ? `?personalized=true` : '');

return fetch(url, API.GET_CONFIG())
.then(Helpers.checkStatus)
.then(Helpers.parseJSON)
.then((res: any): void => onSuccess({ res }))
.catch(onError);
};
.then((res: any) => {
return res;
})
};

1 change: 1 addition & 0 deletions components/Home/sidebar/RootLeftSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ function RootLeftSidebar({
"hubs",
"referral",
"search",
"bounties",
"user",
"author",
].includes(pathname.split("/")[1]) !== true;
Expand Down
2 changes: 1 addition & 1 deletion config/types/contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export const parseBountyContributionItem = (
),
id: raw.id,
createdDate: raw.created_date,
amount: formatBountyAmount({ amount: raw.item.amount }),
amount: formatBountyAmount({ amount: raw.item.amount || raw.item }),
content: raw?.item?.item?.comment_content_json,
...(raw.item.bounty_parent && {
parent: new Bounty(raw.item.bounty_parent),
Expand Down
7 changes: 7 additions & 0 deletions config/types/root_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export type UnifiedDocument = {
documentType: RhDocumentType;
id: ID;
isRemoved: boolean;
authors: Array<AuthorProfile>;
};

export type OrcidConnect = {
Expand Down Expand Up @@ -233,6 +234,7 @@ export const parseOrganization = (raw: any): Organization => {
};

export const parseUnifiedDocument = (raw: any): UnifiedDocument => {

if (typeof raw !== "object") {
return raw;
}
Expand Down Expand Up @@ -270,6 +272,11 @@ export const parseUnifiedDocument = (raw: any): UnifiedDocument => {
parsed.document["body"] = unparsedInnerDoc.renderable_text;
}

if (unparsedInnerDoc.authors) {
parsed["authors"] = unparsedInnerDoc.authors.map(parseAuthorProfile);
}


// @ts-ignore
return parsed;
};
Expand Down
Loading

0 comments on commit 722d1c5

Please sign in to comment.