added withdraw access
This commit is contained in:
parent
48f2e80534
commit
88441f5a9d
20
src/lib/ui-components/CopyButton.svelte
Normal file
20
src/lib/ui-components/CopyButton.svelte
Normal file
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
import { CheckIcon, CopyIcon } from "svelte-feather-icons";
|
||||
let copied = false;
|
||||
export let data = "";
|
||||
</script>
|
||||
|
||||
<button
|
||||
on:click={() => {
|
||||
navigator.clipboard.writeText(data);
|
||||
copied = true;
|
||||
}}
|
||||
class={"btn btn-xs btn-outline rounded-[5px] py-1 px-1.5 " +
|
||||
(copied ? "btn-success" : "btn-ghost")}
|
||||
>
|
||||
{#if copied}
|
||||
<CheckIcon size={"12"} />
|
||||
{:else}
|
||||
<CopyIcon size={"12"} />
|
||||
{/if}
|
||||
</button>
|
@ -18,6 +18,7 @@
|
||||
let value_role = "-1";
|
||||
let value_bid = 0;
|
||||
let value_trading = false;
|
||||
let value_withdraw = false;
|
||||
let value_currency_code = "-1";
|
||||
let value_paid_bid = 0;
|
||||
let value_deposit_address = "";
|
||||
@ -34,12 +35,22 @@
|
||||
value_insurance
|
||||
);
|
||||
|
||||
function checkFields(name, surname, balance, role, bid, code, pbid, addr, insurance) {
|
||||
function checkFields(
|
||||
name,
|
||||
surname,
|
||||
balance,
|
||||
role,
|
||||
bid,
|
||||
code,
|
||||
pbid,
|
||||
addr,
|
||||
insurance
|
||||
) {
|
||||
if (isStringEmptyOrSpaces(code) || code === "-1") {
|
||||
canCreateUser = false;
|
||||
return;
|
||||
}
|
||||
if(!Number.isFinite(insurance) || insurance < 0) {
|
||||
if (!Number.isFinite(insurance) || insurance < 0) {
|
||||
canCreateUser = false;
|
||||
return;
|
||||
}
|
||||
@ -119,7 +130,8 @@
|
||||
payout_bid: Number(value_paid_bid) + "",
|
||||
bid: value_bid.toString(),
|
||||
deposit_address: value_deposit_address + "",
|
||||
insurance: value_insurance.toString()
|
||||
insurance: value_insurance.toString(),
|
||||
is_withdrawal_available: value_withdraw ? "true" : "false",
|
||||
},
|
||||
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||
);
|
||||
@ -137,7 +149,7 @@
|
||||
loadingUserToken = false;
|
||||
}
|
||||
|
||||
let currentCurrencies = [{"code": ""}];
|
||||
let currentCurrencies = [{ code: "" }];
|
||||
async function getCurrentCurrencies() {
|
||||
// Made on 4th of October. Happy Birthday Dear Alex!
|
||||
const result = await makeGet(
|
||||
@ -150,14 +162,12 @@
|
||||
return;
|
||||
}
|
||||
currentCurrencies = result.data.data;
|
||||
if(!Array.isArray(currentCurrencies))
|
||||
{
|
||||
if (!Array.isArray(currentCurrencies)) {
|
||||
currentCurrencies = [];
|
||||
}
|
||||
}
|
||||
|
||||
if(browser)
|
||||
{
|
||||
if (browser) {
|
||||
getCurrentCurrencies();
|
||||
}
|
||||
</script>
|
||||
@ -250,7 +260,7 @@
|
||||
<!-- <option value="2">Модератор</option>
|
||||
<option value="4">Администратор</option> -->
|
||||
</select>
|
||||
<div class="flex p-4 items-center gap-2">
|
||||
<div class="flex p-1 items-center gap-2">
|
||||
<p>Торговля:</p>
|
||||
<input
|
||||
bind:checked={value_trading}
|
||||
@ -258,6 +268,14 @@
|
||||
class="toggle toggle-primary"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex p-1 items-center gap-2">
|
||||
<p>Доступ к выплатам:</p>
|
||||
<input
|
||||
bind:checked={value_withdraw}
|
||||
type="checkbox"
|
||||
class="toggle toggle-primary"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
on:click={() => {
|
||||
createUser();
|
||||
|
@ -5,7 +5,7 @@ import { sayError } from "$lib/tools/toaster/Toaster";
|
||||
import { redirect } from "$lib/tools/url/URLTools";
|
||||
|
||||
export async function load({ params }) {
|
||||
if(!browser) return;
|
||||
if (!browser) return;
|
||||
const { userToken } = params;
|
||||
let userResult = await makePost(
|
||||
"getUser",
|
||||
@ -24,12 +24,23 @@ export async function load({ params }) {
|
||||
sayError("Не удалось настроить пользователя");
|
||||
return {};
|
||||
}
|
||||
userResult["can_trade"] = userResult["can_trade"] === "t" ? true:false;
|
||||
userResult["can_trade_global"] = userResult["can_trade_global"] === "t" ? true:false;
|
||||
userResult["balance"] = Number(userResult["balance"]);
|
||||
userResult["bid"] = Number(userResult["bid"]);
|
||||
// userResult["can_trade"] = userResult["can_trade"] === "t" ? true : false;
|
||||
// userResult["can_trade_global"] =
|
||||
// userResult["can_trade_global"] === "t" ? true : false;
|
||||
// userResult["is_withdrawal_available"] =
|
||||
// userResult["is_withdrawal_available"] === "t" ? true : false;
|
||||
// userResult["balance"] = Number(userResult["balance"]);
|
||||
// userResult["bid"] = Number(userResult["bid"]);
|
||||
let userRes = { ...userResult.data };
|
||||
userRes["can_trade"] = userRes["can_trade"] === "t" ? true : false;
|
||||
userRes["can_trade_global"] =
|
||||
userRes["can_trade_global"] === "t" ? true : false;
|
||||
userRes["is_withdrawal_available"] =
|
||||
userRes["is_withdrawal_available"] === "t" ? true : false;
|
||||
userRes["balance"] = Number(userRes["balance"]);
|
||||
userRes["bid"] = Number(userRes["bid"]);
|
||||
return {
|
||||
token: userToken,
|
||||
userData: userResult.data
|
||||
userData: userRes,
|
||||
};
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
import { sayError, sayInfo } from "$lib/tools/toaster/Toaster.js";
|
||||
import { redirect } from "$lib/tools/url/URLTools.js";
|
||||
import { jwtDecode } from "jwt-decode";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
export let data;
|
||||
let { userData } = data;
|
||||
@ -91,6 +92,9 @@
|
||||
payout_bid: userData.payout_bid.toString(),
|
||||
deposit_address: userData.deposit_address,
|
||||
insurance: userData.insurance.toString(),
|
||||
is_withdrawal_available: userData["is_withdrawal_available"]
|
||||
? "true"
|
||||
: "false",
|
||||
},
|
||||
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||
);
|
||||
@ -109,6 +113,10 @@
|
||||
sayInfo("Пользователь изменён!");
|
||||
document.getElementById("ref")?.click();
|
||||
}
|
||||
|
||||
// onMount(() => {
|
||||
// console.log(userData);
|
||||
// });
|
||||
</script>
|
||||
|
||||
<div class="w-full flex flex-col gap-8">
|
||||
@ -187,7 +195,7 @@
|
||||
<option value="2">Модератор</option>
|
||||
<option value="4">Администратор</option>
|
||||
</select>
|
||||
<div class="flex p-4 items-center gap-2">
|
||||
<div class="flex p-1 items-center gap-2">
|
||||
<p>Торговля:</p>
|
||||
<input
|
||||
bind:checked={userData["can_trade"]}
|
||||
@ -195,7 +203,7 @@
|
||||
class="toggle toggle-primary"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex p-4 items-center gap-2">
|
||||
<div class="flex p-1 items-center gap-2">
|
||||
<p>Глобальная торговля:</p>
|
||||
<input
|
||||
bind:checked={userData["can_trade_global"]}
|
||||
@ -203,6 +211,14 @@
|
||||
class="toggle toggle-primary"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex p-1 items-center gap-2">
|
||||
<p>Доступ к выплатам:</p>
|
||||
<input
|
||||
bind:checked={userData["is_withdrawal_available"]}
|
||||
type="checkbox"
|
||||
class="toggle toggle-primary"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
on:click={() => {
|
||||
changeUserInfo();
|
||||
|
@ -5,6 +5,7 @@
|
||||
import { toValidNumberFormat } from "$lib/tools/strings/Strings.js";
|
||||
import { sayError } from "$lib/tools/toaster/Toaster.js";
|
||||
import { redirect } from "$lib/tools/url/URLTools.js";
|
||||
import CopyButton from "$lib/ui-components/CopyButton.svelte";
|
||||
import Pagination from "$lib/ui-components/pagination.svelte";
|
||||
|
||||
export let data;
|
||||
@ -198,51 +199,106 @@
|
||||
<div class="bg-accent rounded-[4px] w-[10px] h-full"></div>
|
||||
<h1 class="text-2xl font-semibold">Информация о пользователе</h1>
|
||||
</div>
|
||||
<div class="w-full flex flex-col p-4 rounded-box bg-base-300">
|
||||
<div class="flex gap-2 p-2 items-center text-lg">
|
||||
<p class="font-bold">Токен:</p>
|
||||
<p class="text-info">{token}</p>
|
||||
|
||||
<div class="flex flex-col w-full gap-2">
|
||||
<div class="w-full grid grid-cols-1 lg:grid-cols-2 gap-2">
|
||||
<div class="w-full flex flex-col">
|
||||
<div
|
||||
class="bg-base-300 rounded-t-box p-4 pb-2 border-2 border-b-0 border-base-300"
|
||||
>
|
||||
<p class="text-lg font-semibold leading-none">Основная информация</p>
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-col p-4 gap-2 border-2 border-t-0 rounded-b-box border-base-300"
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Токен</p>
|
||||
<div class="flex gap-2">
|
||||
<p class="text-accent font-semibold">{token}</p>
|
||||
<CopyButton data={token} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Имя и фамилия</p>
|
||||
<p class="text-accent font-semibold">
|
||||
{userData.name}
|
||||
{userData.surname}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Валюта</p>
|
||||
<p class="text-accent font-semibold">{userData?.code}</p>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Торговля</p>
|
||||
<p
|
||||
class={userData["can_trade"] === "t"
|
||||
? "text-primary font-semibold"
|
||||
: "text-error font-semibold"}
|
||||
>
|
||||
{userData["can_trade"] === "t" ? "Активна" : "Отключена"}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Доступ к выплатам</p>
|
||||
<p
|
||||
class={userData["is_withdrawal_available"] === "t"
|
||||
? "text-primary font-semibold"
|
||||
: "text-error font-semibold"}
|
||||
>
|
||||
{userData["is_withdrawal_available"] === "t"
|
||||
? "Активен"
|
||||
: "Отключен"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="w-full flex flex-col">
|
||||
<div
|
||||
class="bg-base-300 rounded-t-box p-4 pb-2 border-2 border-b-0 border-base-300"
|
||||
>
|
||||
<p class="text-lg font-semibold leading-none">
|
||||
Информация о финансах
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-col p-4 gap-2 border-2 border-t-0 rounded-b-box border-base-300"
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Баланс</p>
|
||||
<p class="text-accent font-semibold">
|
||||
{toValidNumberFormat(userData.balance)}
|
||||
{userData?.code}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Страховка</p>
|
||||
<p class="text-accent font-semibold">{userData?.insurance} USDT</p>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Ставка</p>
|
||||
<p class="text-accent font-semibold">{userData.bid}%</p>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Ставка на выплаты</p>
|
||||
<p class="text-accent font-semibold">{userData.payout_bid}%</p>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<p class="opacity-50 text-xs">Кошелёк пополнения</p>
|
||||
<div class="flex gap-2">
|
||||
<p class="text-accent font-semibold">
|
||||
{userData.deposit_address}
|
||||
</p>
|
||||
<CopyButton data={userData.deposit_address} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2 p-2 items-center text-lg">
|
||||
<p class="font-bold">Имя и фамилия:</p>
|
||||
<p class="text-info">{userData.name} {userData.surname}</p>
|
||||
</div>
|
||||
<div class="flex gap-2 p-2 items-center text-lg">
|
||||
<p class="font-bold">Валюта:</p>
|
||||
<p class="text-info">{userData?.code}</p>
|
||||
</div>
|
||||
<div class="flex gap-2 p-2 items-center text-lg">
|
||||
<p class="font-bold">Баланс:</p>
|
||||
<p class="text-info">
|
||||
{toValidNumberFormat(userData.balance)}
|
||||
{userData?.code}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2 p-2 items-center text-lg">
|
||||
<p class="font-bold">Страховка:</p>
|
||||
<p class="text-info">{userData?.insurance} USDT</p>
|
||||
</div>
|
||||
<div class="flex gap-2 p-2 items-center text-lg">
|
||||
<p class="font-bold">Ставка:</p>
|
||||
<p class="text-info">{userData.bid} %</p>
|
||||
</div>
|
||||
<div class="flex gap-2 p-2 items-center text-lg">
|
||||
<p class="font-bold">Ставка на выплаты:</p>
|
||||
<p class="text-info">{userData.payout_bid} %</p>
|
||||
</div>
|
||||
<div class="flex gap-2 p-2 items-center text-lg flex-wrap">
|
||||
<p class="font-bold">Кошелёк пополнения:</p>
|
||||
<p class="text-info text-sm">{userData.deposit_address}</p>
|
||||
</div>
|
||||
<div class="flex gap-2 p-2 items-center text-lg">
|
||||
<p class="font-bold">Торговля:</p>
|
||||
<p class={userData["can_trade"] === "t" ? "text-primary" : "text-error"}>
|
||||
{userData["can_trade"] === "t" ? "Активна" : "Отключена"}
|
||||
</p>
|
||||
</div>
|
||||
<div class="w-full flex gap-4 mt-8">
|
||||
<div class="w-full flex justify-start gap-2">
|
||||
<button
|
||||
class="btn btn-neutral w-[100px]"
|
||||
class="btn btn-neutral w-[100px] btn-outline rounded-lg btn-sm"
|
||||
on:click={() => {
|
||||
reloadUserInfo();
|
||||
}}
|
||||
@ -256,13 +312,14 @@
|
||||
</button>
|
||||
<a
|
||||
href={window.location.pathname.replace("profile", "change")}
|
||||
class="btn btn-info">Изменить</a
|
||||
class="btn btn-info btn-outline rounded-lg btn-sm">Изменить</a
|
||||
>
|
||||
<button
|
||||
on:click={() => {
|
||||
deleteUser();
|
||||
if (confirm("Вы уверены, что хотите удалить пользователя?"))
|
||||
deleteUser();
|
||||
}}
|
||||
class="btn btn-error ml-auto">Удалить</button
|
||||
class="btn btn-error btn-outline rounded-lg btn-sm">Удалить</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user