Skip to content

Commit 809f352

Browse files
committed
fix: šŸ› qr code disappear for projects that have it and new tabs mapping for url params (#818)
1 parent 2e6045d commit 809f352

File tree

3 files changed

+54
-11
lines changed

3 files changed

+54
-11
lines changed

ā€Ž.beads/deletions.jsonlā€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
{"id":"interfacer-gui-9lv.13","ts":"2025-12-11T13:40:28.675257Z","by":"git-history-backfill","reason":"recovered from git history (pruned from manifest)"}
33
{"id":"interfacer-gui-9lv.12","ts":"2025-12-11T13:40:28.681444Z","by":"git-history-backfill","reason":"recovered from git history (pruned from manifest)"}
44
{"id":"interfacer-gui-9lv.14","ts":"2025-12-11T13:40:28.687578Z","by":"git-history-backfill","reason":"recovered from git history (pruned from manifest)"}
5+
{"id":"interfacer-gui-yig.14","ts":"2026-02-06T15:05:42.2713Z","by":"git-history-backfill","reason":"recovered from git history (pruned from manifest)"}

ā€Žcomponents/partials/project/[id]/ProjectTabs.tsxā€Ž

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ const ProjectTabs = () => {
8383
// Map tab IDs to their indices for URL parameter handling
8484
const allTabsMap: Record<string, number> = {
8585
overview: 0,
86-
relationships: 1,
87-
included: 1,
88-
graph: 2,
89-
contributors: 3,
90-
contributions: 4,
91-
dpp: 5,
92-
gc1dpp: 5,
86+
relationships: 0,
87+
included: 0,
88+
graph: 1,
89+
contributors: 2,
90+
contributions: 3,
91+
dpp: 4,
92+
gc1dpp: 4,
9393
};
9494

9595
// Mark page as loaded after client-side mount and check for tab parameter

ā€Žcomponents/partials/project/[id]/sidebar/ContributionsCard.tsxā€Ž

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useQuery } from "@apollo/client";
1+
import { gql, useQuery } from "@apollo/client";
22
import { Button, Card, Stack, Text } from "@bbtgnn/polaris-interfacer";
33
import { ListBoxes, MagicWand } from "@carbon/icons-react";
44
import { useProject } from "components/layout/FetchProjectLayout";
@@ -9,8 +9,42 @@ import { ResourceProposalsQuery, ResourceProposalsQueryVariables } from "lib/typ
99
import { useTranslation } from "next-i18next";
1010
import { useRouter } from "next/router";
1111
import { useProjectTabs } from "pages/project/[id]";
12+
import { useMemo } from "react";
1213
import QRCode from "react-qr-code";
1314

15+
// Query to get traceDpp for extracting DPP service ULID
16+
const QUERY_TRACE_DPP = gql`
17+
query getTraceDpp($id: ID!) {
18+
economicResource(id: $id) {
19+
traceDpp
20+
}
21+
}
22+
`;
23+
24+
// Helper function to recursively find DPP service ULID from traceDpp tree
25+
function extractDppServiceUlid(traceDpp: any[]): string | undefined {
26+
let dppServiceUlid: string | undefined;
27+
28+
function traverse(node: any) {
29+
if (!node || dppServiceUlid) return;
30+
31+
if (node.type === "EconomicResource" && node.node?.metadata?.dppServiceUlid) {
32+
dppServiceUlid = node.node.metadata.dppServiceUlid;
33+
return;
34+
}
35+
36+
if (node.children && Array.isArray(node.children)) {
37+
node.children.forEach(traverse);
38+
}
39+
}
40+
41+
if (Array.isArray(traceDpp)) {
42+
traceDpp.forEach(traverse);
43+
}
44+
45+
return dppServiceUlid;
46+
}
47+
1448
const ContributionsCard = () => {
1549
const { project } = useProject();
1650
const { setSelected } = useProjectTabs();
@@ -25,11 +59,19 @@ const ContributionsCard = () => {
2559
variables: { id: id as string },
2660
}
2761
);
62+
const { data: traceDppData } = useQuery(QUERY_TRACE_DPP, {
63+
variables: { id: project?.id },
64+
skip: !project?.id,
65+
});
2866
const url = window.location.protocol + "//" + window.location.host + `/project/${project.id}?tab=gc1dpp`;
67+
const dppServiceUlid = useMemo(() => {
68+
if (!traceDppData?.economicResource?.traceDpp) return undefined;
69+
return extractDppServiceUlid(traceDppData.economicResource.traceDpp);
70+
}, [traceDppData]);
71+
const dppUlid = dppServiceUlid || project.metadata?.dpp;
72+
const showDppQr = project.conformsTo?.name === "Product" && !!dppUlid;
2973

3074
const contributionsCount = contributions?.proposals.edges.length || 0;
31-
const isProduct = project.conformsTo?.name === "Product";
32-
const hasDpp = !!project.metadata?.dpp;
3375

3476
return (
3577
<Card sectioned>
@@ -72,7 +114,7 @@ const ContributionsCard = () => {
72114
>
73115
{t("Make a contribution")}
74116
</Button>
75-
{isProduct && hasDpp && (
117+
{showDppQr && (
76118
<>
77119
<Text as="h2" variant="headingMd">
78120
{t("DPP QR-Code")}

0 commit comments

Comments
Ā (0)