mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
bank cleanup
This commit is contained in:
1 parent
d0ed913d7c
commit
6ee401e3d5
1 file changed
+9
-16
@@ -1,30 +1,24 @@
|
||||
import events from '../utils/events';
|
||||
import { ESX } from './server';
|
||||
import { getSource } from "./functions";
|
||||
import { pool } from './db';
|
||||
import { Transfer, Credentials } from '../../phone/src/common/interfaces/bank';
|
||||
import { useIdentifier } from './functions';
|
||||
import { type } from 'os';
|
||||
import {ESX} from './server';
|
||||
import {getSource, useIdentifier} from "./functions";
|
||||
import {pool} from './db';
|
||||
import {IBankCredentials, Transfer} from '../../phone/src/common/typings/bank';
|
||||
|
||||
|
||||
async function fetchAllTransactions(identifier: string): Promise<Transfer[]> {
|
||||
const query = "SELECT * FROM npwd_bank_transfers WHERE identifier = ? ORDER BY id DESC"
|
||||
const [ results ] = await pool.query(query, [identifier])
|
||||
const transactions = <Transfer[]>results;
|
||||
|
||||
return transactions;
|
||||
return <Transfer[]>results;
|
||||
}
|
||||
|
||||
function fetchCredentials(): Credentials {
|
||||
function fetchCredentials(): IBankCredentials {
|
||||
const name = ESX.GetPlayerFromId(getSource()).getName();
|
||||
const balance = ESX.GetPlayerFromId(getSource()).getAccount('bank').money
|
||||
|
||||
const result = {
|
||||
return {
|
||||
name,
|
||||
balance
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
async function addTransfer(identifier: string, transfer: Transfer): Promise<any> {
|
||||
@@ -86,11 +80,10 @@ onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||
|
||||
onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
||||
const targetSource = xTarget.source;
|
||||
try {
|
||||
const _identifier = await useIdentifier()
|
||||
const transferNotify = await addTransfer(_identifier, transfer)
|
||||
emitNet(events.BANK_TRANSACTION_NOTIFICATION, targetSource, transferNotify)
|
||||
emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify)
|
||||
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, getSource());
|
||||
} catch (error) {
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false)
|
||||
|
||||
Reference in new issue
Block a user