## LoginForm and getClient
npm install rice-instructor``ts
import * as React from 'react'
import { ApolloProvider } from '@apollo/client'
import { BrowserRouter, Switch, Route } from 'react-router-dom'
import { Home } from './Home'
import { LoginForm, getClient } from 'rice-instructor'
const submitCredential = async (username: string, password: string) => {
const res = await fetch(http://localhost:8888/login, {
method: 'POST',
body: JSON.stringify({ username, password }),
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
},
})
const data = await res.json()
if (data.code === 200) {
sessionStorage.setItem('authToken', data.token)
// Redirect to root
window.location.href = '/'
} else {
throw data
}
return data
}
const Routes = () => {
return (
)
}
const client = getClient({ uri: 'http://localhost:8888/graphql' })
const App = () => {
return (
)
}
`
`ts
import * as React from 'react'
import { ThemeProvider } from '@material-ui/core/styles'
import { SnackProvider, Admin, Directory } from 'rice-instructor'
import { theme } from '../theme'
const routes = [{ path: '/Admin', children:
export const Home = () => {
return (
)
}
`
- yarn install && yarn build && yarn linkyarn link "rice-instructor"`
- In another repo: