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

+2 -2
View File
@@ -16,7 +16,7 @@ import { useApps } from './os/apps/hooks/useApps';
import { useContactsService } from './apps/contacts/hooks/useContactsService';
import { useTwitterService } from './apps/twitter/hooks/useTwitterService';
import { useMatchService } from './apps/match/hooks/useMatchService';
import { useSelloutService } from './apps/sellout/hooks/useSelloutService';
import { useMarketplaceService } from './apps/marketplace/hooks/useMarketplaceService';
import { useBankService } from './apps/bank/hooks/useBankService';
import { useMessagesService } from './apps/messages/hooks/useMessageService';
import { useNotesService } from './apps/notes/hooks/useNotesService';
@@ -68,7 +68,7 @@ function Phone() {
useContactsService();
useTwitterService();
useMatchService();
useSelloutService();
useMarketplaceService();
useBankService();
useMessagesService();
useNotesService();
@@ -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);
+6 -1
View File
@@ -189,16 +189,21 @@
"APPS_SETTING_STREAMER_MODE_DESC": "Hide images before they are shown",
"APPS_MARKETPLACE_CREATE_LISTING_SUCCESS": "Successfully created a new listing",
"APPS_MARKETPALCE_CREATE_LISTING_FAILED": "Failed to create a new listing",
"APPS_MARKETPLACE_CREATE_LISTING_FAILED": "Failed to create a new listing",
"APPS_MARKETPLACE_DELETE_LISTING_SUCCESS": "Successfully delete listing",
"APPS_MARKETPLACE_DELETE_LISTING_FAILED": "Failed to delete listing",
"APPS_MARKETPLACE_REPORT_LISTING_FAILED": "This listing has already been reported",
"APPS_MARKETPLACE_REPORT_LISTING_SUCCESS": "Successfully reported listing",
"APPS_MARKETPLACE_REQUIRED_FIELDS": "All required fields must be filled!",
"APPS_MARKETPLACE_FORM_TITLE": "Title",
"APPS_MARKETPLACE_FORM_IMAGE": "Image or URL",
"APPS_MARKETPLACE_FORM_DESCRIPTION": "Description",
"GENERIC_CLICK_TO_REVEAL": "Click to reveal",
"GENERIC_WAIT": "Please wait...",
"GENERIC_SAVE": "Save",
"GENERIC_UPDATE": "Update",
"GENERIC_REQUIRED": "Required",
"GENERIC_DELETE": "Delete",
"GENERIC_REPORT": "Report",
"GENERIC_CALL": "Call",
+4 -4
View File
@@ -25,7 +25,7 @@ import { MessagesApp } from '../../../apps/messages/components/MessagesApp';
import { MatchApp } from '../../../apps/match/components/MatchApp';
import { TwitterApp } from '../../../apps/twitter/components/TwitterApp';
import { ExampleApp } from '../../../apps/example/components/ExampleApp';
import { SelloutApp } from '../../../apps/sellout/components/SelloutApp';
import { MarketplaceApp } from '../../../apps/marketplace/components/MarketplaceApp';
import { NotesApp } from '../../../apps/notes/NotesApp';
import CameraApp from '../../../apps/camera/components/CameraApp';
import { AppRoute } from '../components/AppRoute';
@@ -41,7 +41,7 @@ import {
import {
SELLOUT_APP_PRIMARY_COLOR,
SELLOUT_APP_ICON_COLOR,
} from '../../../apps/sellout/sellout.theme';
} from '../../../apps/marketplace/marketplace.theme';
import { NOTES_APP_ICON_COLOR, NOTES_APP_PRIMARY_COLOR } from '../../../apps/notes/notes.theme';
import { DIALER_APP_PRIMARY_COLOR, DIALER_APP_TEXT_COLOR } from '../../../apps/dialer/dialer.theme';
import {
@@ -149,8 +149,8 @@ export const APPS: IAppConfig[] = [
notificationIcon: <FontAwesomeIcon icon={faAd} fixedWidth size="xs" />,
backgroundColor: SELLOUT_APP_PRIMARY_COLOR,
color: SELLOUT_APP_ICON_COLOR,
path: '/sellout',
Route: () => <AppRoute id="SELLOUT" path="/sellout" component={SelloutApp} />,
path: '/marketplace',
Route: () => <AppRoute id="MARKETPLACE" path="/marketplace" component={MarketplaceApp} />,
},
{
id: 'NOTES',
File renamed without changes.
+1 -1
View File
@@ -3,7 +3,7 @@ import ClientUtils from './cl_utils';
import './cl_main';
import './cl_twitter';
import './cl_contacts';
import './cl_sellout';
import './cl_marketplace';
import './cl_bank';
import './cl_notes';
import './cl_photo';
+1 -1
View File
@@ -4,7 +4,7 @@ import './db';
import './sv_twitter';
import './sv_main';
import './sv_contacts';
import './sv_sellout';
import './sv_marketplace';
import './sv_bank';
import './sv_notes';
import './sv_photo';
File renamed without changes.