begins typing admin, fixes editorconfig

This commit is contained in:
James
2020-11-21 16:11:40 -05:00
parent 44d79d2153
commit b94772bfcd
9 changed files with 132 additions and 97 deletions

View File

@@ -1,13 +1,12 @@
/* eslint-disable import/prefer-default-export */
import qs from 'qs';
export const requests = {
get: (url, params) => {
const query = qs.stringify(params, { addQueryPrefix: true, depth: 10 });
get: (url: string, params: unknown = {}): Promise<Response> => {
const query = qs.stringify(params, { addQueryPrefix: true });
return fetch(`${url}${query}`);
},
post: (url, options = {}) => {
post: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {
const headers = options && options.headers ? { ...options.headers } : {};
const formattedOptions = {
@@ -21,7 +20,7 @@ export const requests = {
return fetch(`${url}`, formattedOptions);
},
put: (url, options = {}) => {
put: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {
const headers = options && options.headers ? { ...options.headers } : {};
const formattedOptions = {
@@ -35,7 +34,7 @@ export const requests = {
return fetch(url, formattedOptions);
},
delete: (url, options = {}) => {
delete: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {
const headers = options && options.headers ? { ...options.headers } : {};
return fetch(url, {
...options,

View File

@@ -53,7 +53,7 @@ const Auth = (props) => {
} else {
toast.error('Successfully unlocked');
}
}, [replaceStatus, serverURL, api, slug, email]);
}, [serverURL, api, slug, email]);
return (
<div className={baseClass}>
@@ -64,33 +64,33 @@ const Auth = (props) => {
autoComplete="email"
/>
{(changingPassword || requirePassword) && (
<div className={`${baseClass}__changing-password`}>
<Password
autoComplete="off"
required
name="password"
label="New Password"
/>
<ConfirmPassword />
{!requirePassword && (
<Button
size="small"
buttonStyle="secondary"
onClick={() => setChangingPassword(false)}
>
Cancel
</Button>
)}
</div>
)}
{(!changingPassword && !requirePassword) && (
<div className={`${baseClass}__changing-password`}>
<Password
autoComplete="off"
required
name="password"
label="New Password"
/>
<ConfirmPassword />
{!requirePassword && (
<Button
size="small"
buttonStyle="secondary"
onClick={() => setChangingPassword(true)}
onClick={() => setChangingPassword(false)}
>
Change Password
Cancel
</Button>
)}
</div>
)}
{(!changingPassword && !requirePassword) && (
<Button
size="small"
buttonStyle="secondary"
onClick={() => setChangingPassword(true)}
>
Change Password
</Button>
)}
<Button
size="small"
@@ -100,22 +100,22 @@ const Auth = (props) => {
Force Unlock
</Button>
{useAPIKey && (
<div className={`${baseClass}__api-key`}>
<Checkbox
label="Enable API Key"
name="enableAPIKey"
/>
{enableAPIKey?.value && (
<APIKey />
)}
</div>
<div className={`${baseClass}__api-key`}>
<Checkbox
label="Enable API Key"
name="enableAPIKey"
/>
{enableAPIKey?.value && (
<APIKey />
)}
</div>
)}
{verify && (
<Checkbox
label="Verified"
name="_verified"
readOnly
/>
<Checkbox
label="Verified"
name="_verified"
readOnly
/>
)}
</div>
);

View File

@@ -14,47 +14,42 @@ import ConfigProvider from './components/providers/Config/Provider';
import './scss/app.scss';
const Index = () => {
const windowInfoProps = {};
const Index = () => (
<React.Fragment>
<ConfigProvider>
<WindowInfoProvider breakpoints={{
xs: parseInt(getCSSVariable('breakpoint-xs-width').replace('px', ''), 10),
s: parseInt(getCSSVariable('breakpoint-s-width').replace('px', ''), 10),
m: parseInt(getCSSVariable('breakpoint-m-width').replace('px', ''), 10),
l: parseInt(getCSSVariable('breakpoint-l-width').replace('px', ''), 10),
}}
>
<ScrollInfoProvider>
<Router>
<ModalProvider
classPrefix="payload"
zIndex={parseInt(getCSSVariable('z-modal'), 10)}
>
<AuthenticationProvider>
<SearchParamsProvider>
<LocaleProvider>
<Routes />
</LocaleProvider>
</SearchParamsProvider>
<ModalContainer />
</AuthenticationProvider>
</ModalProvider>
</Router>
</ScrollInfoProvider>
</WindowInfoProvider>
</ConfigProvider>
<ToastContainer
position="bottom-center"
transition={Slide}
/>
</React.Fragment>
windowInfoProps.breakpoints = {
xs: parseInt(getCSSVariable('breakpoint-xs-width').replace('px', ''), 10),
s: parseInt(getCSSVariable('breakpoint-s-width').replace('px', ''), 10),
m: parseInt(getCSSVariable('breakpoint-m-width').replace('px', ''), 10),
l: parseInt(getCSSVariable('breakpoint-l-width').replace('px', ''), 10),
};
return (
<React.Fragment>
<ConfigProvider>
<WindowInfoProvider {...windowInfoProps}>
<ScrollInfoProvider>
<Router>
<ModalProvider
classPrefix="payload"
zIndex={parseInt(getCSSVariable('z-modal'), 10)}
>
<AuthenticationProvider>
<SearchParamsProvider>
<LocaleProvider>
<Routes />
</LocaleProvider>
</SearchParamsProvider>
<ModalContainer />
</AuthenticationProvider>
</ModalProvider>
</Router>
</ScrollInfoProvider>
</WindowInfoProvider>
</ConfigProvider>
<ToastContainer
position="bottom-center"
transition={Slide}
/>
</React.Fragment>
);
};
);
render(<Index />, document.getElementById('app'));

View File

@@ -1,4 +1,4 @@
export default (element) => {
export default (element: HTMLElement): number => {
let el = element;
// Set our distance placeholder
let distance = 0;
@@ -7,7 +7,7 @@ export default (element) => {
if (el.offsetParent) {
do {
distance += el.offsetTop;
el = el.offsetParent;
el = el.offsetParent as HTMLElement;
} while (el);
}

View File

@@ -198,7 +198,7 @@ class Payload {
this.authenticate = authenticate(this.config);
}
if (typeof options.onInit === 'function') options.onInit();
if (typeof options.onInit === 'function') options.onInit(this);
}
async sendEmail(message: Message) {