refac: 토너먼트 베팅 세부 로직을 ng_betting으로 이동 (#218)
- 토너먼트 베팅을 betting 테이블 대신 Betting 모듈을 이용하는 형태로 변경 - 이전 토너먼트 베팅 기록이 남음 - 현재 이전 토너먼트 기록을 볼 수는 없음 - 베팅에 API/Betting/Bet 을 이용 - 토너먼트, 베팅 페이지를 Betting 모듈에 맞게 임시 조정 - 이전 버전과의 호환성을 위해 betting table과 betting 테이블에 초기값을 추가하는 로직은 남김 - 이후 0.30이 되었을 때 제거 Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/218
This commit was merged in pull request #218.
This commit is contained in:
+13
-23
@@ -4,39 +4,29 @@ import { setAxiosXMLHttpRequest } from '@util/setAxiosXMLHttpRequest';
|
||||
import type { InvalidResponse } from '@/defs';
|
||||
import { convertFormData } from '@util/convertFormData';
|
||||
import { unwrap_any } from '@util/unwrap_any';
|
||||
import { SammoAPI } from './SammoAPI';
|
||||
|
||||
$(function($){
|
||||
setAxiosXMLHttpRequest();
|
||||
declare const staticValues: {
|
||||
bettingID: number;
|
||||
}
|
||||
|
||||
$('.submitBtn').on('click', async function(e){
|
||||
$(function ($) {
|
||||
$('.submitBtn').on('click', async function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const $this = $(this);
|
||||
const target = parseInt($this.data('target'));
|
||||
const amount = parseInt(unwrap_any<string>($(`#target_${target}`).val()));
|
||||
|
||||
let result: InvalidResponse;
|
||||
|
||||
try{
|
||||
const response = await axios({
|
||||
url: 'j_betting.php',
|
||||
responseType: 'json',
|
||||
method: 'post',
|
||||
data: convertFormData({
|
||||
target: target,
|
||||
amount: amount
|
||||
})
|
||||
try {
|
||||
await SammoAPI.Betting.Bet({
|
||||
bettingID: staticValues.bettingID,
|
||||
bettingType: [target],
|
||||
amount: amount,
|
||||
});
|
||||
result = response.data;
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert(`에러: ${e}`);
|
||||
location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.result){
|
||||
alert(`베팅을 실패했습니다: ${result.reason}`);
|
||||
alert(`베팅을 실패했습니다: ${e}`);
|
||||
location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user