added rates to currencies
This commit is contained in:
parent
27b37d8b58
commit
e41509fc2a
@ -14,6 +14,7 @@
|
||||
let currenciesFilter = "-1";
|
||||
let showCurrenciesLoading = false;
|
||||
let currencies = [];
|
||||
let rates = {};
|
||||
async function getCurrencies() {
|
||||
showCurrenciesLoading = true;
|
||||
const res = await makePost(
|
||||
@ -21,11 +22,9 @@
|
||||
{
|
||||
page: currenciesCurrentPage,
|
||||
status:
|
||||
Number(currenciesFilter) > -1
|
||||
? Number(currenciesFilter)
|
||||
: undefined,
|
||||
Number(currenciesFilter) > -1 ? Number(currenciesFilter) : undefined,
|
||||
},
|
||||
makeAuthHeaderForAxios(getAuthInfo()?.a),
|
||||
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||
);
|
||||
// console.log(res);
|
||||
if (res.error) {
|
||||
@ -38,7 +37,7 @@
|
||||
? Number(currenciesFilter)
|
||||
: undefined,
|
||||
},
|
||||
"- ERROR",
|
||||
"- ERROR"
|
||||
);
|
||||
showCurrenciesLoading = false;
|
||||
return;
|
||||
@ -46,6 +45,7 @@
|
||||
currencies = res.data.data ?? [];
|
||||
currenciesMaxPage = Number(res.data.pages);
|
||||
showCurrenciesLoading = false;
|
||||
rates = res.data["rates"];
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
@ -73,14 +73,17 @@
|
||||
}
|
||||
showChangeCurrencyLoading = true;
|
||||
|
||||
const res = await makePost("admin/updateCurrency", {
|
||||
bank: newBankValue.length >= 1 ? newBankValue:undefined,
|
||||
volume: newVolumeValue.length > 1 ? newVolumeValue:undefined,
|
||||
code: selectedCurrency['code']
|
||||
}, makeAuthHeaderForAxios(getAuthInfo()?.a));
|
||||
|
||||
if(res.error)
|
||||
const res = await makePost(
|
||||
"admin/updateCurrency",
|
||||
{
|
||||
bank: newBankValue.length >= 1 ? newBankValue : undefined,
|
||||
volume: newVolumeValue.length > 1 ? newVolumeValue : undefined,
|
||||
code: selectedCurrency["code"],
|
||||
},
|
||||
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||
);
|
||||
|
||||
if (res.error) {
|
||||
sayError("Не удалось обновить валюту");
|
||||
showChangeCurrencyLoading = false;
|
||||
return;
|
||||
@ -99,9 +102,7 @@
|
||||
<div class="bg-accent rounded-[4px] w-[10px] h-full"></div>
|
||||
<h1 class="text-2xl font-semibold">Валюты</h1>
|
||||
</div>
|
||||
<div
|
||||
class="flex w-full flex-col bg-base-300 p-4 rounded-box overflow-x-auto"
|
||||
>
|
||||
<div class="flex w-full flex-col bg-base-300 p-4 rounded-box overflow-x-auto">
|
||||
<div class="flex justify-center items-center p-4">
|
||||
<Pagination
|
||||
pageChangedCallback={(n) => {
|
||||
@ -114,10 +115,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-center items-center p-2">
|
||||
<select
|
||||
bind:value={currenciesFilter}
|
||||
class="select select-bordered"
|
||||
>
|
||||
<select bind:value={currenciesFilter} class="select select-bordered">
|
||||
<option value="-1">Все</option>
|
||||
<option value="0">Активные</option>
|
||||
<option value="1">Неактивные</option>
|
||||
@ -135,6 +133,7 @@
|
||||
<th>Статус</th>
|
||||
<th>Minor Units</th>
|
||||
<th>Приоритетный банк (Bybit)</th>
|
||||
<th>Курс</th>
|
||||
<th>Объем</th>
|
||||
<th>ID</th>
|
||||
<th></th>
|
||||
@ -147,15 +146,12 @@
|
||||
<td>{cur["num"]}</td>
|
||||
<td>{cur["country"]}</td>
|
||||
<td
|
||||
class={cur["is_active"] === "t"
|
||||
? "text-success"
|
||||
: "text-error"}
|
||||
>{cur["is_active"] === "t"
|
||||
? "Активна"
|
||||
: "Неактивна"}</td
|
||||
class={cur["is_active"] === "t" ? "text-success" : "text-error"}
|
||||
>{cur["is_active"] === "t" ? "Активна" : "Неактивна"}</td
|
||||
>
|
||||
<td>{cur["minor_unit"]}</td>
|
||||
<td>{cur["priority_bank_bybit"]}</td>
|
||||
<td>{rates[cur["code"]] ?? ""}</td>
|
||||
<td>{cur["volume"]}</td>
|
||||
<td>{cur["id"]}</td>
|
||||
<td>
|
||||
@ -194,9 +190,12 @@
|
||||
class="input input-bordered"
|
||||
/>
|
||||
|
||||
<button on:click={()=>{
|
||||
<button
|
||||
on:click={() => {
|
||||
changeCurrency();
|
||||
}} class="btn btn-outline btn-success mt-4">
|
||||
}}
|
||||
class="btn btn-outline btn-success mt-4"
|
||||
>
|
||||
Сохранить
|
||||
</button>
|
||||
<button
|
||||
|
Loading…
x
Reference in New Issue
Block a user