Skip to content

Commit

Permalink
Further fixes after CR
Browse files Browse the repository at this point in the history
  • Loading branch information
JanJaroszczak committed Jan 31, 2024
1 parent 0d69bb9 commit 5190a6f
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 69 deletions.
8 changes: 3 additions & 5 deletions src/vva-fe/src/components/molecules/GovernanceActionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
>
<Box data-testid="governance-action-type">
<Typography color="neutralGray" variant="caption">
{t("govActions.type")}
{t("govActions.governanceActionType")}
</Typography>
<Box display={"flex"}>
<Box
Expand All @@ -122,7 +122,7 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
</Box>
<Box mt={5}>
<Typography color="neutralGray" variant="caption">
{t("govActions.id")}
{t("govActions.governanceActionId")}
</Typography>
<Box display={"flex"} mt={0.25}>
<Box
Expand Down Expand Up @@ -237,9 +237,7 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
}}
data-testid={`govaction-${govActionId}-view-detail`}
>
{inProgress
? t("seeTransaction")
: t("govActions.viewProposalDetails")}
{t(inProgress ? "seeTransaction" : "govActions.viewProposalDetails")}
</Button>
</Box>
</Box>
Expand Down
4 changes: 2 additions & 2 deletions src/vva-fe/src/components/molecules/GovernanceVotedOnCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const GovernanceVotedOnCard = ({ votedProposal, inProgress }: Props) => {
>
<Box data-testid="governance-action-type">
<Typography color={"#8E908E"} variant="caption">
{t("govActions.type")}
{t("govActions.governanceActionType")}
</Typography>
<Box display={"flex"}>
<Box
Expand All @@ -119,7 +119,7 @@ export const GovernanceVotedOnCard = ({ votedProposal, inProgress }: Props) => {
</Box>
<Box mt={5}>
<Typography color={"#8E908E"} variant="caption">
{t("govActions.id")}
{t("govActions.governanceActionId")}
</Typography>
<Box display={"flex"} mt={0.5}>
<Box
Expand Down
24 changes: 12 additions & 12 deletions src/vva-fe/src/components/molecules/VoteActionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const VoteActionForm = ({
const renderCancelButton = useMemo(() => {
return (
<Button
data-testid={"cancel-button"}
data-testid="cancel-button"
onClick={() => setValue("vote", state.vote)}
variant="outlined"
size="extraLarge"
Expand All @@ -74,7 +74,7 @@ export const VoteActionForm = ({
const renderChangeVoteButton = useMemo(() => {
return (
<LoadingButton
data-testid={"change-vote"}
data-testid="change-vote"
onClick={confirmVote}
disabled={
(!areFormErrors && voteFromEP === vote) ||
Expand All @@ -96,7 +96,7 @@ export const VoteActionForm = ({
}, [confirmVote, areFormErrors, vote]);

return (
<Box flex={1} display="flex" flexDirection="column" width={"full"}>
<Box flex={1} display="flex" flexDirection="column" width="full">
<Box
flex={1}
display="flex"
Expand Down Expand Up @@ -142,7 +142,7 @@ export const VoteActionForm = ({
</Box>
{dRep?.isRegistered && (
<Button
data-testid={"show-votes-button"}
data-testid="show-votes-button"
variant="text"
size="large"
sx={{ mt: 3 }}
Expand Down Expand Up @@ -198,33 +198,33 @@ export const VoteActionForm = ({
</p>
</Box>
{isContext && (
<Box display={"flex"} flexDirection={"column"} flex={1}>
<Box display="flex" flexDirection="column" flex={1}>
<Input
control={control}
dataTestId="url-input"
errorMessage={errors.url?.message}
formFieldName="url"
placeholder={t("forms.urlWithContextPlaceholder")}
width={"100%"}
width="100%"
/>
<Input
control={control}
dataTestId="hash-input"
errorMessage={errors.hash?.message}
formFieldName="hash"
placeholder={t("forms.hashPlaceholder")}
width={"100%"}
width="100%"
/>
<Link
data-testid={"how-to-create-link"}
data-testid="how-to-create-link"
onClick={() =>
openInNewTab(
"https://docs.sanchogov.tools/faqs/how-to-create-a-metadata-anchor"
)
}
mb={isMobile ? 2 : 8}
sx={{ cursor: "pointer" }}
textAlign={"center"}
textAlign="center"
visibility={!isContext ? "hidden" : "visible"}
>
<Typography color="primary" fontWeight={400} variant="body2">
Expand All @@ -247,17 +247,17 @@ export const VoteActionForm = ({
{(state?.vote && state?.vote !== vote) ||
(voteFromEP && voteFromEP !== vote) ? (
<Box
display={"flex"}
display="flex"
flexDirection={isMobile ? "column" : "row"}
justifyContent={"space-between"}
justifyContent="space-between"
>
{isMobile ? renderChangeVoteButton : renderCancelButton}
<Box px={1} py={isMobile ? 1.5 : 0} />
{isMobile ? renderCancelButton : renderChangeVoteButton}
</Box>
) : (
<Button
data-testid={"vote-button"}
data-testid="vote-button"
variant="contained"
disabled={
!vote ||
Expand Down
68 changes: 38 additions & 30 deletions src/vva-fe/src/components/organisms/DashboardCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,42 @@ export const DashboardCards = () => {
formHexToBech32,
]);

const getRegistrationCardDescription = () => {
if (registerTransaction.transactionHash) {
switch (registerTransaction.type) {
case "retirement":
return t("dashboard.registration.retirementInProgress");
case "registration":
return t("dashboard.registration.registrationInProgress");
default:
return t("dashboard.registration.metadataUpdateInProgress");
}
} else if (dRep?.isRegistered || dRep?.wasRegistered) {
return t("dashboard.registration.holdersCanDelegate");
} else {
return t("dashboard.registration.ifYouWant");
}
};

const getRegistrationCardTitle = () => {
if (registerTransaction?.transactionHash) {
switch (registerTransaction.type) {
case "retirement":
return t("dashboard.registration.dRepRetirement");
case "registration":
return t("dashboard.registration.dRepRegistration");
default:
return t("dashboard.registration.dRepUpdate");
}
} else if (dRep?.isRegistered) {
return t("dashboard.registration.youAreRegistered");
} else if (dRep?.wasRegistered) {
return t("dashboard.registration.registerAgain");
} else {
return t("dashboard.registration.registerAsDRep");
}
};

const renderGovActionSection = useCallback(() => {
return (
<>
Expand Down Expand Up @@ -340,21 +376,7 @@ export const DashboardCards = () => {
? "change-metadata-button"
: "register-learn-more-button"
}
description={t(
`dashboard.registration.${
registerTransaction.transactionHash
? registerTransaction?.type === "retirement"
? "retirementInProgress"
: registerTransaction?.type === "registration"
? "registrationInProgress"
: "metadataUpdateInProgress"
: dRep?.isRegistered
? "holdersCanDelegate"
: dRep?.wasRegistered
? "holdersCanDelegate"
: "ifYouWant"
}`
)}
description={getRegistrationCardDescription()}
firstButtonAction={
dRep?.isRegistered
? retireAsDrep
Expand Down Expand Up @@ -394,21 +416,7 @@ export const DashboardCards = () => {
cardTitle={
dRep?.isRegistered || dRep?.wasRegistered ? t("myDRepId") : ""
}
title={t(
`dashboard.registration.${
registerTransaction?.transactionHash
? registerTransaction?.type === "retirement"
? "dRepRetirement"
: registerTransaction?.type === "registration"
? "dRepRegistration"
: "dRepUpdate"
: dRep?.isRegistered
? "youAreRegistered"
: dRep?.wasRegistered
? "registerAgain"
: "registerAsDRep"
}`
)}
title={getRegistrationCardTitle()}
/>
</Box>
{!dRep?.isRegistered && renderGovActionSection()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const DashboardGovernanceActionsVotedOn = ({
</Typography>
) : !filteredData?.length ? (
<Typography py={4} fontWeight="300">
{t("govActions.noResults")}
{t("govActions.noResultsForTheSearch")}
</Typography>
) : (
<>
Expand Down
12 changes: 5 additions & 7 deletions src/vva-fe/src/components/organisms/ExternalLinkModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ export function ExternalLinkModal() {
style={{ height: "84px", margin: "0 auto", width: "84px" }}
/>
<ModalHeader sx={{ marginTop: "34px" }}>
{isMobile
? t("modals.externalLink.safety")
: t("modals.externalLink.beCareful")}
{t(`modals.externalLink.${isMobile ? "safety" : "beCareful"}`)}
</ModalHeader>
<ModalContents>
<Typography textAlign="center" sx={{ fontSize: "16px" }}>
{isMobile
? t("modals.externalLink.thisIs")
: t("modals.externalLink.youAreAboutToOpen")}
{t(
`modals.externalLink.${isMobile ? "thisIs" : "youAreAboutToOpen"}`
)}
</Typography>
<Typography
textAlign="center"
Expand Down Expand Up @@ -80,7 +78,7 @@ export function ExternalLinkModal() {
}}
variant="contained"
>
{isMobile ? t("continue") : t("modals.externalLink.continueTo")}
{t(`${isMobile ? "continue" : "modals.externalLink.continueTo"}`)}
</Button>
<Button
data-testid={"cancel-modal-button"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const GovernanceActionDetailsCard = ({
<Box flex={1} mt={3}>
<Box>
<Typography color="neutralGray" variant="caption">
{t("govActions.type")}
{t("govActions.governanceActionType")}
</Typography>
<Box display={"flex"}>
<Box mt={1} px={2} py={1} bgcolor="lightBlue" borderRadius={100}>
Expand All @@ -144,7 +144,7 @@ export const GovernanceActionDetailsCard = ({
</Box>
<Box mt={4}>
<Typography color="neutralGray" variant="caption">
{t("govActions.id")}
{t("govActions.governanceActionId")}
</Typography>
<Box display="flex">
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const GovernanceActionsToVote = ({
<>
{!mappedData.length ? (
<Typography fontWeight={300} sx={{ py: 4 }}>
{t("govActions.noResults")}
{t("govActions.noResultsForTheSearch")}
</Typography>
) : (
<>
Expand Down
16 changes: 10 additions & 6 deletions src/vva-fe/src/context/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,15 @@ function CardanoProvider(props: Props) {
resetRegisterTransaction();
if (isEnabled)
addErrorAlert(
registerTransaction.type === "retirement"
? t("alerts.retirement.failed")
: registerTransaction.type === "registration"
? t("alerts.registration.failed")
: t("alerts.metadataUpdate.failed")
t(
`alerts.${
registerTransaction.type === "retirement"
? "retirement.failed"
: registerTransaction.type === "registration"
? "registration.failed"
: "metadataUpdate.failed"
}`
)
);
}
};
Expand Down Expand Up @@ -587,7 +591,7 @@ function CardanoProvider(props: Props) {
.to_hex();
});
} else {
console.log(t("warnings.usingUnregisteredStakeKeys"));
console.warn(t("warnings.usingUnregisteredStakeKeys"));
stakeKeysList = unregisteredStakeKeysList.map((stakeKey) => {
const stakeKeyHash = PublicKey.from_hex(stakeKey).hash();
const stakeCredential = Credential.from_keyhash(stakeKeyHash);
Expand Down
6 changes: 3 additions & 3 deletions src/vva-fe/src/translations/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,17 @@ export const en = {
expiryDate: "Expiry date:",
filterTitle: "Governance Action Type",
forGovAction: "for this Governance Action",
id: "Governance Action ID:",
governanceActionId: "Governance Action ID:",
governanceActionType: "Governance Action Type:",
myVote: "My Vote:",
noResults: "No results for the search.",
noResultsForTheSearch: "No results for the search.",
optional: "(optional)",
provideContext: "Provide context about your vote",
selectDifferentOption: "Select a different option to change your vote",
showVotes: "Show votes",
submissionDate: "Submission date:",
title: "Governance Actions",
toVote: "To vote",
type: "Governance Action Type:",
viewOtherDetails: "View other details",
viewProposalDetails: "View proposal details",
vote: "Vote",
Expand Down

0 comments on commit 5190a6f

Please sign in to comment.