diff --git a/src/routes/newuser/+page.svelte b/src/routes/newuser/+page.svelte index e9110eb..875c215 100644 --- a/src/routes/newuser/+page.svelte +++ b/src/routes/newuser/+page.svelte @@ -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(); + }
@@ -203,7 +226,10 @@ class="select select-bordered w-full text-base" > - + {#each currentCurrencies as currency} + + {/each} +