Skip to content

Commit

Permalink
Refactor author claim case to not use authorship
Browse files Browse the repository at this point in the history
  • Loading branch information
yattias committed Aug 22, 2024
1 parent 008ff73 commit e04be39
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 40 deletions.
25 changes: 4 additions & 21 deletions components/Author/Profile/AuthorPublications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { css, StyleSheet } from "aphrodite";
import { useEffect, useState } from "react";
import {
UnifiedCard,
getDocumentCard,
} from "~/components/UnifiedDocFeed/utils/getDocumentCard";
import AddPublicationsModal from "~/components/Publication/AddPublicationsModal";
import { ROUTES as WS_ROUTES } from "~/config/ws";
Expand All @@ -31,12 +30,6 @@ import {
getFEUnifiedDocType,
} from "~/config/utils/getUnifiedDocType";
import FeedCard from "../Tabs/FeedCard";
import {
Authorship,
parseGenericDocument,
parsePaper,
} from "~/components/Document/lib/types";
import MoreHoriz from "@mui/icons-material/MoreHoriz";
import ClaimRewardsModal from "~/components/ResearchCoin/ClaimRewardsModal";
import ClaimRewardsButton from "~/components/shared/ClaimRewardsButton";
import { getRewardsEligibilityInfo } from "~/components/ResearchCoin/lib/rewardsUtil";
Expand All @@ -48,8 +41,6 @@ import { MessageActions } from "~/redux/message";
import { useAlert } from "react-alert";
import { Tooltip } from "@mui/material";
import VerifyIdentityModal from "~/components/Verification/VerifyIdentityModal";
import { faLongArrowDown } from "@fortawesome/pro-regular-svg-icons";
import { ClipLoader } from "react-spinners";
import LoadMore from "~/components/shared/LoadMore";
import SearchEmpty from "~/components/Search/SearchEmpty";
import { breakpoints } from "~/config/themes/screen";
Expand Down Expand Up @@ -77,20 +68,17 @@ const AuthorPublications = ({
isOpen: boolean;
paperId: string | null;
paperTitle: string;
authorship: Authorship | null;
}>({
isOpen: false,
paperId: null,
paperTitle: "",
authorship: null,
});

const resetRewardsModalState = () => {
setRewardsModalState({
isOpen: false,
paperId: null,
paperTitle: "",
authorship: null,
});
};

Expand All @@ -103,6 +91,8 @@ const AuthorPublications = ({
setFullAuthorProfile,
setIsLoadingPublications,
isLoadingPublications,
summaryStats,
setSummaryStats,
} = authorProfileContext();

useEffect(() => {
Expand Down Expand Up @@ -174,7 +164,6 @@ const AuthorPublications = ({
paperId={rewardsModalState.paperId}
isOpen={rewardsModalState.isOpen}
paperTitle={rewardsModalState.paperTitle}
authorship={rewardsModalState.authorship}
closeModal={() => resetRewardsModalState()}
/>

Expand Down Expand Up @@ -355,10 +344,9 @@ const AuthorPublications = ({
...publicationsResponse,
};

fullAuthorProfile.summaryStats.worksCount =
fullAuthorProfile.summaryStats.worksCount - 1;
setFullAuthorProfile({ ...fullAuthorProfile });
summaryStats.worksCount = summaryStats.worksCount - 1
setPublicationsResponse(updatedResponse);
setSummaryStats({ ...summaryStats });
})
.catch(() => {
dispatch(
Expand Down Expand Up @@ -389,11 +377,6 @@ const AuthorPublications = ({
setRewardsModalState({
paperId: targetDoc.id,
paperTitle: targetDoc.title,
authorship:
authors.find(
(author) =>
author.id === fullAuthorProfile.id
) || null,
isOpen: true,
});
}}
Expand Down
20 changes: 9 additions & 11 deletions components/Author/Tabs/FeedCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { PaperActions } from "~/redux/paper";
import {
AuthorProfile,
RhDocumentType,
UnifiedDocument,
} from "~/config/types/root_types";
import { useState, useEffect, SyntheticEvent } from "react";
import colors, {
Expand All @@ -41,7 +40,6 @@ import ContentBadge from "~/components/ContentBadge";
import { useRouter } from "next/router";
import Link from "next/link";
import {
Authorship,
Paper,
Post,
parsePaper,
Expand Down Expand Up @@ -304,8 +302,6 @@ function FeedCard({
numOfVisibleHubs--;
}

console.log('authors', authors)

return (
<div
className={css(
Expand Down Expand Up @@ -388,13 +384,15 @@ function FeedCard({
}
}}
>
{authors.map((author) => (
<Tooltip title={author.firstName + " " + author.lastName}>
<Avatar src={author.profileImage} sx={{ width: 22, height: 22, fontSize: 13, }}>
{isEmpty(author.profileImage) && (author.firstName || "")[0]}
</Avatar>
</Tooltip>
))}
{authors.map((author) => {
return (
<Tooltip title={author.firstName + " " + author.lastName}>
<Avatar src={author.profileImage} sx={{ width: 22, height: 22, fontSize: 13, }}>
{isEmpty(author.profileImage) && (author.firstName || "")[0]}
</Avatar>
</Tooltip>
)
})}
</AvatarGroup>
</div>

Expand Down
2 changes: 1 addition & 1 deletion components/Notifications/NotificationEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const NotificationEntry = (props) => {
if (notification_type === "IDENTITY_VERIFICATION_UPDATED") {
return "Congratulations! Your account has been verified by the ResearchHub team. ";
} else if (notification_type === "PAPER_CLAIM_PAYOUT") {
return "Congratulations! You claim has been approved and RSC has been awarded to your account.";
return "Congratulations! Your claim has been approved and RSC has been awarded to your account.";
} else if (notification_type === "PUBLICATIONS_ADDED") {
return (
<div style={{ display: "flex", flexDirection: "column" }}>
Expand Down
4 changes: 0 additions & 4 deletions components/ResearchCoin/ClaimRewardsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import { submitRewardsClaim, fetchEligiblePaperRewards } from "./lib/api";
import useCurrentUser from "~/config/hooks/useCurrentUser";
import { ID } from "~/config/types/root_types";
import { Authorship } from "../Document/lib/types";
import { RewardSummary, parseRewardSummary } from "./lib/types";
import ClaimRewardSummary from "./lib/ClaimRewardSummary";
import FormInput from "../Form/FormInput";
Expand All @@ -29,7 +28,6 @@ interface Props {
isOpen: boolean;
paperId: ID;
paperTitle: string;
authorship: Authorship | null;
closeModal: () => void;
}

Expand Down Expand Up @@ -128,7 +126,6 @@ const blockStyles = StyleSheet.create({
const ClaimRewardsModal = ({
paperId,
paperTitle,
authorship,
isOpen,
closeModal,
}: Props) => {
Expand Down Expand Up @@ -167,7 +164,6 @@ const ClaimRewardsModal = ({
try {
const response = await submitRewardsClaim({
paperId,
authorshipId: authorship!.id,
userId: currentUser.id,
preregistrationUrl,
openDataUrl,
Expand Down
3 changes: 0 additions & 3 deletions components/ResearchCoin/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { Helpers } from "@quantfive/js-web-config";

interface Props {
paperId: ID;
authorshipId: ID;
userId: ID;
preregistrationUrl?: string | null;
openDataUrl?: string | null;
}

export const submitRewardsClaim = ({
paperId,
authorshipId,
userId,
preregistrationUrl,
openDataUrl,
Expand All @@ -22,7 +20,6 @@ export const submitRewardsClaim = ({
url,
API.POST_CONFIG({
target_paper_id: paperId,
authorship_id: authorshipId,
requestor: userId,
creator: userId,
...(openDataUrl ? {open_data_url: openDataUrl} : {}),
Expand Down

0 comments on commit e04be39

Please sign in to comment.