Improve/marketplace (#184)

Overall fixes for sellout => marketplace.
This commit is contained in:
Christopher Gjelten authored and GitHub committed 2021-03-28 04:20:12 +02:00
1 parent baf6dedb6f
commit a88286f97a
23 files changed
+85 -52

No files matched your search

@@ -1,28 +1,28 @@
import React from 'react';
import { AppWrapper } from '../../../ui/components/AppWrapper';
import { AppContent } from '../../../ui/components/AppContent';
import { SelloutTitle } from './SelloutTitle';
import { SelloutListContainer } from './SelloutList/SelloutListContainer';
import { MarketplaceTitle } from './MarketplaceTitle';
import { MarketplaceListContainer } from './SelloutList/MarketplaceListContainer';
import { NavigationBar } from './navigation/NavigationBar';
import { Switch, Route } from 'react-router-dom';
import { ListingFormContainer } from './form/ListingFormContainer';
import InjectDebugData from '../../../os/debug/InjectDebugData';
import { SelloutThemeProvider } from '../providers/SelloutThemeProvider';
import { MarketplaceThemeProvider } from '../providers/MarketplaceThemeProvider';
export const SelloutApp = () => {
export const MarketplaceApp = () => {
return (
<SelloutThemeProvider>
<MarketplaceThemeProvider>
<AppWrapper id="sellout-app">
<SelloutTitle />
<MarketplaceTitle />
<AppContent>
<Switch>
<Route path="/sellout" exact component={SelloutListContainer} />
<Route path="/sellout/new" component={ListingFormContainer} />
<Route path="/marketplace" exact component={MarketplaceListContainer} />
<Route path="/marketplace/new" component={ListingFormContainer} />
</Switch>
</AppContent>
<NavigationBar />
</AppWrapper>
</SelloutThemeProvider>
</MarketplaceThemeProvider>
);
};
@@ -35,8 +35,9 @@ InjectDebugData([
id: 1,
name: 'Some guy',
number: '111-1134',
title: 'Car',
description: 'Selling this cool car',
title: 'eeeeeeeeeeeeeeeeeeeeeeeee',
description:
'skldfsd sajsfjklsdfj sdajsklfjdsjklas jskj sdjsd jasdkl sdjsf jasdklsfjfj kljasdkf jkaf jsdkla jsk jdkla j kljasdkf jkld jasd kljk',
url: 'https://beta.iodine.gg/706Y3.jpeg',
},
{
@@ -20,7 +20,7 @@ const useStyles = makeStyles((theme) => ({
},
}));
export const SelloutTitle = () => {
export const MarketplaceTitle = () => {
const classes = useStyles();
return (
<Paper className={classes.root} square variant="outlined" elevation={24}>
@@ -33,7 +33,7 @@ const useStyles = makeStyles((theme) => ({
},
}));
export const SelloutItem = (listing: MarketplaceListing) => {
export const MarketplaceItem = (listing: MarketplaceListing) => {
const classes = useStyles();
return (
@@ -62,7 +62,7 @@ export const SelloutItem = (listing: MarketplaceListing) => {
</Typography>
)}
<Typography variant="h6" style={{ padding: 10 }}>
<Typography variant="body1" style={{ padding: 10 }}>
{listing.description}
</Typography>
<ListingActions listing={listing} />
@@ -1,15 +1,15 @@
import React from 'react';
import { List } from '../../../../ui/components/List';
import { useListing } from '../../hooks/useListing';
import { SelloutItem } from './SelloutItem';
import { MarketplaceItem } from './MarketplaceItem';
export const SelloutList = () => {
export const MarketplaceList = () => {
const listings = useListing();
return (
<List>
{listings.map((listing) => (
<SelloutItem key={listing.id} {...listing} />
<MarketplaceItem key={listing.id} {...listing} />
))}
</List>
);
@@ -0,0 +1,6 @@
import React from 'react';
import { MarketplaceList } from './MarketplaceList';
export const MarketplaceListContainer = () => {
return <MarketplaceList />;
};
@@ -1,7 +1,10 @@
import React, { useState } from 'react';
import { makeStyles, Button, TextField } from '@material-ui/core';
import { makeStyles, Button, TextField, Typography } from '@material-ui/core';
import Nui from '../../../../os/nui-events/utils/Nui';
import { MarketplaceEvents } from '../../../../../../typings/marketplace';
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router';
const useStyles = makeStyles((theme) => ({
root: {
@@ -29,17 +32,28 @@ const useStyles = makeStyles((theme) => ({
export const ListingForm = () => {
const classes = useStyles();
const { t } = useTranslation();
const { addAlert } = useSnackbar();
const history = useHistory();
const [title, setTitle] = useState('');
const [url, setUrl] = useState('');
const [description, setDescription] = useState('');
const addListing = () => {
Nui.send(MarketplaceEvents.ADD_LISTING, {
title,
url,
description,
});
if (title !== '' && description !== '') {
Nui.send(MarketplaceEvents.ADD_LISTING, {
title,
url,
description,
});
history.push('/marketplace');
} else {
addAlert({
message: t('APPS_MARKETPLACE_REQUIRED_FIELDS'),
type: 'error',
});
}
};
return (
@@ -48,15 +62,22 @@ export const ListingForm = () => {
<TextField
className={classes.input}
onChange={(e) => setTitle(e.target.value)}
placeholder="Title on listing.."
inputProps={{ className: classes.textFieldInput }}
label={t('GENERIC_REQUIRED')}
placeholder={t('APPS_MARKETPLACE_FORM_TITLE')}
inputProps={{
className: classes.textFieldInput,
maxLength: 25,
}}
style={{ width: '80%' }}
size="medium"
InputLabelProps={{
shrink: true,
}}
/>
<TextField
className={classes.input}
placeholder="Image URL"
placeholder={t('APPS_MARKETPLACE_FORM_IMAGE')}
onChange={(e) => setUrl(e.target.value)}
inputProps={{ className: classes.textFieldInput }}
style={{ width: '80%' }}
@@ -67,15 +88,21 @@ export const ListingForm = () => {
<TextField
className={classes.input}
onChange={(e) => setDescription(e.target.value)}
placeholder="Description"
inputProps={{ className: classes.multilineFieldInput }}
label={t('GENERIC_REQUIRED')}
placeholder={t('APPS_MARKETPLACE_FORM_DESCRIPTION')}
inputProps={{
className: classes.multilineFieldInput,
maxLength: 130,
}}
style={{ width: '80%' }}
size="medium"
InputLabelProps={{
shrink: true,
}}
multiline
rows={4}
variant="outlined"
/>
<Button onClick={addListing} className={classes.postButton}>
Post
</Button>
@@ -31,9 +31,9 @@ export const NavigationBar = () => {
<BottomNavigationAction
component={Link}
icon={<FontAwesomeIcon icon={faHome} />}
to="/sellout"
to="/marketplace"
/>
<BottomNavigationAction component={Link} icon={<AddCircleIcon />} to="/sellout/new" />
<BottomNavigationAction component={Link} icon={<AddCircleIcon />} to="/marketplace/new" />
</BottomNavigation>
);
};
@@ -6,7 +6,7 @@ import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import { MarketplaceEvents } from '../../../../../typings/marketplace';
export const useSelloutService = () => {
export const useMarketplaceService = () => {
const setSellout = useSetRecoilState(selloutState.listing);
const { addAlert } = useSnackbar();
const { t } = useTranslation();
@@ -0,0 +1,5 @@
import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider';
import selloutTheme from '../marketplace.theme';
export const MarketplaceThemeProvider = createAppThemeProvider(selloutTheme);
@@ -1,6 +0,0 @@
import React from 'react';
import { SelloutList } from './SelloutList';
export const SelloutListContainer = () => {
return <SelloutList />;
};
@@ -1,5 +0,0 @@
import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider';
import selloutTheme from '../sellout.theme';
export const SelloutThemeProvider = createAppThemeProvider(selloutTheme);