Skip to content

Commit

Permalink
Merge pull request #2 from flynneva/devel
Browse files Browse the repository at this point in the history
add bump gh action
  • Loading branch information
flynneva committed Dec 24, 2020
2 parents 3c1a295 + 1308088 commit cb8e78a
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 194 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"prettier/react"
],
"env": {
"node": true
"node": true,
"browser": true
},
"parserOptions": {
"ecmaVersion": 2020,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: build & test

on:
push:
Expand All @@ -20,4 +20,4 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build --if-present
#- run: npm test
- run: npm test
38 changes: 38 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Bump, Tag & Publish Release
on:
push:
branches: master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Setup git config
run: |
git config user.name "flynneva"
git config user.email "<evanflynn.msu@gmail.com>"
- name: Install dependencies
run: npm install
- name: Build Release
run: npm run build
- name: Bump version and push tag
uses: mikeal/merge-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
DEPLOY_DIR: .
SRC_PACKAGE_DIR: src
- name: Get new version
id: package
uses: martinbeentjes/npm-get-version-action@master
- name: Create a GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.package.outputs.current-version }}
release_name: Release ${{ steps.package.outputs.current-version }}
body: ""
35 changes: 17 additions & 18 deletions doczrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import { createPlugin } from "docz-core";
import proxy from 'http-proxy-middleware';
import { createPlugin } from 'docz-core'
import proxy from 'http-proxy-middleware'

const proxyPlugin = () => createPlugin({
onCreateDevServer: ({ app }) => {
app.use( '/ncaa_api',
proxy({
target: "https://data.ncaa.com/",
changeOrigin: true,
pathRewrite: {
'^/ncaa_api/': '/'
}
}));
}
});
const proxyPlugin = () =>
createPlugin({
onCreateDevServer: ({ app }) => {
app.use(
'/ncaa_api',
proxy({
target: 'https://data.ncaa.com/',
changeOrigin: true,
pathRewrite: { '^/ncaa_api/': '/' }
})
)
}
})

export default {
dest: './docs/',
base: './react-ncaa-data/',
title: 'react-ncaa-data',
plugins: [
proxyPlugin(),
],
};
plugins: [proxyPlugin()]
}
241 changes: 129 additions & 112 deletions src/components/NCAA.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,145 +3,166 @@ import { NCAAContext, NCAAProvider } from './NCAAContext'
import PropTypes from 'prop-types'

var headers = {
'pragma': 'no-cache',
'cache-control': 'no-cache'
pragma: 'no-cache',
'cache-control': 'no-cache'
}

function useNCAA() {
const [ ncaa, setNCAA ] = useContext(NCAAContext);
const [ncaa, setNCAA] = useContext(NCAAContext)

function changeProxyApi(new_proxy) {
setNCAA(ncaa => ({ ...ncaa, proxy_api: new_proxy}));
function changeProxyApi(newProxy) {
setNCAA((ncaa) => ({ ...ncaa, proxy_api: newProxy }))
}

function changeDate(date) {
const tempDay = ('0' + date.getDate()).slice(-2);
const tempMonth = ('0' + (date.getMonth() + 1)).slice(-2);
const tempYear = date.getFullYear();
const tempDay = ('0' + date.getDate()).slice(-2)
const tempMonth = ('0' + (date.getMonth() + 1)).slice(-2)
const tempYear = date.getFullYear()

setNCAA(ncaa => ({ ...ncaa, day: tempDay}));
setNCAA(ncaa => ({ ...ncaa, month: tempMonth}));
setNCAA(ncaa => ({ ...ncaa, year: tempYear}));
setNCAA((ncaa) => ({ ...ncaa, day: tempDay }))
setNCAA((ncaa) => ({ ...ncaa, month: tempMonth }))
setNCAA((ncaa) => ({ ...ncaa, year: tempYear }))
}

function getGames(sport) {
var query = '/' + ncaa.proxy_api +
'/' + ncaa.base_query +
'/scoreboard' +
'/' + sport +
'/' + ncaa.division +
'/' + ncaa.year +
'/' + ncaa.month +
'/' + ncaa.day +
'/scoreboard.json';
if(!ncaa.loadingGames) {
setNCAA(ncaa => ({ ...ncaa, loadingGames: true}));
var query =
'/' +
ncaa.proxy_api +
'/' +
ncaa.base_query +
'/scoreboard' +
'/' +
sport +
'/' +
ncaa.division +
'/' +
ncaa.year +
'/' +
ncaa.month +
'/' +
ncaa.day +
'/scoreboard.json'

if (!ncaa.loadingGames) {
setNCAA((ncaa) => ({ ...ncaa, loadingGames: true }))
fetch(query, {
method: 'GET',
headers: headers,
body: JSON.stringify()
})
.then(response => response.json())
.then(data => {
if (data.games.length !== 0) {
setNCAA(ncaa => ({ ...ncaa, games: data.games}));
setNCAA(ncaa => ({ ...ncaa, sport: sport}));
setNCAA(ncaa => ({ ...ncaa, timestamp: Date.UTC()}));
setNCAA(ncaa => ({ ...ncaa, loadingGames: false}));
}
method: 'GET',
headers: headers,
body: JSON.stringify()
})
.catch(error => {
console.log(error);
setNCAA(ncaa => ({ ...ncaa, games: [] }));
setNCAA(ncaa => ({ ...ncaa, sport: 'none'}));
setNCAA(ncaa => ({ ...ncaa, loadingGames: false}));
});
.then((response) => response.json())
.then((data) => {
if (data.games.length !== 0) {
setNCAA((ncaa) => ({ ...ncaa, games: data.games }))
setNCAA((ncaa) => ({ ...ncaa, sport: sport }))
setNCAA((ncaa) => ({ ...ncaa, timestamp: Date.UTC() }))
setNCAA((ncaa) => ({ ...ncaa, loadingGames: false }))
}
})
.catch((error) => {
console.log(error)
setNCAA((ncaa) => ({ ...ncaa, games: [] }))
setNCAA((ncaa) => ({ ...ncaa, sport: 'none' }))
setNCAA((ncaa) => ({ ...ncaa, loadingGames: false }))
})
}
}

function getBoxScore(gameID) {
var query = '/' + ncaa.proxy_api +
'/' + ncaa.base_query +
'/game' +
'/' + gameID +
'/boxscore.json';
if(!ncaa.loadingBoxScore) {
setNCAA(ncaa => ({ ...ncaa, loadingBoxScore: true}));
var query =
'/' +
ncaa.proxy_api +
'/' +
ncaa.base_query +
'/game' +
'/' +
gameID +
'/boxscore.json'
if (!ncaa.loadingBoxScore) {
setNCAA((ncaa) => ({ ...ncaa, loadingBoxScore: true }))
fetch(query, {
method: 'GET',
headers: headers,
body: JSON.stringify()
})
.then(response => response.json())
.then(data => {
setNCAA(ncaa => ({ ...ncaa, boxscore: data}));
setNCAA(ncaa => ({ ...ncaa, gameID: gameID}));
setNCAA(ncaa => ({ ...ncaa, loadingBoxScore: false}));
})
.catch(error => {
setNCAA(ncaa => ({ ...ncaa, loadingBoxScore: false}));
console.log(error);
method: 'GET',
headers: headers,
body: JSON.stringify()
})
.then((response) => response.json())
.then((data) => {
setNCAA((ncaa) => ({ ...ncaa, boxscore: data }))
setNCAA((ncaa) => ({ ...ncaa, gameID: gameID }))
setNCAA((ncaa) => ({ ...ncaa, loadingBoxScore: false }))
})
.catch((error) => {
setNCAA((ncaa) => ({ ...ncaa, loadingBoxScore: false }))
console.log(error)
})
}
}

function getGameInfo(gameID) {
var query = '/' + ncaa.proxy_api +
'/' + ncaa.base_query +
'/game' +
'/' + gameID +
'/gameInfo.json';
if(!ncaa.loadingGameInfo) {
setNCAA(ncaa => ({ ...ncaa, loadingGameInfo: true}));
var query =
'/' +
ncaa.proxy_api +
'/' +
ncaa.base_query +
'/game' +
'/' +
gameID +
'/gameInfo.json'
if (!ncaa.loadingGameInfo) {
setNCAA((ncaa) => ({ ...ncaa, loadingGameInfo: true }))
fetch(query, {
method: 'GET',
headers: headers,
body: JSON.stringify()
})
.then(response => response.json())
.then(data => {
setNCAA(ncaa => ({ ...ncaa, gameInfo: data}));
setNCAA(ncaa => ({ ...ncaa, gameID: gameID}));
setNCAA(ncaa => ({ ...ncaa, loadingGameInfo: false}));
})
.catch(error => {
setNCAA(ncaa => ({ ...ncaa, loadingGameInfo: false}));
console.log(error);
method: 'GET',
headers: headers,
body: JSON.stringify()
})
.then((response) => response.json())
.then((data) => {
setNCAA((ncaa) => ({ ...ncaa, gameInfo: data }))
setNCAA((ncaa) => ({ ...ncaa, gameID: gameID }))
setNCAA((ncaa) => ({ ...ncaa, loadingGameInfo: false }))
})
.catch((error) => {
setNCAA((ncaa) => ({ ...ncaa, loadingGameInfo: false }))
console.log(error)
})
}
}

function getPbP(gameID) {
var query = '/' + ncaa.proxy_api +
'/' + ncaa.base_query +
'/game' +
'/' + gameID +
'/pbp.json';
if(!ncaa.loadingPbp) {
setNCAA(ncaa => ({ ...ncaa, loadingPbp: true}));
var query =
'/' +
ncaa.proxy_api +
'/' +
ncaa.base_query +
'/game' +
'/' +
gameID +
'/pbp.json'
if (!ncaa.loadingPbp) {
setNCAA((ncaa) => ({ ...ncaa, loadingPbp: true }))
fetch(query, {
method: 'GET',
headers: headers,
body: JSON.stringify()
})
.then(response => response.json())
.then(data => {
setNCAA(ncaa => ({ ...ncaa, pbp: data}));
setNCAA(ncaa => ({ ...ncaa, gameID: gameID}));
setNCAA(ncaa => ({ ...ncaa, loadingPbp: false}));
})
.catch(error => {
setNCAA(ncaa => ({ ...ncaa, loadingPbp: false}));
console.log(error);
method: 'GET',
headers: headers,
body: JSON.stringify()
})
.then((response) => response.json())
.then((data) => {
setNCAA((ncaa) => ({ ...ncaa, pbp: data }))
setNCAA((ncaa) => ({ ...ncaa, gameID: gameID }))
setNCAA((ncaa) => ({ ...ncaa, loadingPbp: false }))
})
.catch((error) => {
setNCAA((ncaa) => ({ ...ncaa, loadingPbp: false }))
console.log(error)
})
}
}

function toggleGender() {
if ( ncaa.gender == 'men' ) {
setNCAA(ncaa => ({ ...ncaa, gender: 'women'}));
} else if (ncaa.gender == 'women') {
setNCAA(ncaa => ({ ...ncaa, gender: 'men'}));
if (ncaa.gender === 'men') {
setNCAA((ncaa) => ({ ...ncaa, gender: 'women' }))
} else if (ncaa.gender === 'women') {
setNCAA((ncaa) => ({ ...ncaa, gender: 'men' }))
}
}

Expand All @@ -168,20 +189,16 @@ function useNCAA() {
timestamp: ncaa.timestamp,
day: ncaa.day,
month: ncaa.month,
year: ncaa.year,
year: ncaa.year
}
}

function NCAA(props) {
return (
<NCAAProvider>
{props.children}
</NCAAProvider>
);
return <NCAAProvider>{props.children}</NCAAProvider>
}

NCAA.propTypes = {
children: PropTypes.node.isRequired,
children: PropTypes.node.isRequired
}

export { useNCAA, NCAA };
export { useNCAA, NCAA }
Loading

0 comments on commit cb8e78a

Please sign in to comment.