Skip to content

Commit

Permalink
Show products in member pages (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Dec 16, 2021
1 parent 63037c9 commit 54ae1c7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gatsby/lobid/src/components/member.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import md5 from 'md5';
import Header from "./header.html";
import Footer from "./footer.html";
import Publications from "./publications.html";
import Products from "./products.html";

import "./css/lobid.css";
import "./css/bootstrap.min.css";
Expand Down Expand Up @@ -66,6 +67,8 @@ export class Member extends React.Component {
<img alt={this.props.member.name.label} id="index-image" src={this.props.member.image || `https://gravatar.com/avatar/${md5(this.props.member.email)}?s=300&d=identicon`} />
</div>
</div>
<p className="lead">{this.props.makesOfferName}</p>
<Products products={this.props.products} lang={this.props.lang}/>
<Publications pubs={this.props.pubs} publications={this.props.publications} />
<Footer companyDetails={this.props.companyDetails} privacy={this.props.privacy} />
</div>
Expand Down
24 changes: 24 additions & 0 deletions gatsby/lobid/src/components/products.html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import { getImage, simpleId } from './helpers.js'

export default class Products extends React.Component {
render() {
return (
<div className="container">
{this.props.products.map((product) =>
<div key={product.id}>
{getImage(product.id, product.image)}
<p className="details">
<a href={"/product/" + simpleId(product.id)}>
{product.name && product.name[this.props.lang]}
</a>
<br />
{(product.slogan && product.slogan[this.props.lang]) || (product.name && product.name[this.props.lang])}
</p>
</div>
)}
<p />
</div>
);
}
}
26 changes: 26 additions & 0 deletions gatsby/lobid/src/templates/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export default function MemberPage({ data, location, pageContext }) {
const member = data.allFile.edges[0].node.childTeamJson
return (<Member
member={member}
products={data.allProductJson.edges
.map(edge => edge.node)
.filter(p => p.membership.find(m => m.member.id === member.id))
}
pubs={data.allPublicationJson.edges
.map(edge => edge.node)
.filter(p => p.creator.find(c => c.id === member.id))
Expand All @@ -22,6 +26,7 @@ export default function MemberPage({ data, location, pageContext }) {
companyDetails="Impressum"
privacy="Datenschutz"
contactPointId="mailto:[email protected]"
lang="de"
/>);
}

Expand Down Expand Up @@ -66,5 +71,26 @@ export const query = graphql`
}
}
}
allProductJson {
edges {
node {
id
image
name {
de
en
}
slogan {
de
en
}
membership {
member {
id
}
}
}
}
}
}
`;

0 comments on commit 54ae1c7

Please sign in to comment.