feat(marketplace/nui): useListing interface

This commit is contained in:
Christopher committed 2021-01-14 16:40:33 +01:00
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>
);
};
+1 -1
View File
@@ -3,7 +3,7 @@ import { atom } from 'recoil';
export const selloutState = {
listing: atom({
key: 'listing',
default: [],
default: null,
}),
listingModal: atom({
key: 'listingModal',
+7 -3
View File
@@ -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 };
};
+2 -1
View File
@@ -1,4 +1,5 @@
export interface Listings {
export interface ListingProps {
id: number;
name: string;
phone_number: string;
title: string;