added currencies to user creation

This commit is contained in:
you 2024-10-04 14:19:00 +03:00
parent 199dc560d8
commit fb146659c8

View File

@ -9,6 +9,8 @@
import { onMount } from "svelte";
import { sayError } from "$lib/tools/toaster/Toaster";
import { redirect } from "$lib/tools/url/URLTools";
import { error } from "@sveltejs/kit";
import { browser } from "$app/environment";
let value_name = "";
let value_surname = "";
@ -32,8 +34,7 @@
);
function checkFields(name, surname, balance, role, bid, code, pbid, addr) {
if(isStringEmptyOrSpaces(code) || code === "-1")
{
if (isStringEmptyOrSpaces(code) || code === "-1") {
canCreateUser = false;
return;
}
@ -79,7 +80,7 @@
const result = await makePost(
"createUser",
{
"code": value_currency_code
code: value_currency_code,
},
makeAuthHeaderForAxios(getAuthInfo()?.a)
);
@ -106,30 +107,52 @@
surname: value_surname,
balance: value_balance.toString(),
rate: "0",
can_trade: value_trading ? "true":"false",
can_trade_global: value_trading ? "true":"false",
can_trade: value_trading ? "true" : "false",
can_trade_global: value_trading ? "true" : "false",
role: value_role,
payout_bid: Number(value_paid_bid)+"",
payout_bid: Number(value_paid_bid) + "",
bid: value_bid.toString(),
deposit_address: value_deposit_address+"",
deposit_address: value_deposit_address + "",
},
makeAuthHeaderForAxios(getAuthInfo()?.a)
);
if(result.status === 401)
{
if (result.status === 401) {
sayError("Данные авторизации устарели");
// window.location.href = "/";
redirect("/admin/");
return;
}
if(result.error)
{
if (result.error) {
sayError("Не удалось настроить пользователя");
return;
}
userToken = temp_userToken;
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>
<div class="w-full flex flex-col gap-8">
@ -203,7 +226,10 @@
class="select select-bordered w-full text-base"
>
<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="4">Администратор</option> -->
</select>