mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(resources/marketplace): more cleanup
This commit is contained in:
1 parent
9f5d5e50a8
commit
bf06c1ed3f
3 files changed
+17
-15
No files matched your search
@@ -15,20 +15,21 @@ onNet(events.SELLOUT_SEND_LISTING, (listing: MarketplaceListing) => {
|
|||||||
RegisterNuiCallbackType(events.SELLOUT_ADD_LISTING);
|
RegisterNuiCallbackType(events.SELLOUT_ADD_LISTING);
|
||||||
on(`__cfx_nui:${events.SELLOUT_ADD_LISTING}`, (data: MarketplaceListing) => {
|
on(`__cfx_nui:${events.SELLOUT_ADD_LISTING}`, (data: MarketplaceListing) => {
|
||||||
emitNet(events.SELLOUT_ADD_LISTING, data);
|
emitNet(events.SELLOUT_ADD_LISTING, data);
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
emitNet(events.SELLOUT_FETCH_LISTING);
|
|
||||||
console.log('Fetched');
|
|
||||||
}, 500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// this will be triggerd when
|
||||||
|
// the adding of a new listing is successfully
|
||||||
|
|
||||||
|
onNet(events.SELLOUT_ADD_LISTING_SUCCESS, () => {
|
||||||
|
emitNet(events.SELLOUT_FETCH_LISTING);
|
||||||
|
});
|
||||||
|
|
||||||
onNet(events.SELLOUT_ACTION_RESULT, (alert: IAlertProps) => {
|
onNet(events.SELLOUT_ACTION_RESULT, (alert: IAlertProps) => {
|
||||||
SendNuiMessage(
|
SendNuiMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
app: "SELLOUT",
|
app: 'SELLOUT',
|
||||||
method: "setAlert",
|
method: 'setAlert',
|
||||||
data: alert
|
data: alert,
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -8,7 +8,6 @@ import { MarketplaceListing } from '../../phone/src/common/typings/marketplace';
|
|||||||
|
|
||||||
const selloutLogger = mainLogger.child({ module: 'sellout' });
|
const selloutLogger = mainLogger.child({ module: 'sellout' });
|
||||||
|
|
||||||
|
|
||||||
async function fetchAllListings(): Promise<MarketplaceListing[]> {
|
async function fetchAllListings(): Promise<MarketplaceListing[]> {
|
||||||
const query = 'SELECT * FROM npwd_sellout_listings ORDER BY id DESC';
|
const query = 'SELECT * FROM npwd_sellout_listings ORDER BY id DESC';
|
||||||
|
|
||||||
@@ -58,10 +57,11 @@ onNet(events.SELLOUT_ADD_LISTING, async (listing: MarketplaceListing) => {
|
|||||||
const phoneNumber = await usePhoneNumber(_identifier);
|
const phoneNumber = await usePhoneNumber(_identifier);
|
||||||
await addListing(_identifier, name, phoneNumber, listing);
|
await addListing(_identifier, name, phoneNumber, listing);
|
||||||
|
|
||||||
|
emitNet(events.SELLOUT_ADD_LISTING_SUCCESS, _source);
|
||||||
emitNet(events.SELLOUT_ACTION_RESULT, _source, {
|
emitNet(events.SELLOUT_ACTION_RESULT, _source, {
|
||||||
message: 'MARKETPLACE_CREATE_LISTING_SUCCESS',
|
message: 'MARKETPLACE_CREATE_LISTING_SUCCESS',
|
||||||
type: 'success'
|
type: 'success',
|
||||||
})
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
selloutLogger.error(`Failed to add listing ${e.message}`, {
|
selloutLogger.error(`Failed to add listing ${e.message}`, {
|
||||||
source: _source,
|
source: _source,
|
||||||
@@ -69,7 +69,7 @@ onNet(events.SELLOUT_ADD_LISTING, async (listing: MarketplaceListing) => {
|
|||||||
|
|
||||||
emitNet(events.SELLOUT_ACTION_RESULT, _source, {
|
emitNet(events.SELLOUT_ACTION_RESULT, _source, {
|
||||||
message: 'MARKETPALCE_CREATE_LISTING_FAILED',
|
message: 'MARKETPALCE_CREATE_LISTING_FAILED',
|
||||||
type: 'error'
|
type: 'error',
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -41,6 +41,7 @@ export default {
|
|||||||
|
|
||||||
// Sellout
|
// Sellout
|
||||||
SELLOUT_ADD_LISTING: 'phone:addListing',
|
SELLOUT_ADD_LISTING: 'phone:addListing',
|
||||||
|
SELLOUT_ADD_LISTING_SUCCESS: 'phone:addListingSuccess',
|
||||||
SELLOUT_FETCH_LISTING: 'phone:fetchAllListings',
|
SELLOUT_FETCH_LISTING: 'phone:fetchAllListings',
|
||||||
SELLOUT_SEND_LISTING: 'phone:sendAllListings',
|
SELLOUT_SEND_LISTING: 'phone:sendAllListings',
|
||||||
SELLOUT_ACTION_RESULT: 'phone:selloutActionResult',
|
SELLOUT_ACTION_RESULT: 'phone:selloutActionResult',
|
||||||
|
|||||||
Reference in new issue
Block a user