Skip to content

Commit

Permalink
Temporary fix for credentials not passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Hi-Ray committed Aug 9, 2021
1 parent 907a239 commit f68e314
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 15 deletions.
55 changes: 40 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useEffect, useState } from "react";
import { ipcRenderer as ipc } from "electron";
import * as Sentry from "@sentry/react";

import { platform } from "os";
import { Agent } from "https";

import axios from "axios";
import { ipcRenderer as ipc } from "electron";
import { Agent } from "https";

import Swagger from "./Swagger";
import { platform } from "os";
import React, { useEffect, useState } from "react";
import discord from "./images/discord.svg";
import github from "./images/github.svg";
import Logo from "./images/logo.png";
import Loading from "./Loading";

import appstyles from "./stylesheets/sass/app.module.sass";
import Logo from "./images/logo.png";
import discord from "./images/discord.svg";
import github from "./images/github.svg";

import Swagger from "./Swagger";

const reAgent = new Agent({
rejectUnauthorized: false,
Expand All @@ -31,6 +31,7 @@ const App = (): React.ReactElement => {
const [promptAnswer, setPromptAnswer]: any = useState(null);
const [status, setStatus]: any = useState("Starting");
const [credentials, setCredentials]: any = useState();
const [retry, setRetry]: any = useState(0);

useEffect(() => {
Sentry.init({
Expand Down Expand Up @@ -93,6 +94,11 @@ const App = (): React.ReactElement => {
});
}, []);

useEffect(() => {
console.log(`Credentials are`);
console.log(credentials);
});

/**
* Check if prompt ever changes if it does then that means the prompt was answered and
* do the appropriate action
Expand Down Expand Up @@ -165,6 +171,11 @@ const App = (): React.ReactElement => {
});
}, []);

const onRetry = () => {
setRetry(retry + 1);
ipc.send("FEREADY", "");
};

return (
<>
<div
Expand Down Expand Up @@ -242,12 +253,26 @@ const App = (): React.ReactElement => {
<img src={github} alt="" className={appstyles.rifticons} />
</div>
</div>
<Swagger
spec={swaggerJson}
auth={`Basic ${btoa(
`${credentials.username}:${credentials.password}`
)}`}
/>
{credentials && (
<Swagger
spec={swaggerJson}
auth={`Basic ${btoa(
`${credentials.username}:${credentials.password}`
)}`}
/>
)}

{!credentials && (
<div className={appstyles.err}>
<div>
AN ERROR HAS OCCURRED <br />
</div>
{/* eslint-disable-next-line react/button-has-type */}
<button className={appstyles.retry} onClick={onRetry}>
Retry #{retry}
</button>
</div>
)}
</div>
) : (
<Loading
Expand Down
18 changes: 18 additions & 0 deletions src/stylesheets/sass/app.module.sass
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ $buttonsize: 0.6rem
&:hover
opacity: 0.5

.retry
background: #222
color: white
padding: 3vh 1vw
border-radius: 1vw
box-shadow: none
border: 1px solid #fff
&:focus
border: 1px solid #aaa
outline: none

.err
display: flex
justify-content: center
align-items: center
width: 100%
flex-direction: column

.rifticons
opacity: 0.5
cursor: pointer
Expand Down

0 comments on commit f68e314

Please sign in to comment.