Skip to content
This repository was archived by the owner on May 29, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/PageContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ type user = {

const PageContext = React.createContext({
colorMode: {
toggleColorMode: () => {}
toggleColorMode: () => {return}
},
setTokenInfo: (token: string, expiration: number) => {},
setUser: (user: user) => {},
setTokenInfo: (token: string, expiration: number) => {return},
setUser: (user: user) => {return},
user: {
name: '',
id: '',
avatar: ''
},
accessToken: '',
expiration: 0,
setCookie: (name: ("mode" | "user" | "token"), value: any, options?: any) => {}
setCookie: (name: ("mode" | "user" | "token"), value: any, options?: any) => {return}
})

export default PageContext
2 changes: 1 addition & 1 deletion src/ProfileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function ProfileMenu(props: {user?: {id: string, avatar: string, name: string}})
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
>
<MenuItem onClick={() => {window.location.href="https://discord.com/api/oauth2/authorize?client_id=852589582733541416&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth&response_type=token&scope=identify"}}>
<MenuItem onClick={() => {window.location.href=`https://discord.com/api/oauth2/authorize?client_id=852589582733541416&redirect_uri=${encodeURIComponent(window.location.origin + "/")}auth&response_type=token&scope=identify`}}>
Login
</MenuItem>
<MenuItem>
Expand Down
15 changes: 9 additions & 6 deletions src/config/permissionDialogs/AllowedForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const AllowedForm = (props: {
handleAllowedOnChange: (event: SelectChangeEvent<string>)=>void,
setAllowed: (s:string)=>void}) => {
const botContext = useContext(ConfigContext)
if(botContext.bot === undefined){
return null
}
return(
<>
{props.permType === 'all' ? (null) : (props.permType === 'rank' ? (
Expand All @@ -36,7 +39,7 @@ const AllowedForm = (props: {
onChange={(e) => props.setAllowed(e.target.value)}
label="Allowed"
>
{botContext.bot!.config.ranks.map((rank: rank)=>
{botContext.bot.config.ranks.map((rank: rank)=>
<MenuItem key={rank.name} value={rank.name}>
{rank.name}
</MenuItem>
Expand All @@ -51,12 +54,12 @@ const AllowedForm = (props: {
labelId="allowed-input"
multiple
// Looks like value isnt properly typed for multiple
// @ts-ignore
//@ts-expect-error Select should be accepting this, looks to be MUI error
value={props.allowedOn}
onChange={props.handleAllowedOnChange}
label="AllowedOn"
>
{botContext.bot!.config.ranks.map((rank: rank)=>
{botContext.bot.config.ranks.map((rank: rank)=>
<MenuItem key={rank.name} value={rank.name}>
{rank.name}
</MenuItem>
Expand All @@ -82,7 +85,7 @@ const AllowedForm = (props: {
onChange={(e) => props.setAllowed(e.target.value)}
label="Allowed"
>
{botContext.bot!.config.roles.map((rank: rank)=>
{botContext.bot.config.roles.map((rank: rank)=>
<MenuItem key={rank.name} value={rank.name}>
{rank.name}
</MenuItem>
Expand All @@ -97,12 +100,12 @@ const AllowedForm = (props: {
labelId="allowed-input"
multiple
// Looks like value isnt properly typed for multiple
// @ts-ignore
//@ts-expect-error Select should be accepting this, looks to be MUI error
value={props.allowedOn}
onChange={props.handleAllowedOnChange}
label="AllowedOn"
>
{botContext.bot!.config.roles.map((rank: rank)=>
{botContext.bot.config.roles.map((rank: rank)=>
<MenuItem key={rank.name} value={rank.name}>
{rank.name}
</MenuItem>
Expand Down
12 changes: 6 additions & 6 deletions src/utils/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ENV_URL from "./env"

export async function getConfig(token: string, serverid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/private/getConfig`, {
const res = await fetch(`${ENV_URL}/private/getConfig`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -26,7 +26,7 @@ export async function getConfig(token: string, serverid :string){

export async function getBots(token: string){
try{
const res = await fetch(`http://web.${ENV_URL}/private/getBots`, {
const res = await fetch(`${ENV_URL}/private/getBots`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -47,7 +47,7 @@ export async function getBots(token: string){

export async function addServer(token: string, serverid: string){
try{
const res = await fetch(`http://web.${ENV_URL}/private/addServer`, {
const res = await fetch(`${ENV_URL}/private/addServer`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -71,7 +71,7 @@ export async function addServer(token: string, serverid: string){

export async function removeServer(token: string, serverid: string){
try{
const res = await fetch(`http://web.${ENV_URL}/private/removeServer`, {
const res = await fetch(`${ENV_URL}/private/removeServer`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -95,7 +95,7 @@ export async function removeServer(token: string, serverid: string){

export async function updateConfig(token: string, serverid: string, config: object){
try{
const res = await fetch(`http://web.${ENV_URL}/private/updateConfig`, {
const res = await fetch(`${ENV_URL}/private/updateConfig`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -120,7 +120,7 @@ export async function updateConfig(token: string, serverid: string, config: obje

export async function getUpdateStatus(token: string, serverid: string){
try{
const res = await fetch(`http://web.${ENV_URL}/private/getUpdateStatus`, {
const res = await fetch(`${ENV_URL}/private/getUpdateStatus`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/env.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const ENV_URL = "localhost:8080"
const ENV_URL = process.env.NODE_ENV === "development" ? "http://web.localhost:8080" : "https://web.reppo.io"
export default ENV_URL;
4 changes: 2 additions & 2 deletions src/utils/global.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const getDesignTokens = (mode: PaletteMode)=> ({

export async function login(accessToken: string, expiration: string){
try{
const res = await fetch(`http://web.${ENV_URL}/global/login`, {
const res = await fetch(`${ENV_URL}/global/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -105,7 +105,7 @@ export async function login(accessToken: string, expiration: string){

export async function logout(accessToken: string){
try{
const res = await fetch(`http://web.${ENV_URL}/global/logout`, {
const res = await fetch(`${ENV_URL}/global/logout`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
8 changes: 4 additions & 4 deletions src/utils/homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ENV_URL from "./env"

export async function getTotalUserCount(){
try{
const res = await fetch(`http://web.${ENV_URL}/homepage/getTotalUserCount`, {
const res = await fetch(`${ENV_URL}/homepage/getTotalUserCount`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -21,7 +21,7 @@ export async function getTotalUserCount(){

export async function getTotalServerCount(){
try{
const res = await fetch(`http://web.${ENV_URL}/homepage/getTotalServerCount`, {
const res = await fetch(`${ENV_URL}/homepage/getTotalServerCount`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -40,7 +40,7 @@ export async function getTotalServerCount(){

export async function search(searchString: string){
try{
const res = await fetch(`http://web.${ENV_URL}/homepage/search`, {
const res = await fetch(`${ENV_URL}/homepage/search`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -63,7 +63,7 @@ export async function search(searchString: string){

export async function getHourTransactions(){
try{
const res = await fetch(`http://web.${ENV_URL}/homepage/getHourTransactions`, {
const res = await fetch(`${ENV_URL}/homepage/getHourTransactions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
42 changes: 21 additions & 21 deletions src/utils/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import ENV_URL from "./env"

export async function getServer(serverid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/server/getServer`, {
const res = await fetch(`${ENV_URL}/server/getServer`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
serverid
})
serverid
})
})
if(res.status !== 200){
const payload = await res.json()
const payload = await res.json()
throw new Error(payload.failed)
}
return (await res.json()).success
Expand All @@ -25,18 +25,18 @@ export async function getServer(serverid :string){

export async function getTopUsers(serverid :string, num: number){
try{
const res = await fetch(`http://web.${ENV_URL}/server/getTopUsers`, {
const res = await fetch(`${ENV_URL}/server/getTopUsers`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
serverid,
num
})
serverid,
num
})
})
if(res.status !== 200){
const payload = await res.json()
const payload = await res.json()
throw new Error(payload.failed)
}
return (await res.json()).success
Expand All @@ -49,17 +49,17 @@ export async function getTopUsers(serverid :string, num: number){

export async function getActivityForDay(serverid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/server/getActivityForDay`, {
const res = await fetch(`${ENV_URL}/server/getActivityForDay`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
serverid
})
serverid
})
})
if(res.status !== 200){
const payload = await res.json()
const payload = await res.json()
throw new Error(payload.failed)
}
return (await res.json()).success
Expand All @@ -72,17 +72,17 @@ export async function getActivityForDay(serverid :string){

export async function getActivityForMonth(serverid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/server/getActivityForMonth`, {
const res = await fetch(`${ENV_URL}/server/getActivityForMonth`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
serverid
})
serverid
})
})
if(res.status !== 200){
const payload = await res.json()
const payload = await res.json()
throw new Error(payload.failed)
}
return (await res.json()).success
Expand All @@ -95,17 +95,17 @@ export async function getActivityForMonth(serverid :string){

export async function getActivityForYear(serverid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/server/getActivityForYear`, {
const res = await fetch(`${ENV_URL}/server/getActivityForYear`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
serverid
})
serverid
})
})
if(res.status !== 200){
const payload = await res.json()
const payload = await res.json()
throw new Error(payload.failed)
}
return (await res.json()).success
Expand Down
12 changes: 6 additions & 6 deletions src/utils/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ENV_URL from "./env"

export async function getUser(userid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/user/getUser`, {
const res = await fetch(`${ENV_URL}/user/getUser`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -25,7 +25,7 @@ export async function getUser(userid :string){

export async function getReps(userid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/user/getReps`, {
const res = await fetch(`${ENV_URL}/user/getReps`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -48,7 +48,7 @@ export async function getReps(userid :string){

export async function getRecentTransactions(userid :string, num: number){
try{
const res = await fetch(`http://web.${ENV_URL}/user/getRecentTransactions`, {
const res = await fetch(`${ENV_URL}/user/getRecentTransactions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -72,7 +72,7 @@ export async function getRecentTransactions(userid :string, num: number){

export async function getActivityForDay(userid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/user/getActivityForDay`, {
const res = await fetch(`${ENV_URL}/user/getActivityForDay`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -95,7 +95,7 @@ export async function getActivityForDay(userid :string){

export async function getActivityForMonth(userid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/user/getActivityForMonth`, {
const res = await fetch(`${ENV_URL}/user/getActivityForMonth`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -118,7 +118,7 @@ export async function getActivityForMonth(userid :string){

export async function getActivityForYear(userid :string){
try{
const res = await fetch(`http://web.${ENV_URL}/user/getActivityForYear`, {
const res = await fetch(`${ENV_URL}/user/getActivityForYear`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down