mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
fix(sellout/report): Fixed sellout discord reports
This commit is contained in:
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 classes = useStyles();
|
||||||
const { number: myNumber } = useSimcard();
|
const { number: myNumber } = useSimcard();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -30,9 +30,7 @@ export const ListingActions = (listing: MarketplaceListing) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleReportListing = () => {
|
const handleReportListing = () => {
|
||||||
Nui.send('phone:reportListing', {
|
Nui.send('phone:reportListing', listing);
|
||||||
listing,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCall = () => {
|
const handleCall = () => {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export const SelloutItem = (listing: MarketplaceListing) => {
|
|||||||
<Typography variant="h6" style={{ padding: 10 }}>
|
<Typography variant="h6" style={{ padding: 10 }}>
|
||||||
{listing.description}
|
{listing.description}
|
||||||
</Typography>
|
</Typography>
|
||||||
<ListingActions {...listing} />
|
<ListingActions listing={listing} />
|
||||||
</Paper>
|
</Paper>
|
||||||
</div>
|
</div>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ on(`__cfx_nui:${events.SELLOUT_DELETE_LISTING}`, (data: MarketplaceListing, cb:
|
|||||||
|
|
||||||
RegisterNuiCallbackType(events.SELLOUT_REPORT_LISTING);
|
RegisterNuiCallbackType(events.SELLOUT_REPORT_LISTING);
|
||||||
on(`__cfx_nui:${events.SELLOUT_REPORT_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
on(`__cfx_nui:${events.SELLOUT_REPORT_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||||
emitNet(events.SELLOUT_SEND_LISTING, data);
|
emitNet(events.SELLOUT_REPORT_LISTING, data);
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ async function getListing(listingId: number): Promise<MarketplaceListing> {
|
|||||||
const [results] = await pool.query(query, [listingId]);
|
const [results] = await pool.query(query, [listingId]);
|
||||||
const listings = <MarketplaceListing[]>results;
|
const listings = <MarketplaceListing[]>results;
|
||||||
const listing = listings[0];
|
const listing = listings[0];
|
||||||
|
|
||||||
return listing;
|
return listing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +60,8 @@ async function reportListing(listingId: number, profile: string): Promise<void>
|
|||||||
|
|
||||||
async function doesReportExist(listingId: number, profile: string): Promise<boolean> {
|
async function doesReportExist(listingId: number, profile: string): Promise<boolean> {
|
||||||
const query = `SELECT * FROM npwd_marketplace_reports WHERE listing_id = ? AND profile = ?`;
|
const query = `SELECT * FROM npwd_marketplace_reports WHERE listing_id = ? AND profile = ?`;
|
||||||
const results = await pool.query(query, [listingId, profile]);
|
const [results] = await pool.query(query, [listingId, profile]);
|
||||||
const result = <any[]>results;
|
const result = <any>results;
|
||||||
|
|
||||||
return result.length > 0;
|
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
|
// gets the player name (steam) of the player that is reporting
|
||||||
const reportingPlayer = GetPlayerName(pSource);
|
const reportingPlayer = GetPlayerName(pSource);
|
||||||
|
|
||||||
if (reportExists) {
|
if (reportExists) {
|
||||||
// send an info alert
|
// send an info alert
|
||||||
selloutLogger.error(`This listing has already been reported`);
|
selloutLogger.error(`This listing has already been reported`);
|
||||||
|
|
||||||
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
|
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
|
||||||
message: 'MARKETPLACE_REPORT_LISTING_FAILED',
|
message: 'MARKETPLACE_REPORT_LISTING_FAILED',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
@@ -155,7 +152,6 @@ onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => {
|
|||||||
} else {
|
} else {
|
||||||
await reportListing(rListing.id, rListing.name);
|
await reportListing(rListing.id, rListing.name);
|
||||||
await reportListingToDiscord(rListing, reportingPlayer);
|
await reportListingToDiscord(rListing, reportingPlayer);
|
||||||
|
|
||||||
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
|
emitNet(events.SELLOUT_ACTION_RESULT, pSource, {
|
||||||
message: 'MARKETPLACE_REPORT_LISTING_SUCCESS',
|
message: 'MARKETPLACE_REPORT_LISTING_SUCCESS',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
|||||||
Reference in new issue
Block a user