Skip to content

Commit 1cc3527

Browse files
author
Ajit Kumar
committed
fix(plugin page);feat(pre commit check)
1 parent 06c54d9 commit 1cc3527

34 files changed

+269
-2768
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx biome check

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@
3737
"Foxbiz",
3838
"gapis",
3939
"hideloading",
40+
"hintrc",
4041
"hljs",
4142
"iconsrc",
4243
"IFNULL",
4344
"ifsc",
4445
"inappproducts",
4546
"lightgreen",
47+
"locationchange",
4648
"maxlength",
4749
"nagivate",
4850
"noreferrer",
@@ -54,7 +56,6 @@
5456
"onhide",
5557
"onloadeend",
5658
"onloaderror",
57-
"onnavigate",
5859
"onok",
5960
"onref",
6061
"onrename",
@@ -81,6 +82,9 @@
8182
"[json]": {
8283
"editor.defaultFormatter": "biomejs.biome"
8384
},
85+
"[css]": {
86+
"editor.defaultFormatter": "biomejs.biome"
87+
},
8488
"editor.codeActionsOnSave": {
8589
"quickFix.biome": "explicit",
8690
"source.organizeImports.biome": "explicit"

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
33
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
4-
"files": { "ignoreUnknown": true, "ignore": ["public/**/*", "*.d.ts", ".vscode/**/*", "**/jsconfig.json"] },
4+
"files": { "ignoreUnknown": true, "ignore": ["public/**/*", "*.d.ts", ".vscode/**/*", "**/jsconfig.json", ".babelrc", ".hintrc"] },
55
"formatter": {
66
"enabled": true,
77
"useEditorconfig": true,

client/components/MonthSelect.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ import moment from 'moment';
99
*/
1010
export default function MonthSelect({ onChange, ref }) {
1111
const currentMonth = moment().month();
12-
return <select ref={ref} attr-name="month" onchange={onChange} title='Month'>{
13-
moment.months().map(
14-
(month, i) => <option selected={currentMonth === i} value={i}>{month}</option>,
15-
)
16-
}</select>;
12+
return (
13+
<select ref={ref} attr-name='month' onchange={onChange} title='Month'>
14+
{moment.months().map((month, i) => (
15+
<option selected={currentMonth === i} value={i}>
16+
{month}
17+
</option>
18+
))}
19+
</select>
20+
);
1721
}

client/components/YearSelect.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@ import moment from 'moment';
99
*/
1010
export default function YearSelect({ onChange, ref }) {
1111
const currentYear = moment().year();
12-
return <select ref={ref} attr-name="year" onchange={onChange} title='Year'>{
13-
(() => {
14-
// return list of years
15-
const MIN_YEAR = 2023;
16-
const MAX_YEAR = new Date().getFullYear();
12+
return (
13+
<select ref={ref} attr-name='year' onchange={onChange} title='Year'>
14+
{(() => {
15+
// return list of years
16+
const MIN_YEAR = 2023;
17+
const MAX_YEAR = new Date().getFullYear();
1718

18-
const options = [];
19-
for (let i = MIN_YEAR; i <= MAX_YEAR; i++) {
20-
options.push(
21-
<option selected={currentYear === i} value={i}>{i}</option>,
22-
);
23-
}
24-
return options;
25-
})()
26-
}</select>;
19+
const options = [];
20+
for (let i = MIN_YEAR; i <= MAX_YEAR; i++) {
21+
options.push(
22+
<option selected={currentYear === i} value={i}>
23+
{i}
24+
</option>,
25+
);
26+
}
27+
return options;
28+
})()}
29+
</select>
30+
);
2731
}

client/components/ajaxForm/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import './style.scss';
1212
* @param {string} param0.contentType
1313
* @returns
1414
*/
15-
export default function AjaxForm({
16-
ref, onloadend, onerror, loading, loadingEnd, method, action, encoding, contentType,
17-
}, children) {
15+
export default function AjaxForm({ ref, onloadend, onerror, loading, loadingEnd, method, action, encoding, contentType }, children) {
1816
const actionUrl = typeof action === 'function' ? '#' : action;
19-
const form = <form ref={ref} action={actionUrl} method={method} encoding={encoding}>
20-
{children}
21-
</form>;
17+
const form = (
18+
<form ref={ref} action={actionUrl} method={method} encoding={encoding}>
19+
{children}
20+
</form>
21+
);
2222

2323
form.addEventListener('submit', async (event) => {
2424
event.preventDefault();
@@ -28,9 +28,9 @@ export default function AjaxForm({
2828
const jsonData = {};
2929

3030
if (contentType === 'json') {
31-
formData.entries().forEach(([key, value]) => {
31+
for (const [key, value] of formData.entries()) {
3232
jsonData[key] = value;
33-
});
33+
}
3434
body = JSON.stringify(jsonData);
3535
}
3636

client/components/dialogs/alert.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,11 @@ import DialogBox from './dialogBox';
22

33
/**
44
* Alert dialog
5-
* @param {string} title
6-
* @param {string} message
7-
* @param {()=>void} [onok]
8-
* @param {boolean} [keep]
5+
* @param {string} title
6+
* @param {string} message
7+
* @param {()=>void} [onok]
8+
* @param {boolean} [keep]
99
*/
1010
export default function alert(title, message, onok, keep) {
11-
const dialog = <DialogBox
12-
onhide={onok}
13-
title={title}
14-
message={message}
15-
onok={(hide) => hide()}
16-
keep={keep}
17-
/>;
18-
19-
document.body.append(dialog);
11+
document.body.append(<DialogBox onhide={onok} title={title} message={message} onok={(hide) => hide()} keep={keep} />);
2012
}

client/components/dialogs/confirm.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ import DialogBox from './dialogBox';
22

33
export default function confirm(title, message) {
44
return new Promise((resolve) => {
5-
const dialog = <DialogBox title={title} message={message} onok={(hide) => {
6-
hide();
7-
resolve(true);
8-
}} oncancel={(hide) => {
9-
hide();
10-
resolve(false);
11-
}} />;
5+
const dialog = (
6+
<DialogBox
7+
title={title}
8+
message={message}
9+
onok={(hide) => {
10+
hide();
11+
resolve(true);
12+
}}
13+
oncancel={(hide) => {
14+
hide();
15+
resolve(false);
16+
}}
17+
/>
18+
);
1219
document.body.append(dialog);
1320
});
1421
}

client/components/dialogs/select.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ export default async function select(title, options) {
66
hide(false);
77
resolve(options[index]);
88
};
9-
const dialog = <DialogBox
10-
onhide={() => { resolve(null); }}
11-
title={title}
12-
options={options}
13-
onselect={onselect}
14-
/>;
9+
const dialog = (
10+
<DialogBox
11+
onhide={() => {
12+
resolve(null);
13+
}}
14+
title={title}
15+
options={options}
16+
onselect={onselect}
17+
/>
18+
);
1519
document.body.append(dialog);
1620
});
1721
}

client/components/sendOtp.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
* @returns
88
*/
99
export default function SendOtp({ errorText, getEmail, type = 'signup' }) {
10-
return <span style={{ marginTop: 0 }} className="link" on:click={sendOtp}>Send OTP</span>;
10+
return (
11+
<span style={{ marginTop: 0 }} className='link' on:click={sendOtp}>
12+
Send OTP
13+
</span>
14+
);
1115

1216
async function sendOtp(e) {
1317
const email = getEmail();
@@ -42,9 +46,13 @@ export default function SendOtp({ errorText, getEmail, type = 'signup' }) {
4246
target.classList.add('success');
4347
target.textContent = data.message;
4448
target.style.pointerEvents = 'none';
45-
startTimer(60, (time) => {
46-
target.textContent = `Resend OTP (${time})`;
47-
}, restore);
49+
startTimer(
50+
60,
51+
(time) => {
52+
target.textContent = `Resend OTP (${time})`;
53+
},
54+
restore,
55+
);
4856
} catch (error) {
4957
errorText.value = error.message;
5058
restore();

client/lib/Router.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Router {
3737
}
3838

3939
/**
40-
* Nvigate to given path
40+
* Navigate to given path
4141
* @param {string} url
4242
*/
4343
navigate(url) {
@@ -47,14 +47,14 @@ class Router {
4747
const allCallbacks = [];
4848
this.#currentUrl = url;
4949

50-
Object.keys(this.#beforeNavigate).forEach((path) => {
50+
for (const path in this.#beforeNavigate) {
5151
if (url.startsWith(path)) {
5252
const callbacks = this.#beforeNavigate[path];
5353
if (Array.isArray(callbacks)) {
5454
allCallbacks.push(...callbacks);
5555
}
5656
}
57-
});
57+
}
5858

5959
allCallbacks.push((currUrl, _next, forceParams) => {
6060
this.#navigate(currUrl, forceParams);
@@ -81,11 +81,9 @@ class Router {
8181
this.#lastPath = path;
8282
route(forceParams ?? params, queries);
8383

84-
if (typeof this.onnavigate === 'function') {
85-
this.onnavigate(url, changed);
84+
for (const listener of Array.from(this.#on.navigate)) {
85+
listener(url, changed);
8686
}
87-
88-
this.#on.navigate.forEach((listener) => listener(url, changed));
8987
break;
9088
} catch (_error) {
9189
// not matched
@@ -100,7 +98,7 @@ class Router {
10098
const { location } = window;
10199
this.navigate(location.pathname);
102100
document.addEventListener('locationchange', () => this.navigate());
103-
document.body.addEventListener('click', this.#listenForAncher.bind(this));
101+
document.body.addEventListener('click', this.#listenForAnchor.bind(this));
104102
window.addEventListener('popstate', () => {
105103
document.dispatchEvent(this.#customEvent);
106104
});
@@ -134,14 +132,14 @@ class Router {
134132
*/
135133
use(router) {
136134
const { routes, beforeNavigateCallbacks } = router;
137-
Object.keys(routes).forEach((path) => {
135+
for (const path in routes) {
138136
this.add(path, routes[path]);
139-
});
137+
}
140138

141-
beforeNavigateCallbacks.forEach(({ path, callback }) => {
139+
for (const { path, callback } of beforeNavigateCallbacks) {
142140
if (!this.#beforeNavigate[path]) this.#beforeNavigate[path] = [];
143141
this.#beforeNavigate[path].push(callback);
144-
});
142+
}
145143
}
146144

147145
/**
@@ -181,10 +179,10 @@ class Router {
181179
const routeSegments = route.split('/');
182180
const pathSegments = path.split('/');
183181

184-
queryString?.split('&').forEach((get) => {
185-
const [key, value] = get.split('=');
182+
for (const query of queryString.split('&')) {
183+
const [key, value] = query.split('=');
186184
queries[decodeURIComponent(key)] = decodeURIComponent(value);
187-
});
185+
}
188186

189187
const len = Math.max(routeSegments.length, pathSegments.length);
190188

@@ -230,7 +228,7 @@ class Router {
230228
* @param {MouseEvent} e
231229
* @returns
232230
*/
233-
#listenForAncher(e) {
231+
#listenForAnchor(e) {
234232
const $el = e.target;
235233

236234
if (!($el instanceof HTMLAnchorElement)) return;

client/lib/RouterExtension.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ export default class RouterExtension {
3636
}
3737

3838
get beforeNavigateCallbacks() {
39-
return [
40-
...this.#beforeNavigate,
41-
];
39+
return [...this.#beforeNavigate];
4240
}
4341
}

client/main.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ interface Router {
2828
event: 'nagivate',
2929
listener: (url: String, changed: Boolean) => void
3030
): void;
31-
onnavigate(url: String): void;
3231
}
3332

3433
interface Order {

client/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ window.onload = async () => {
6565

6666
Router.listen();
6767

68-
Router.onnavigate = () => {
68+
Router.on('navigate', () => {
6969
const navToggler = tag.get('#menu-toggler');
7070
if (navToggler.checked) {
7171
navToggler.checked = false;
7272
}
7373
main.content = '';
7474
app.scrollTop = 0;
75-
};
75+
});
7676

7777
async function loadModule(module, props = {}) {
7878
showLoading();

client/pages/payments/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export default function Payments() {
2121
throw new Error(data.error);
2222
}
2323

24-
data.forEach((i) => {
25-
list.append(Payment(i));
26-
});
24+
for (const item of data) {
25+
list.append(Payment(item));
26+
}
2727
} catch (err) {
2828
alert('ERROR', err.message || err);
2929
}

0 commit comments

Comments
 (0)