diff --git a/phone/src/apps/sellout/hooks/useSelloutService.ts b/phone/src/apps/sellout/hooks/useSelloutService.ts index cac461d..98b9094 100644 --- a/phone/src/apps/sellout/hooks/useSelloutService.ts +++ b/phone/src/apps/sellout/hooks/useSelloutService.ts @@ -2,9 +2,13 @@ import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent'; import { selloutState } from './state'; import { useListing } from './useListing'; import { useSetRecoilState } from 'recoil'; +import { useSnackbar } from '../../../ui/hooks/useSnackbar'; export const useSelloutService = () => { const setSellout = useSetRecoilState(selloutState.listing); + const { addAlert } = useSnackbar(); + + useNuiEvent('SELLOUT', 'setAlert', addAlert); useNuiEvent('SELLOUT', 'setListings', setSellout); return useListing(); -}; +}; \ No newline at end of file diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json index 9e8e908..c5e21aa 100644 --- a/phone/src/locale/en.json +++ b/phone/src/locale/en.json @@ -100,6 +100,9 @@ "APPS_SETTINGS_OPTION_RINGTONE": "Ringtone", "APPS_SETTINGS_OPTION_RINGTONEVOL": "Ringtone Volume", + "APPS_MARKETPLACE_CREATE_LISTING_SUCCESS": "Successfully created a new listing", + "APPS_MARKETPALCE_CREATE_LISTING_FAILED": "Failed to create a new listing", + "GENERIC_SAVE": "Save", "GENERIC_UPDATE": "Update", "GENERIC_DELETE": "Delete" diff --git a/resources/client/cl_sellout.ts b/resources/client/cl_sellout.ts index 32f6609..584b7dd 100644 --- a/resources/client/cl_sellout.ts +++ b/resources/client/cl_sellout.ts @@ -12,11 +12,21 @@ onNet(events.SELLOUT_SEND_LISTING, (listing: any) => { RegisterNuiCallbackType(events.SELLOUT_ADD_LISTING); on(`__cfx_nui:${events.SELLOUT_ADD_LISTING}`, (data: any) => { - const listing = data; - emitNet(events.SELLOUT_ADD_LISTING, listing); + emitNet(events.SELLOUT_ADD_LISTING, data); setTimeout(() => { emitNet(events.SELLOUT_FETCH_LISTING); console.log('Fetched'); }, 500); }); + + +onNet(events.SELLOUT_ACTION_RESULT, (alert: { message: string, type: string }) => { + SendNuiMessage( + JSON.stringify({ + app: "SELLOUT", + method: "setAlert", + data: alert + }) + ) +}) \ No newline at end of file diff --git a/resources/server/sv_sellout.ts b/resources/server/sv_sellout.ts index c3bda7e..767ae9d 100644 --- a/resources/server/sv_sellout.ts +++ b/resources/server/sv_sellout.ts @@ -62,9 +62,19 @@ onNet(events.SELLOUT_ADD_LISTING, async (listing: Listing) => { const phoneNumber = await usePhoneNumber(_identifier); await addListing(_identifier, name, phoneNumber, listing); + + emitNet(events.SELLOUT_ACTION_RESULT, _source, { + message: 'MARKETPLACE_CREATE_LISTING_SUCCESS', + type: 'success' + }) } catch (e) { selloutLogger.error(`Failed to add listing ${e.message}`, { source: _source, }); + + emitNet(events.SELLOUT_ACTION_RESULT, _source, { + message: 'MARKETPALCE_CREATE_LISTING_FAILED', + type: 'error' + }) } }); diff --git a/resources/utils/events.ts b/resources/utils/events.ts index 3a8e52f..2cef8db 100644 --- a/resources/utils/events.ts +++ b/resources/utils/events.ts @@ -37,11 +37,13 @@ export default { CONTACTS_DELETE_CONTACT: 'phone:deleteContact', CONTACTS_DELETE_CONTACT_SUCCESS: 'contacts:deleteSuccess', CONTACTS_UPDATE_CONTACT_SUCCESS: 'phone:updateContactSuccess', + CONTACTS_ACTION_RESULT: 'phone:contactActionResult', // Sellout SELLOUT_ADD_LISTING: 'phone:addListing', SELLOUT_FETCH_LISTING: 'phone:fetchAllListings', SELLOUT_SEND_LISTING: 'phone:sendAllListings', + SELLOUT_ACTION_RESULT: 'phone:selloutActionResult', // BANK_ADD_TRANSFER: 'phone:addTransfer', @@ -66,6 +68,7 @@ export default { MESSAGES_FETCH_MESSAGES: 'phone:fetchMessages', MESSAGES_FETCH_MESSAGES_SUCCESS: 'phone:fetchMessagesSuccess', MESSAGES_FETCH_MESSAGES_FAILED: 'phone:fetchMessagesFailed', + MESSAGES_ACTION_RESULT: 'phone:messagesActionResult', // Notes NOTE_ADD_NOTE: 'phone:addNote', @@ -95,7 +98,6 @@ export default { CAMERA_SEND_PHOTOS: 'phone:SendPhotos', CAMERA_DELETE_PHOTO: 'photo:deletePhoto', CAMERA_DELETE_PHOTO_SUCCESS: 'phone:deletePhotoSuccess', - CONTACTS_ACTION_RESULT: 'phone:contactActionResult', // copy PHONE_USE_CLIPBOARD: 'phone:useClipboard',