Skip to content

Commit

Permalink
Fix: default matomo siteId and multiple winners (#588)
Browse files Browse the repository at this point in the history
* fix: open terms and package.json details

* fix: open github commit from current version

* feat: set matomo env vars

* feat: parse matomo project id

* feat: add trackEvents

* feat: set VITE_MATOMO_PROJECT_ID 1 by default

* fix: remove debugs

* fix: update status page

* feat: multiple winners
  • Loading branch information
jimcase authored Sep 23, 2024
1 parent f26badf commit 7762d57
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 37 deletions.
2 changes: 1 addition & 1 deletion ui/summit-2024/src/common/constants/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const MATOMO_BASE_URL =
const MATOMO_PROJECT_ID =
window._env_?.VITE_MATOMO_PROJECT_ID ||
import.meta.env.VITE_MATOMO_PROJECT_ID ||
"0";
"1";
const DISCORD_CHANNEL_URL =
window._env_?.VITE_DISCORD_CHANNEL_URL ||
import.meta.env.VITE_DISCORD_CHANNEL_URL;
Expand Down
2 changes: 1 addition & 1 deletion ui/summit-2024/src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const Footer = () => {
</span>
(
<Link
href="https://status.voting.summit.cardano.org/"
href="https://status2024.voting.summit.cardano.org"
target="_blank"
rel="noopener"
sx={{
Expand Down
17 changes: 10 additions & 7 deletions ui/summit-2024/src/pages/Categories/components/ViewReceipt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
setVoteReceipt,
setVotes,
} from "../../../store/reducers/votesCache";
import { copyToClipboard } from "../../../utils/utils";
import { copyToClipboard, resolveCardanoNetwork } from "../../../utils/utils";
import { getUserInSession, tokenIsExpired } from "../../../utils/session";
import {
getVoteReceipt,
Expand All @@ -31,6 +31,8 @@ import { eventBus, EventName } from "../../../utils/EventBus";
import { ToastType } from "../../../components/common/Toast/Toast.types";
import { parseError } from "../../../common/constants/errors";
import { verifyVote } from "../../../common/api/verificationService";
import { env } from "../../../common/constants/env";
import { NetworkType } from "../../../components/ConnectWalletList/ConnectWalletList.types";

const ViewReceipt: React.FC<ViewReceiptProps> = ({ categoryId, close }) => {
const session = getUserInSession();
Expand Down Expand Up @@ -77,10 +79,11 @@ const ViewReceipt: React.FC<ViewReceiptProps> = ({ categoryId, close }) => {

const viewOnChainVote = () => {
if (receipt?.merkleProof?.transactionHash) {
window.open(
`https://preprod.cardanoscan.io/transaction/${receipt?.merkleProof?.transactionHash}`,
"_blank",
);
let url = `https://explorer.cardano.org/transaction?id=${receipt?.merkleProof?.transactionHash}`;
if (resolveCardanoNetwork(env.TARGET_NETWORK) === NetworkType.TESTNET) {
url = `https://preprod.cardanoscan.io/transaction/${receipt?.merkleProof?.transactionHash}`;
}
window.open(url, "_blank");
}
};

Expand Down Expand Up @@ -204,7 +207,7 @@ const ViewReceipt: React.FC<ViewReceiptProps> = ({ categoryId, close }) => {
),
title: "In Progress",
description:
"Your transaction has been sent and is awaiting confirmation from the Cardano network (this could be 5-10 minutes). Once this has been confirmed youll be able to verify your vote.",
"Your transaction has been sent and is awaiting for the event's grace period to finish. Once it ends you'll be able to verify your vote.",
iconBottom: (
<RefreshIcon
sx={{
Expand Down Expand Up @@ -260,7 +263,7 @@ const ViewReceipt: React.FC<ViewReceiptProps> = ({ categoryId, close }) => {
),
title: "In Progress",
description:
"Your transaction has been sent and is awaiting confirmation from the Cardano network (this could be 5-10 minutes). Once this has been confirmed youll be able to verify your vote.",
"Your transaction has been sent and is awaiting for the event's grace period to finish. Once it ends you'll be able to verify your vote.",
iconBottom: (
<RefreshIcon
sx={{
Expand Down
70 changes: 42 additions & 28 deletions ui/summit-2024/src/pages/Categories/components/Winners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ const Winners: React.FC<WinnersProps> = ({
(v) => v.categoryId === categoryId,
)?.proposalId;

let nominees =
const nominees =
extendedCategoryData.find((c) => c.id === categoryId)?.proposals || [];
const winner = nominees[0];
nominees.shift();

const maxVotes = Math.max(...nominees.map((n) => n.votes || 0));
const winners = nominees.filter((n) => n.votes === maxVotes);
const remainingNominees = nominees.filter((n) => n.votes !== maxVotes);

useEffect(() => {
getVotingResults().then((response) => {
Expand Down Expand Up @@ -169,7 +171,7 @@ const Winners: React.FC<WinnersProps> = ({
zIndex: 3,
}}
>
{votedFor === winner.id ? (
{winners.find((w) => w.id === votedFor) ? (
<TickIcon circleSize={28} tickSize={20} />
) : null}
</Box>
Expand All @@ -188,32 +190,45 @@ const Winners: React.FC<WinnersProps> = ({
marginBottom: "40px",
}}
>
Winner!
Winner
{winners.length > 1 ? "s" : ""}!
</Typography>
<Box component="div" display="flex" justifyContent="center" mt={2}>
<img src={awardImg} alt="Placeholder" height={148} />
</Box>
<Typography
onClick={(event: React.MouseEvent<HTMLDivElement, MouseEvent>) =>
handleLearnMoreClick(event, "")
}
align="center"
<Box
component="div"
display="flex"
justifyContent="center"
mt={2}
sx={{
color: theme.palette.text.neutralLightest,
textAlign: "center",
textShadow: "0px 0px 12px rgba(18, 18, 18, 0.20)",
fontFamily: "Dosis",
fontSize: "28px",
fontStyle: "normal",
fontWeight: 700,
lineHeight: "32px",
marginTop: "40px",
cursor: "pointer",
marginBottom: "30px",
}}
>
{winner?.name}
</Typography>
<img src={awardImg} alt="Placeholder" height={148} />
</Box>
{winners.map((winner) => {
return (
<Typography
onClick={(event: React.MouseEvent<HTMLDivElement, MouseEvent>) =>
handleLearnMoreClick(event, "")
}
align="center"
mt={2}
sx={{
color: theme.palette.text.neutralLightest,
textAlign: "center",
textShadow: "0px 0px 12px rgba(18, 18, 18, 0.20)",
fontFamily: "Dosis",
fontSize: "28px",
fontStyle: "normal",
fontWeight: 700,
lineHeight: "32px",
marginTop: "10px",
cursor: "pointer",
}}
>
{winner?.name}
</Typography>
);
})}
<Box
component="div"
sx={{
Expand Down Expand Up @@ -275,10 +290,9 @@ const Winners: React.FC<WinnersProps> = ({
marginTop: "4px",
}}
>
{winner?.votes}
{winners[0].votes}
</Typography>
</Box>

<Box
component="div"
sx={{
Expand Down Expand Up @@ -421,7 +435,7 @@ const Winners: React.FC<WinnersProps> = ({
</TableRow>
</TableHead>
<TableBody>
{nominees?.map((nominee, index) => (
{remainingNominees?.map((nominee, index) => (
<TableRow
key={index}
sx={{
Expand Down

0 comments on commit 7762d57

Please sign in to comment.