added currencies to user creation
This commit is contained in:
parent
199dc560d8
commit
fb146659c8
@ -9,6 +9,8 @@
|
|||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { sayError } from "$lib/tools/toaster/Toaster";
|
import { sayError } from "$lib/tools/toaster/Toaster";
|
||||||
import { redirect } from "$lib/tools/url/URLTools";
|
import { redirect } from "$lib/tools/url/URLTools";
|
||||||
|
import { error } from "@sveltejs/kit";
|
||||||
|
import { browser } from "$app/environment";
|
||||||
|
|
||||||
let value_name = "";
|
let value_name = "";
|
||||||
let value_surname = "";
|
let value_surname = "";
|
||||||
@ -32,8 +34,7 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
function checkFields(name, surname, balance, role, bid, code, pbid, addr) {
|
function checkFields(name, surname, balance, role, bid, code, pbid, addr) {
|
||||||
if(isStringEmptyOrSpaces(code) || code === "-1")
|
if (isStringEmptyOrSpaces(code) || code === "-1") {
|
||||||
{
|
|
||||||
canCreateUser = false;
|
canCreateUser = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,7 +80,7 @@
|
|||||||
const result = await makePost(
|
const result = await makePost(
|
||||||
"createUser",
|
"createUser",
|
||||||
{
|
{
|
||||||
"code": value_currency_code
|
code: value_currency_code,
|
||||||
},
|
},
|
||||||
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||||
);
|
);
|
||||||
@ -106,30 +107,52 @@
|
|||||||
surname: value_surname,
|
surname: value_surname,
|
||||||
balance: value_balance.toString(),
|
balance: value_balance.toString(),
|
||||||
rate: "0",
|
rate: "0",
|
||||||
can_trade: value_trading ? "true":"false",
|
can_trade: value_trading ? "true" : "false",
|
||||||
can_trade_global: value_trading ? "true":"false",
|
can_trade_global: value_trading ? "true" : "false",
|
||||||
role: value_role,
|
role: value_role,
|
||||||
payout_bid: Number(value_paid_bid)+"",
|
payout_bid: Number(value_paid_bid) + "",
|
||||||
bid: value_bid.toString(),
|
bid: value_bid.toString(),
|
||||||
deposit_address: value_deposit_address+"",
|
deposit_address: value_deposit_address + "",
|
||||||
},
|
},
|
||||||
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||||
);
|
);
|
||||||
if(result.status === 401)
|
if (result.status === 401) {
|
||||||
{
|
|
||||||
sayError("Данные авторизации устарели");
|
sayError("Данные авторизации устарели");
|
||||||
// window.location.href = "/";
|
// window.location.href = "/";
|
||||||
redirect("/admin/");
|
redirect("/admin/");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(result.error)
|
if (result.error) {
|
||||||
{
|
|
||||||
sayError("Не удалось настроить пользователя");
|
sayError("Не удалось настроить пользователя");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
userToken = temp_userToken;
|
userToken = temp_userToken;
|
||||||
loadingUserToken = false;
|
loadingUserToken = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let currentCurrencies = [{"code": ""}];
|
||||||
|
async function getCurrentCurrencies() {
|
||||||
|
// Made on 4th of October. Happy Birthday Dear Alex!
|
||||||
|
const result = await makeGet(
|
||||||
|
"client/currencies/enabled",
|
||||||
|
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||||
|
);
|
||||||
|
if (result.error) {
|
||||||
|
console.error("Error with currencies");
|
||||||
|
sayError("Не удалось получить валюты");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentCurrencies = result.data.data;
|
||||||
|
if(!Array.isArray(currentCurrencies))
|
||||||
|
{
|
||||||
|
currentCurrencies = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(browser)
|
||||||
|
{
|
||||||
|
getCurrentCurrencies();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="w-full flex flex-col gap-8">
|
<div class="w-full flex flex-col gap-8">
|
||||||
@ -203,7 +226,10 @@
|
|||||||
class="select select-bordered w-full text-base"
|
class="select select-bordered w-full text-base"
|
||||||
>
|
>
|
||||||
<option disabled selected value="-1">Валюта</option>
|
<option disabled selected value="-1">Валюта</option>
|
||||||
<option value="KGS">KGS</option>
|
{#each currentCurrencies as currency}
|
||||||
|
<option value={currency.code}>{currency.code}</option>
|
||||||
|
{/each}
|
||||||
|
<!-- <option value="KGS">KGS</option> -->
|
||||||
<!-- <option value="2">Модератор</option>
|
<!-- <option value="2">Модератор</option>
|
||||||
<option value="4">Администратор</option> -->
|
<option value="4">Администратор</option> -->
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user