mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Tweak/marketplace additions (#137)
Checks for being the OP of the listing. Calling, Message, Delete and Report. Updates to Locale is needed.
This commit is contained in:
1 parent
0203ebbe51
commit
6b6080c4b2
13 files changed
+277
-47
No files matched your search
@@ -34,7 +34,7 @@ InjectDebugData([
|
||||
{
|
||||
id: 1,
|
||||
name: 'Some guy',
|
||||
number: '123-4567',
|
||||
number: '111-1134',
|
||||
title: 'Car',
|
||||
description: 'Selling this cool car',
|
||||
url: 'https://i.imgur.com/ROmGTwi.jpeg',
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import { Box, Tooltip, Button } from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import React from 'react';
|
||||
import { MarketplaceListing } from '../../../../common/typings/marketplace';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import DeleteIcon from '@material-ui/icons/Delete';
|
||||
import ReportIcon from '@material-ui/icons/Report';
|
||||
import ChatIcon from '@material-ui/icons/Chat';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
icon: {
|
||||
color: theme.palette.primary.main,
|
||||
},
|
||||
}));
|
||||
|
||||
export const ListingActions = (listing: MarketplaceListing) => {
|
||||
const classes = useStyles();
|
||||
const { number: myNumber } = useSimcard();
|
||||
const { t } = useTranslation();
|
||||
const history = useHistory();
|
||||
|
||||
const handleDeleteListing = () => {
|
||||
Nui.send('phone:marketplaceDeleteListing', {
|
||||
id: listing.id,
|
||||
});
|
||||
};
|
||||
|
||||
const handleReportListing = () => {
|
||||
Nui.send('phone:reportListing', {
|
||||
listing,
|
||||
});
|
||||
};
|
||||
|
||||
const handleCall = () => {
|
||||
Nui.send('phone:beginCall', {
|
||||
number: listing.number,
|
||||
});
|
||||
};
|
||||
|
||||
const handleMessage = () => {
|
||||
history.push(`/messages/new/${listing.number}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box flex justifyContent="space-between" alignItems="center">
|
||||
<div style={{ float: 'left' }}>
|
||||
{listing.number !== myNumber ? (
|
||||
<>
|
||||
<Tooltip title={t('GENERIC_MESSAGE')}>
|
||||
<Button onClick={handleMessage}>
|
||||
<ChatIcon className={classes.icon} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip title={`${t('GENERIC_CALL')}: ${listing.number}`}>
|
||||
<Button onClick={handleCall}>
|
||||
<PhoneIcon className={classes.icon} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div style={{ float: 'right' }}>
|
||||
{listing.number === myNumber ? (
|
||||
<Tooltip title={t('GENERIC_DELETE')}>
|
||||
<Button onClick={handleDeleteListing}>
|
||||
<DeleteIcon />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Tooltip title={t('GENERIC_REPORT')}>
|
||||
<Button onClick={handleReportListing}>
|
||||
<ReportIcon />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { Button, Typography, Paper } from '@material-ui/core';
|
||||
import { Typography, Paper } from '@material-ui/core';
|
||||
import { ListItem } from '../../../../ui/components/ListItem';
|
||||
import ChatIcon from '@material-ui/icons/Chat';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import { PictureResponsive } from '../../../../ui/components/PictureResponsive';
|
||||
import { MarketplaceListing } from '../../../../common/typings/marketplace';
|
||||
import { ListingActions } from './ListingActions';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -30,42 +30,26 @@ const useStyles = makeStyles((theme) => ({
|
||||
background: theme.palette.background.default,
|
||||
marginBottom: 20,
|
||||
},
|
||||
icon: {
|
||||
color: theme.palette.primary.main,
|
||||
},
|
||||
header: {
|
||||
margin: 10,
|
||||
},
|
||||
headerTypo: {
|
||||
margin: 5,
|
||||
},
|
||||
desc: {
|
||||
padding: 10,
|
||||
},
|
||||
}));
|
||||
|
||||
export const SelloutItem = (listing) => {
|
||||
export const SelloutItem = (listing: MarketplaceListing) => {
|
||||
const classes = useStyles();
|
||||
|
||||
return (
|
||||
<ListItem className={classes.root}>
|
||||
<div className={classes.content}>
|
||||
<Paper elevation={2} className={classes.paper}>
|
||||
<div className={classes.header}>
|
||||
<Typography className={classes.headerTypo} variant="h5">
|
||||
<div style={{ margin: 10 }}>
|
||||
<Typography style={{ margin: 5 }} variant="h5">
|
||||
{listing.name}
|
||||
</Typography>
|
||||
<Typography
|
||||
className={classes.headerTypo}
|
||||
style={{ borderBottom: '1px solid #f44336' }}
|
||||
>
|
||||
{listing.number}
|
||||
</Typography>
|
||||
<Typography variant="h5" style={{ padding: 5 }}>
|
||||
{listing.title}
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
{listing.url ? (
|
||||
<PictureResponsive src={listing.url} alt={`${listing.name} image`} />
|
||||
<PictureResponsive src={listing.url} alt={`${listing.name}`} />
|
||||
) : (
|
||||
<Typography style={{ margin: 10 }}>
|
||||
No image provided{' '}
|
||||
@@ -74,17 +58,11 @@ export const SelloutItem = (listing) => {
|
||||
</span>
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="h6" className={classes.desc}>
|
||||
|
||||
<Typography variant="h6" style={{ padding: 10 }}>
|
||||
{listing.description}
|
||||
</Typography>
|
||||
<div>
|
||||
<Button>
|
||||
<ChatIcon className={classes.icon} />
|
||||
</Button>
|
||||
<Button>
|
||||
<PhoneIcon className={classes.icon} />
|
||||
</Button>
|
||||
</div>
|
||||
<ListingActions {...listing} />
|
||||
</Paper>
|
||||
</div>
|
||||
</ListItem>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import React from 'react';
|
||||
import { List } from '../../../../ui/components/List';
|
||||
import { useListing } from '../../hooks/useListing';
|
||||
import { SelloutItem } from './SelloutItem';
|
||||
|
||||
export const SelloutList = ({ listings }) => {
|
||||
export const SelloutList = () => {
|
||||
const listings = useListing();
|
||||
|
||||
return (
|
||||
<List>
|
||||
{listings.map((listing) => (
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React from 'react';
|
||||
import { useListing } from '../../hooks/useListing';
|
||||
import { SelloutList } from './SelloutList';
|
||||
|
||||
export const SelloutListContainer = () => {
|
||||
const { listing } = useListing();
|
||||
return <SelloutList listings={listing} />;
|
||||
return <SelloutList />;
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { MarketplaceListing } from '../../../common/typings/marketplace';
|
||||
import { selloutState } from './state';
|
||||
|
||||
export const useListing = () => {
|
||||
const listing = useRecoilValue(selloutState.listing);
|
||||
return { listing };
|
||||
return useRecoilValue<MarketplaceListing[]>(selloutState.listing);
|
||||
};
|
||||
Reference in new issue
Block a user