mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
core: add contest invitation code
This commit is contained in:
1 parent
f91f201f1e
commit
4e564f1ca8
7 files changed
+51
-14
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { AutoloadPage } from 'vj/misc/Page';
|
||||
import delay from 'vj/utils/delay';
|
||||
import i18n from 'vj/utils/i18n';
|
||||
import request from 'vj/utils/request';
|
||||
import Notification from 'vj/components/notification';
|
||||
|
||||
const contestPage = new AutoloadPage('contestPage', () => {
|
||||
$('[data-contest-code]').on('click', (ev) => {
|
||||
ev.preventDefault();
|
||||
// eslint-disable-next-line no-alert
|
||||
const code = prompt(i18n('Invitation code:'));
|
||||
request.post('', {
|
||||
operation: 'attend',
|
||||
code,
|
||||
}).then(() => {
|
||||
Notification.success(i18n('Successfully attended'));
|
||||
delay(1000).then(() => window.location.reload());
|
||||
}).catch((e) => {
|
||||
Notification.error(e.message || e);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export default contestPage;
|
||||
Reference in new issue
Block a user