Only fetch extra headers on template files.
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
|||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from "./Dialog";
|
} from "./Dialog";
|
||||||
import PanelBox from "./PanelBox";
|
import PanelBox from "./PanelBox";
|
||||||
|
import { templates } from '../utils/templates';
|
||||||
|
|
||||||
const Navigation = () => {
|
const Navigation = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -243,27 +244,27 @@ const Navigation = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<PanelBox as="a" href="/develop/1d14e51e2e02dc0a508cb0733767a914">
|
<PanelBox as="a" href={`/develop/${templates.starter}`}>
|
||||||
<Heading>Starter</Heading>
|
<Heading>Starter</Heading>
|
||||||
<Text>Just an empty starter with essential imports</Text>
|
<Text>Just an empty starter with essential imports</Text>
|
||||||
</PanelBox>
|
</PanelBox>
|
||||||
<PanelBox as="a" href="/develop/bcd6d0c0fcbe52545ddb802481ff9d26">
|
<PanelBox as="a" href={`/develop/${templates.starter}`}>
|
||||||
<Heading>Firewall</Heading>
|
<Heading>Firewall</Heading>
|
||||||
<Text>This Hook essentially checks a blacklist of accounts</Text>
|
<Text>This Hook essentially checks a blacklist of accounts</Text>
|
||||||
</PanelBox>
|
</PanelBox>
|
||||||
<PanelBox as="a" href="/develop/1d14e51e2e02dc0a508cb0733767a914">
|
<PanelBox as="a" href={`/develop/${templates.accept}`}>
|
||||||
<Heading>Accept</Heading>
|
<Heading>Accept</Heading>
|
||||||
<Text>This hook just accepts any transaction coming through it</Text>
|
<Text>This hook just accepts any transaction coming through it</Text>
|
||||||
</PanelBox>
|
</PanelBox>
|
||||||
<PanelBox as="a" href="/develop/a789c75f591eeab7932fd702ed8cf9ea">
|
<PanelBox as="a" href={`/develop/${templates.notary}`}>
|
||||||
<Heading>Notary</Heading>
|
<Heading>Notary</Heading>
|
||||||
<Text>Collecting signatures for multi-sign transactions</Text>
|
<Text>Collecting signatures for multi-sign transactions</Text>
|
||||||
</PanelBox>
|
</PanelBox>
|
||||||
<PanelBox as="a" href="/develop/43925143fa19735d8c6505c34d3a6a47">
|
<PanelBox as="a" href={`/develop/${templates.carbon}`}>
|
||||||
<Heading>Carbon</Heading>
|
<Heading>Carbon</Heading>
|
||||||
<Text>Send a percentage of sum to an address</Text>
|
<Text>Send a percentage of sum to an address</Text>
|
||||||
</PanelBox>
|
</PanelBox>
|
||||||
<PanelBox as="a" href="/develop/ceaf352e2a65741341033ab7ef05c448">
|
<PanelBox as="a" href={`/develop/${templates.peggy}`}>
|
||||||
<Heading>Peggy</Heading>
|
<Heading>Peggy</Heading>
|
||||||
<Text>An oracle based stabe coin hook</Text>
|
<Text>An oracle based stabe coin hook</Text>
|
||||||
</PanelBox>
|
</PanelBox>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Octokit } from "@octokit/core";
|
import { Octokit } from "@octokit/core";
|
||||||
import Router from "next/router";
|
import Router from "next/router";
|
||||||
import state from '../index';
|
import state from '../index';
|
||||||
|
import { templates } from '../../utils/templates';
|
||||||
|
|
||||||
|
|
||||||
const octokit = new Octokit();
|
const octokit = new Octokit();
|
||||||
|
|
||||||
const HEADER_GIST_ID = '9b448e8a55fab11ef5d1274cb59f9cf3'
|
|
||||||
|
|
||||||
/* Fetches Gist files from Githug Gists based on
|
/* Fetches Gist files from Githug Gists based on
|
||||||
* gistId and stores the content in global state
|
* gistId and stores the content in global state
|
||||||
*/
|
*/
|
||||||
@@ -20,8 +20,11 @@ export const fetchFiles = (gistId: string) => {
|
|||||||
octokit
|
octokit
|
||||||
.request("GET /gists/{gist_id}", { gist_id: gistId })
|
.request("GET /gists/{gist_id}", { gist_id: gistId })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
// fetch header file(s) and append to res
|
if (!Object.values(templates).includes(gistId)) {
|
||||||
return octokit.request("GET /gists/{gist_id}", { gist_id: HEADER_GIST_ID }).then(({ data: { files: headerFiles } }) => {
|
return res
|
||||||
|
}
|
||||||
|
// in case of templates, fetch header file(s) and append to res
|
||||||
|
return octokit.request("GET /gists/{gist_id}", { gist_id: templates.headers }).then(({ data: { files: headerFiles } }) => {
|
||||||
const files = { ...res.data.files, ...headerFiles }
|
const files = { ...res.data.files, ...headerFiles }
|
||||||
res.data.files = files
|
res.data.files = files
|
||||||
return res
|
return res
|
||||||
|
|||||||
9
utils/templates.ts
Normal file
9
utils/templates.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export const templates = {
|
||||||
|
'starter': '1d14e51e2e02dc0a508cb0733767a914', // TODO currently same as accept
|
||||||
|
'accept': '1d14e51e2e02dc0a508cb0733767a914',
|
||||||
|
'firewall': 'bcd6d0c0fcbe52545ddb802481ff9d26',
|
||||||
|
'notary': 'a789c75f591eeab7932fd702ed8cf9ea',
|
||||||
|
'carbon': '43925143fa19735d8c6505c34d3a6a47',
|
||||||
|
'peggy': 'ceaf352e2a65741341033ab7ef05c448',
|
||||||
|
'headers': '9b448e8a55fab11ef5d1274cb59f9cf3'
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user