import './App.scss'; import * as action from './actions' import * as reducer from './reducers' import * as Logcomp from './components/Login' import * as Sidebar from './components/Sidebar' import * as Page from './components/Page' import { PlayerbarConnect } from './components/Playerbar' import thunk from 'redux-thunk'; import { createStore, combineReducers, applyMiddleware } from 'redux'; import { Provider } from 'react-redux'; import { Route, Router, Switch } from 'react-router-dom'; import createHistory from 'history/createBrowserHistory' export function jwtDecode(token) { try { let decoded = token.split('.') decoded = decoded[1] decoded = atob(decoded) decoded = JSON.parse(decoded) return decoded } catch (e) { return; } } export const getGQL = url => (query, variables = {}) => fetch(url, { method: 'POST', headers: { "Content-Type": "application/json", ...(localStorage.authToken ? { "Authorization": "Bearer " + localStorage.authToken } : {}) }, body: JSON.stringify({ query, variables }) }) .then(res => res.json()) .then(data => { if (data.errors && !data.data) throw new Error(JSON.stringify(data.errors)) return data.data[Object.keys(data.data)[0]] }) export const history = createHistory() export const backendURL = "http://player.asmer.fs.a-level.com.ua" export const gql = getGQL(backendURL + '/graphql') export const store = createStore( combineReducers( { promise: reducer.promiseReducer, auth: reducer.authReducer, player: reducer.playerReducer //local: localStoreReducer(promiseReducer, 'locale') } ), applyMiddleware(thunk) ) store.subscribe(() => console.log(store.getState())) //works only once on start of page if (store.getState().auth?.token) { history.push('/player') store.dispatch(action.actionGetUserData()) store.dispatch(action.actionGetUserPlaylists()) } else { history.push('/login') } const GreetPg = () => <>

Welcome to online Player!

const Player = () =>
function App() { return (
); } export default App;