mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 06:28:51 +00:00
feat(marketplace/nui): useListing interface
This commit is contained in:
1 parent
d443b794c3
commit
60bf8be58d
5 files changed
+13
-8
No files matched your search
@@ -8,7 +8,7 @@ export const SelloutList = ({ listings }) => {
|
||||
<div>
|
||||
<SelloutSearch />
|
||||
<List style={{ backgroundColor: '#F6F6F6' }}>
|
||||
{listings.map((listing) => (
|
||||
{listings?.map(listing => (
|
||||
<SelloutItem key={listing.id} {...listing} />
|
||||
))}
|
||||
</List>
|
||||
|
||||
@@ -20,12 +20,12 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||
export const SelloutListContainer = () => {
|
||||
const { modal } = useListingModal();
|
||||
const { itemModal } = useItemModal();
|
||||
const listing = useListing();
|
||||
const { listings } = useListing();
|
||||
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<div className={modal ? classes.hidden : classes.show}>
|
||||
{itemModal ? <ItemModal /> : <SelloutList listings={listing} />}
|
||||
{itemModal ? <ItemModal /> : <SelloutList listings={listings} />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -3,7 +3,7 @@ import { atom } from 'recoil';
|
||||
export const selloutState = {
|
||||
listing: atom({
|
||||
key: 'listing',
|
||||
default: [],
|
||||
default: null,
|
||||
}),
|
||||
listingModal: atom({
|
||||
key: 'listingModal',
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { selloutState } from './state';
|
||||
|
||||
import { Listings } from '../../../common/typings/listings';
|
||||
import { ListingProps } from '../../../common/typings/listings';
|
||||
|
||||
export const useListing = () => {
|
||||
interface ListingHook {
|
||||
listings: ListingProps[];
|
||||
}
|
||||
|
||||
export const useListing = (): ListingHook => {
|
||||
const listings = useRecoilValue(selloutState.listing);
|
||||
return listings;
|
||||
return { listings };
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
export interface Listings {
|
||||
export interface ListingProps {
|
||||
id: number;
|
||||
name: string;
|
||||
phone_number: string;
|
||||
title: string;
|
||||
|
||||
Reference in new issue
Block a user