Skip to content

Commit

Permalink
added dev functions
Browse files Browse the repository at this point in the history
  • Loading branch information
SlushEE0 committed Nov 24, 2023
1 parent 06bb7d3 commit 998a2af
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
24 changes: 23 additions & 1 deletion lib/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
export const ESPHOME_KEY =
'eyJzdWIiOiJFU1BIb21lIiwibmFtZSI6IkdhcmFnZSIsImlhdCI6MTUxNjIzOTAyMn0';
export const GEOCODING_KEY = '61cefcc612msh04fe1c5b7be6beep1c7dd8jsn5cd0b3377281';
export const GEOCODING_KEY =
'61cefcc612msh04fe1c5b7be6beep1c7dd8jsn5cd0b3377281';

export const AUTH_PASSWORDS = ['gadem'];
export const VALID_ZIPS = ['92127'];

export const DEV_KEYS = ['##URLCHANGE##'];
export const DEV_FUNCS = function (devKey: string, param?: any[]) {
switch (devKey) {
case '##URLCHANGE##':
{
if (param != null && param.length >= 2) {
param[0] = param[1];
} else {
throw new Error('Expected Param in Dev Script');
}
}
break;

default:
{
}
break;
}
};
13 changes: 12 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as SECRETS from '../lib/secrets';

import './App.css';

const ESPHOME_API_URL = 'https://esphome.webredirect.org/api/garage';

export default function App() {
const [auth, SETauth] = React.useState(false);

Expand Down Expand Up @@ -61,18 +63,27 @@ export default function App() {
function GarageDashboardPage() {
const [openAllowed, SETopenAllowed] = React.useState(true);
const [force, SETforce] = React.useState(false);
let API_URL = ESPHOME_API_URL;

let toastAlerts: any = {};

let openRequests = 0;
let timeouts: number[] = [];


const dev = function (key: string, params?: any[]) {
if (SECRETS.DEV_KEYS.includes(key)) {
SECRETS.DEV_FUNCS(key, params);
}
};
dev('');

const handleGarageBtnClick = async function () {
const timeout = setTimeout(() => {
toast.error('Something went wrong');
}, 5000);

const resp = await fetch('https://esphome.webredirect.org/api/garage', {
const resp = await fetch(`${API_URL}`, {
headers: {
Accept: '*/*',
'Content-Type': 'application/json'
Expand Down

0 comments on commit 998a2af

Please sign in to comment.