fix(sellout/report): Fixed sellout discord reports

This commit is contained in:
Taso committed 2021-03-10 21:04:59 -05:00
1 parent ea5b034fbe
commit c6bdf4b331
4 files changed
+6 -12

No files matched your search

@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}));
export const ListingActions = (listing: MarketplaceListing) => {
export const ListingActions = ({ listing }: { listing: MarketplaceListing }) => {
const classes = useStyles();
const { number: myNumber } = useSimcard();
const { t } = useTranslation();
@@ -30,9 +30,7 @@ export const ListingActions = (listing: MarketplaceListing) => {
};
const handleReportListing = () => {
Nui.send('phone:reportListing', {
listing,
});
Nui.send('phone:reportListing', listing);
};
const handleCall = () => {
@@ -62,7 +62,7 @@ export const SelloutItem = (listing: MarketplaceListing) => {
<Typography variant="h6" style={{ padding: 10 }}>
{listing.description}
</Typography>
<ListingActions {...listing} />
<ListingActions listing={listing} />
</Paper>
</div>
</ListItem>
+1 -1
View File
@@ -26,7 +26,7 @@ on(`__cfx_nui:${events.SELLOUT_DELETE_LISTING}`, (data: MarketplaceListing, cb:
RegisterNuiCallbackType(events.SELLOUT_REPORT_LISTING);
on(`__cfx_nui:${events.SELLOUT_REPORT_LISTING}`, (data: MarketplaceListing, cb: Function) => {
emitNet(events.SELLOUT_SEND_LISTING, data);
emitNet(events.SELLOUT_REPORT_LISTING, data);
cb();
});
+2 -6
View File
@@ -49,7 +49,6 @@ async function getListing(listingId: number): Promise<MarketplaceListing> {
const [results] = await pool.query(query, [listingId]);
const listings = <MarketplaceListing[]>results;
const listing = listings[0];
return listing;
}
@@ -61,8 +60,8 @@ async function reportListing(listingId: number, profile: string): Promise<void>
async function doesReportExist(listingId: number, profile: string): Promise<boolean> {
const query = `SELECT * FROM npwd_marketplace_reports WHERE listing_id = ? AND profile = ?`;
const results = await pool.query(query, [listingId, profile]);
const result = <any[]>results;
const [results] = await pool.query(query, [listingId, profile]);
const result = <any>results;
return result.length > 0;
}
@@ -143,11 +142,9 @@ onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => {
// gets the player name (steam) of the player that is reporting
const reportingPlayer = GetPlayerName(pSource);
if (reportExists) {
// send an info alert
selloutLogger.error(`This listing has already been reported`);
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
message: 'MARKETPLACE_REPORT_LISTING_FAILED',
type: 'info',
@@ -155,7 +152,6 @@ onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => {
} else {
await reportListing(rListing.id, rListing.name);
await reportListingToDiscord(rListing, reportingPlayer);
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
message: 'MARKETPLACE_REPORT_LISTING_SUCCESS',
type: 'success',