Small tweaks
This commit is contained in:
parent
9f01712230
commit
d0bcdde4c8
@ -105,7 +105,7 @@ begin
|
|||||||
update bank_account
|
update bank_account
|
||||||
set balance = balance + resource_amount / resource_sell_factor
|
set balance = balance + resource_amount / resource_sell_factor
|
||||||
where user_id = p_user_id
|
where user_id = p_user_id
|
||||||
returning resource_amount * resource_sell_factor into return_amount;
|
returning resource_amount / resource_sell_factor into return_amount;
|
||||||
|
|
||||||
sale_result := 'Success';
|
sale_result := 'Success';
|
||||||
end if;
|
end if;
|
||||||
|
@ -13,13 +13,13 @@ const ResourceAccount = (props: {
|
|||||||
const [conversionPair, setConversionPair] = useState<
|
const [conversionPair, setConversionPair] = useState<
|
||||||
IConversionPair | undefined
|
IConversionPair | undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
const [conversionRate, setConversionRate] = useState<number>(0.1);
|
const [conversionRate, setConversionRate] = useState<number>(0);
|
||||||
|
|
||||||
const handleConversionPair = (amount: number, resourceType: string) => {
|
const handleConversionPair = (amount: number, resourceType: string) => {
|
||||||
const updatedPair = {
|
const updatedPair = {
|
||||||
resourceType: resourceType,
|
resourceType: resourceType,
|
||||||
resourceAmount: amount,
|
resourceAmount: amount,
|
||||||
moneyAmount: amount * conversionRate,
|
moneyAmount: amount / conversionRate,
|
||||||
};
|
};
|
||||||
setConversionPair(updatedPair);
|
setConversionPair(updatedPair);
|
||||||
};
|
};
|
||||||
@ -31,6 +31,11 @@ const ResourceAccount = (props: {
|
|||||||
return rate;
|
return rate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSellResource = () => {
|
||||||
|
conversionPair && props.sellResource([conversionPair]);
|
||||||
|
setShowModal(false);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const rate = getConversionRate(props.account);
|
const rate = getConversionRate(props.account);
|
||||||
setConversionRate(rate);
|
setConversionRate(rate);
|
||||||
@ -84,7 +89,7 @@ const ResourceAccount = (props: {
|
|||||||
</p>
|
</p>
|
||||||
{conversionPair && (
|
{conversionPair && (
|
||||||
<button
|
<button
|
||||||
onClick={() => props.sellResource([conversionPair])}
|
onClick={() => handleSellResource()}
|
||||||
className="bg-green-700 py-2 text-slate-900 rounded-lg font-bold w-28 text-center text-white"
|
className="bg-green-700 py-2 text-slate-900 rounded-lg font-bold w-28 text-center text-white"
|
||||||
>
|
>
|
||||||
Sell Now
|
Sell Now
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, { useState, useEffect } from "react";
|
import React from "react";
|
||||||
import {
|
import { IBankAccount, IConversionPair, IGameConfig } from "typings";
|
||||||
IBankAccount,
|
|
||||||
IConversionPair,
|
|
||||||
IGameConfig,
|
|
||||||
IResourceAccount,
|
|
||||||
} from "typings";
|
|
||||||
import Account from "./Account";
|
import Account from "./Account";
|
||||||
import { BiLoaderAlt } from "react-icons/bi";
|
import { BiLoaderAlt } from "react-icons/bi";
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ export default function Home() {
|
|||||||
const [notificationTime, setNotificationTime] = useState(30);
|
const [notificationTime, setNotificationTime] = useState(30);
|
||||||
const [storeItems, setStoreItems] = useState<IStoreItem[] | null>(null);
|
const [storeItems, setStoreItems] = useState<IStoreItem[] | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [activeComponent, setActiveComponent] = useState("inventoryitemview");
|
const [activeComponent, setActiveComponent] = useState("stakingsourcesview");
|
||||||
const [gameConfig, setGameConfig] = useState<IGameConfig>();
|
const [gameConfig, setGameConfig] = useState<IGameConfig>();
|
||||||
|
|
||||||
const isOwned = (storeItemId: number) => {
|
const isOwned = (storeItemId: number) => {
|
||||||
@ -204,7 +204,13 @@ export default function Home() {
|
|||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setNotification({
|
setNotification({
|
||||||
message: `You've received ${data[0].returnAmount} $MoonBucks`,
|
message: `You've received ${data[0].returnAmount.toLocaleString(
|
||||||
|
"en-US",
|
||||||
|
{
|
||||||
|
minimumFractionDigits: 2,
|
||||||
|
maximumFractionDigits: 2,
|
||||||
|
}
|
||||||
|
)} $MoonBucks`,
|
||||||
type: "Success",
|
type: "Success",
|
||||||
});
|
});
|
||||||
fetchBankAccount();
|
fetchBankAccount();
|
||||||
@ -340,6 +346,7 @@ export default function Home() {
|
|||||||
return <p>Loading...</p>;
|
return <p>Loading...</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(bankAccount);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Navbar setUserId={setUserId} />
|
<Navbar setUserId={setUserId} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user