on master help sign in
application: rewrite to show related grant cards using GrantPreview
18db385Matilde Park
pages/applications/[[...application]].js+13−11
@@ -19,9 +19,10 @@ import Gateway404 from "../../components/gateway/Gateway404";
19import MetadataBlock from "../../components/gateway/MetadataBlock";
19import MetadataBlock from "../../components/gateway/MetadataBlock";
20import MetadataLink from "../../components/gateway/MetadataLink";
20import MetadataLink from "../../components/gateway/MetadataLink";
21import Description from "../../components/gateway/Description";
21import Description from "../../components/gateway/Description";
22−import { getGrantByShortcode } from "../../lib/lib";
22+import { getGrantsByShortcode } from "../../lib/lib";
23+import GrantPreview from "../../components/GrantPreview";
23
24
24−const ApplicationPage = ({ data, markdown, organisation, matchedGrant, search, params }) => {
25+const ApplicationPage = ({ data, markdown, organisation, matchedGrants, search, params }) => {
25 const { application } = params;
26 const { application } = params;
26 if (!ob.isValidPatp(application[0])) {
27 if (!ob.isValidPatp(application[0])) {
27 return <Gateway404 type="application" />;
28 return <Gateway404 type="application" />;
@@ -103,19 +104,19 @@ const ApplicationPage = ({ data, markdown, organisation, matchedGrant, search, p
103 className="basis-1/2 sm:basis-1/4"
104 className="basis-1/2 sm:basis-1/4"
104 content={data.shortcode ? data.shortcode : data.title}
105 content={data.shortcode ? data.shortcode : data.title}
105 />
106 />
106− {matchedGrant && <div className="basis-full flex flex-col space-y-1">
107− <p className="font-semibold text-wall-400">Grant Proposal</p>
108− <Link href={`/grants/${matchedGrant}`} passHref>
109− <a className="text-green-400 font-medium">urbit.org/grants/{matchedGrant}
110− </a>
111− </Link>
112− </div>}
113 </div>
107 </div>
114 <Description
108 <Description
115 description={data.description}
109 description={data.description}
116 fallback="An application on Urbit."
110 fallback="An application on Urbit."
117 markdown={markdown}
111 markdown={markdown}
118 />
112 />
113+ <hr className="text-wall-200" />
114+ {matchedGrants && <div className="basis-full flex flex-col space-y-2">
115+ <p className="font-semibold text-wall-400">Related Grants</p>
116+ {matchedGrants.map((grant) => {
117+ return <GrantPreview grant={grant} />
118+ })}
119+ </div>}
119
120
120 <div class="bg-wall-100 py-4 px-6 border-2 border-wall-200 rounded-xl">
121 <div class="bg-wall-100 py-4 px-6 border-2 border-wall-200 rounded-xl">
121 <p class="text-sm text-wall-400">
122 <p class="text-sm text-wall-400">
@@ -180,7 +181,8 @@ export const getServerSideProps = async ({ params, res }) => {
180 ? JSON.stringify(Markdown.parse({ post: { content } }))
181 ? JSON.stringify(Markdown.parse({ post: { content } }))
181 : null;
182 : null;
182
183
183− const matchedGrant = getGrantByShortcode(params.application) || null;
184+ const matchedGrants = getGrantsByShortcode(params.application) || null;
185+
184 if (!data.title) {
186 if (!data.title) {
185 data = {
187 data = {
186 title: params.application?.join("/"),
188 title: params.application?.join("/"),
@@ -193,7 +195,7 @@ export const getServerSideProps = async ({ params, res }) => {
193 data,
195 data,
194 markdown,
196 markdown,
195 organisation,
197 organisation,
196− matchedGrant,
198+ matchedGrants,
197 params,
199 params,
198 },
200 },
199 };
201 };