This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| export default function DataItem({ dataItem }) { | |
| return ( | |
| <div> | |
| <div className="m-auto mt-10 py-3"> | |
| <div className="bg-white shadow-2xl" > | |
| <div> | |
| <img src={dataItem.fields.image} /> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Head from 'next/head'; | |
| import { table, minifyRecords } from './api/utils/airtable'; | |
| import {DataItemsContext} from '../contexts/dataContext'; | |
| import Navbar from '../components/Navbar'; | |
| import DataItem from '../components/DataItem'; | |
| import {useEffect, useContext} from 'react'; | |
| export default function Home({initialDataItems}) { | |
| const { dataItems, setDataItems } = useContext(DataItemsContext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import '../styles/globals.css' | |
| import '../styles/index.css'; | |
| import {DataItemsProvider} from '../contexts/dataContext'; | |
| function MyApp({ Component, pageProps }) { | |
| return ( | |
| <DataItemsProvider> | |
| <div className="bg-gray-800 pattern py-5"> | |
| <Component {...pageProps} /> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {createContext, useState} from 'react'; | |
| const DataItemsContext = createContext(); | |
| const DataItemsProvider = ({children}) => { | |
| const [dataItems, setDataItems] = useState([]); | |
| const refreshDataItems = async () => { | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { table, minifyRecords } from './utils/airtable'; | |
| export default async (req, res) => { | |
| try { | |
| const records = await table.select({}).firstPage(); | |
| const minifiedRecords = minifyRecords(records); | |
| res.statusCode = 200; | |
| res.json(minifiedRecords); | |
| } catch (err) { | |
| res.statusCode = 500; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const airtable = require('airtable'); | |
| const base = new airtable({apiKey: `${process.env.AIRTABLE_API_KEY}`}).base(`${process.env.AIRTABLE_BASE_ID}`); | |
| const table = base(`${process.env.AIRTABLE_TABLE_NAME}`); | |
| const minifyRecords = (records) => { | |
| return records.map((record) => getMinifiedRecord(record)); | |
| }; | |
| const getMinifiedRecord = (record) => { | |
| return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getXGithubDelivery(header) { | |
| return commitURL = delve(header, 'x-github-delivery'); | |
| } | |
| function getXGithubEvent(header) { | |
| return commitURL = delve(header, 'x-github-event'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function postToJenkins(payload, jenkinsTargetUrl, token, basicAuth, XGithubDelivery) { | |
| let data = new FormData(); | |
| data.append('payload', `${JSON.stringify(payload)}`); | |
| let config = { | |
| method: 'post', | |
| url: `${jenkinsTargetUrl}buildWithParameters?token=${token}`, | |
| headers: { | |
| 'X-Github-Delivery': `${XGithubDelivery}`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function updateCommitStatus(commitURL, state, jenkinsTargetUrl, message, accessToken) { | |
| let data = JSON.stringify({"state":`${state}`,"target_url":`${jenkinsTargetUrl}`,"description":`${message}`,"context":"continuous-integration/jenkins"}); | |
| let config = { | |
| method: 'post', | |
| url: `${commitURL}?access_token=${accessToken}`, | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| data : data |
NewerOlder