mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
1 parent
baf6dedb6f
commit
a88286f97a
23 files changed
+85
-52
No files matched your search
@@ -0,0 +1,8 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
export const selloutState = {
|
||||
listing: atom({
|
||||
key: 'listing',
|
||||
default: [],
|
||||
}),
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { MarketplaceListing } from '../../../../../typings/marketplace';
|
||||
import { selloutState } from './state';
|
||||
|
||||
export const useListing = () => {
|
||||
return useRecoilValue<MarketplaceListing[]>(selloutState.listing);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||
import { selloutState } from './state';
|
||||
import { useListing } from './useListing';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { MarketplaceEvents } from '../../../../../typings/marketplace';
|
||||
|
||||
export const useMarketplaceService = () => {
|
||||
const setSellout = useSetRecoilState(selloutState.listing);
|
||||
const { addAlert } = useSnackbar();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleAddAlert = ({ message, type }: IAlert) => {
|
||||
addAlert({
|
||||
message: t(`APPS_${message}`),
|
||||
type,
|
||||
});
|
||||
};
|
||||
|
||||
useNuiEvent('SELLOUT', MarketplaceEvents.SEND_ALERT, handleAddAlert);
|
||||
useNuiEvent('SELLOUT', MarketplaceEvents.SEND_LISTING, setSellout);
|
||||
return useListing();
|
||||
};
|
||||
Reference in new issue
Block a user