Skip to content

Commit

Permalink
feat(resource-group-description): link RP name to RP website on resou…
Browse files Browse the repository at this point in the history
…rce detail page
  • Loading branch information
yomatters committed Dec 12, 2024
1 parent 4bbb215 commit c8428d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
26 changes: 15 additions & 11 deletions src/resource-group-description.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@ import Icon from "./icon";

export default function ResourceGroupDescription({ infoGroupId }) {
const resourceGroup = useResourceGroup(infoGroupId);
console.log(resourceGroup);
if (!resourceGroup) return;
const { name, description, imageUri, tags } = resourceGroup;
const { name, description, imageUri, organizations, tags } = resourceGroup;
return (
<div class="resource-group-description">
{imageUri ? (
<img class="resource-group-feature-image" src={imageUri} />
) : null}
<h1>{resourceGroup.name}</h1>

{tags
.filter((tag) => tag.tagCategory.name == "Resource Provider")
.map((tag) => (
<p>
<a href="#">
{tag.iconUri ? <Icon alt={tag.name} src={tag.iconUri} /> : null}
{tag.name}
</a>
</p>
))}
{organizations.map((org) => (
<p>
<a href={org.organization_url || "#"}>
{org.organization_favicon_url ? (
<Icon
alt={org.organization_name}
src={org.organization_favicon_url}
/>
) : null}
{org.organization_name}
</a>
</p>
))}
{description ? <p>{description}</p> : null}
<a href="https://allocations.access-ci.org" class="btn secondary lg">
<Icon name="check2-circle" /> Get Started with {name}
Expand Down
15 changes: 8 additions & 7 deletions src/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,16 @@ export const useResourceGroups = () => {
tagCategoryId: feature.feature_category_id,
}));

for (let organization of organizations)
const organizationsMap = {};
for (let organization of organizations) {
tags.push({
tagId: organization.organization_id * -1,
name: organization.organization_name,
tagCategoryId: -1,
iconUri: organization.organization_favicon_url || null,
});
organizationsMap[organization.organization_id] = organization;
}

tags.sort((a, b) => a.name.localeCompare(b.name));

Expand Down Expand Up @@ -161,6 +164,10 @@ export const useResourceGroups = () => {
),
],
resourceCategoryId: group.rollup_feature_ids.includes(137) ? 2 : 1,
accessAllocated: group.rollup_feature_ids.includes(139),
organizations: group.rollup_organization_ids
.map((orgId) => organizationsMap[orgId])
.filter((org) => org),
}))
.sort((a, b) => a.name.localeCompare(b.name));

Expand Down Expand Up @@ -202,12 +209,6 @@ export const useTransform = (
}, responseArray);
};

const makeMap = (items, key) => {
const map = {};
for (let item of items) map[item[key]] = item;
return map;
};

const linkResourceGroups = ({
resourceCategories,
resourceGroups,
Expand Down

0 comments on commit c8428d5

Please sign in to comment.