minor fixes

This commit is contained in:
you 2024-09-11 09:35:13 +03:00
parent cd92a3bb46
commit df81da6d63
6 changed files with 106 additions and 18 deletions

View File

@ -150,6 +150,49 @@
};
return mimeTypes[mimeType] || "bin"; // Если тип неизвестен, возвращаем .bin
}
let showDisputeReceiptImage = false;
let showLoadingReceiptShowing = false;
let receiptImage = "";
async function showDisputeReceipt() {
// console.log(receiptImage);
showDisputeReceiptImage = false;
showLoadingReceiptShowing = true;
try {
const response = await axios.get(
"https://hostapay.trade/api/v1/loadFile?dispute=" +
selectedDispute["order_id"],
// "17731",
{
responseType: "blob",
headers: makeAuthHeaderForAxios(getAuthInfo()?.a).headers,
}
);
const url = window.URL.createObjectURL(new Blob([response.data]));
// console.log(url);
receiptImage = url;
showDisputeReceiptImage = true;
showLoadingReceiptShowing = false;
// const contentType = response?.data?.type;
// let extension = mimeToExtension(contentType);
// const a = document.createElement("a");
// a.style.display = "none";
// a.href = url;
// a.download = `Чек_${Date.now()}.${extension}`;
// document.body.appendChild(a);
// a.click();
// window.URL.revokeObjectURL(url);
// document.body.removeChild(a);
// showLoadingReceipDownloading = false;
} catch (error) {
sayError("Ошибка загрузки изображения");
showDisputeReceiptImage = false;
showLoadingReceiptShowing = false;
//console.log(error);
}
}
</script>
<div class="w-full flex flex-col gap-8">
@ -328,6 +371,18 @@
>
Скачать чек
</button>
<button
on:click={() => {
showDisputeReceipt();
}}
class="btn btn-info btn-outline mt-1"
>
{#if showLoadingReceiptShowing}
<span class="loading loading-xs"></span>
{:else}
{"Показать чек"}
{/if}
</button>
{/if}
<button
on:click={() => {
@ -340,3 +395,12 @@
</div>
</div>
{/if}
{#if showDisputeReceiptImage}
<div class="fixed inset-0 p-4 md:p-8 flex flex-col items-center bg-base-300 z-[100]">
<div class="w-[90%] h-[90%] flex">
<img src={receiptImage} alt="receipt" class="w-full h-full object-scale-down">
</div>
<button on:click={()=>{showDisputeReceiptImage = false;}} class="btn btn-info w-full mt-auto">Закрыть</button>
</div>
{/if}

View File

@ -86,7 +86,7 @@
let showChangeSum = false;
let newSum = 0;
$: if (foundedDispute !== 0) newSum = Number(foundedDispute?.summa);
// $: if (foundedDispute !== 0) newSum = Number(foundedDispute?.summa);
let showLoadingChangeSum = false;
async function changeSum(id) {

View File

@ -2,14 +2,14 @@
import { getAuthInfo, makeAuthHeaderForAxios } from "$lib/auth/Auth.js";
import { makePost } from "$lib/tools/requests/requests.js";
import { isStringEmptyOrSpaces } from "$lib/tools/strings/Strings";
import { sayError } from "$lib/tools/toaster/Toaster.js";
import { sayError, sayInfo } from "$lib/tools/toaster/Toaster.js";
import { redirect } from "$lib/tools/url/URLTools.js";
import { jwtDecode } from "jwt-decode";
export let data;
let { userData } = data;
let { token } = data;
let value_role = jwtDecode(getAuthInfo()?.a).role.toString();
let value_role = "1";
let changingUser = false;
let canChangeUser = true;
@ -20,13 +20,15 @@
userData.balance,
value_role,
userData.bid,
userData.paid_bid
userData.payout_bid
);
function checkFields(name, surname, balance, role, bid, paid_bid) {
function checkFields(name, surname, balance, role, bid, payout_bid) {
// balance = Number(balance);
// bid = Number(balance);
if (isStringEmptyOrSpaces(name) || name.length < 3) {
console.log(name, surname, balance, role, bid, payout_bid);
if (isStringEmptyOrSpaces(name) || name.length < 2) {
canChangeUser = false;
return;
}
@ -34,11 +36,11 @@
canChangeUser = false;
return;
}
if ((paid_bid !== 0 && !paid_bid) || paid_bid < 0) {
if ((payout_bid !== 0 && !payout_bid) || payout_bid < 0) {
canChangeUser = false;
return;
}
if (isStringEmptyOrSpaces(surname) || surname.length < 3) {
if (isStringEmptyOrSpaces(surname) || surname.length < 2) {
canChangeUser = false;
return;
}
@ -67,15 +69,15 @@
can_trade_global: userData["can_trade_global"] ? "true":"false",
role: value_role,
bid: userData.bid.toString(),
paid_bid: userData.paid_bid.toString()
payout_bid: userData.payout_bid.toString()
},
makeAuthHeaderForAxios(getAuthInfo()?.a)
);
if (userResult.status === 401) {
sayError("Данные авторизации устарели");
// window.location.href = "/";
redirect("/admin/");
changingUser = false;
redirect("/admin/");
return;
}
if (userResult.error) {
@ -83,6 +85,7 @@
changingUser = false;
return;
}
sayInfo("Пользователь изменён!");
document.getElementById("ref")?.click();
}
</script>
@ -142,7 +145,7 @@
class="select select-bordered w-full text-base"
>
<option disabled selected value="-1">Права доступа</option>
<option value="1">Пользователь</option>
<option value="1">Трейдер</option>
<option value="2">Модератор</option>
<option value="4">Администратор</option>
</select>

View File

@ -38,7 +38,7 @@
canChange = false;
return;
}
if (value_phone?.length !== 11) {
if (value_phone?.length < 6) {
canChange = false;
return;
}

View File

@ -74,7 +74,7 @@
"admin/getUserOrders",
{
token: token,
page: currentPageUserOrders - 1,
page: currentPageUserOrders,
// orderBy: "id",
statuses_to_send: Number(ordersFilter),
},
@ -100,11 +100,14 @@
disablePagesUserOrders = false;
}
let reqsCurrentPage = 1;
let reqsMaxPage = 1;
let userRequisites = [];
async function getUserRequisites() {
const result = await makePost(
"getRequisite",
"admin/getRequisite",
{
page: Number(reqsCurrentPage),
token: token,
},
makeAuthHeaderForAxios(getAuthInfo()?.a)
@ -118,8 +121,9 @@
sayError("Не удалось получить реквизиты пользователя");
return;
}
userRequisites = result.data;
userRequisites = result.data.data;
if(!Array.isArray(userDeposits)) userRequisites = [];
reqsMaxPage = Number(result.data.pages);
console.log(result.data);
}
@ -258,6 +262,20 @@
<h1 class="text-2xl font-semibold">Реквизиты пользователя</h1>
<button disabled class="btn btn-accent">Добавить реквизит</button>
</div>
<div class="w-full flex flex-col p-4 rounded-box bg-base-300">
<div class="w-full flex flex-col justify-center items-center">
<Pagination
totalPages={reqsMaxPage}
pageChangedCallback={(n) => {
reqsCurrentPage = n;
getUserRequisites();
}}
disableButtons={false}
css={"btn-neutral mt-2"}
/>
<p class="opacity-50 text-xs mt-1">Всего страниц: {reqsMaxPage}</p>
</div>
</div>
<div class="w-full flex flex-col p-4 rounded-box bg-base-300">
<div class="overflow-x-auto mt-4">
<table class="table">
@ -290,7 +308,7 @@
<td>{requisite["cardnumber"]}</td>
<td>{requisite["phone"]}</td>
<td>{requisite["name"]}</td>
<td>{requisite["device_id"]}</td>
<td>{requisite["device_uuid"]}</td>
<td>{requisite["daily_volume"]}</td>
<td>{requisite["daily_volume_limit"]}</td>
<td class="flex gap-2">
@ -349,11 +367,13 @@
<!-- head -->
<thead>
<tr>
<th>ID заявки</th>
<th>UUID</th>
<th>ID клиента</th>
<th>Статус</th>
<th>Сумма</th>
<th>Курс</th>
<th>Название реквизита</th>
<th>СБП</th>
<th>Мерчант</th>
<th>Время создания</th>
@ -365,6 +385,7 @@
<tbody>
{#each userOrders as order}
<tr class="hover:bg-neutral group">
<td class="font-semibold">{order["id"]}</td>
<td class="font-semibold">{order["uuid"]}</td>
<td class="font-semibold">{order["external_user_id"]}</td>
<td class="">{order["status"]}</td>
@ -372,7 +393,7 @@
<td>{order["rate"]} {userData?.code}</td>
<td>{order["is_sbp"] === "t" ? "да" : "нет"}</td>
<td>{order["merchant_id"]}</td>
<td>{order["creationtime"]}</td>
<td>{order["creation_time"]}</td>
<td>{order["closetime"]}</td>
<!-- <td>
<button class="btn btn-outline">Закрыть ручками</button>

View File

@ -55,7 +55,7 @@
<tr class="hover:bg-neutral group">
<th class="font-normal">{user["token"]}</th>
<td class="font-semibold">{user["name"]} {user["surname"]}</td>
<td>{user["balance"]} USDT</td>
<td>{(Number(user["balance"]) / 1e6)} USDT</td>
<td>
<a href={"/admin/user/profile/"+user["token"]} class="btn btn-outline btn-info group-hover:btn-warning">Профиль</a>
</td>