Skip to content

Commit 83dcdef

Browse files
authored
FE fixes (#497)
* VB-451: hide tabs: "Settings", "Messages" * VB-450: fix localization text * VB-449: fix price inputs * VB-447: fix showing date at create auction page, fix localization at datepicker * VB-447: fix min date of auction ending
1 parent e8d9141 commit 83dcdef

File tree

14 files changed

+84
-54
lines changed

14 files changed

+84
-54
lines changed

packages/frontend/components/header/burger-menu/profile-dropdown/component.tsx

+17-10
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,28 @@ export const ProfileDropdown = ({
4747
cssExtend: styles.option,
4848
},
4949
{
50-
value: t('common:header.popover.settings'),
51-
key: 'Settings',
52-
onClick: () => push(`${Routes.PROFILE}${ProfileRoutes.ACCOUNT_SETTINGS}`),
53-
cssExtend: styles.option,
54-
},
55-
{
56-
value: t('common:header.popover.messages'),
57-
key: 'Messages',
58-
onClick: () => push(`${Routes.PROFILE}${ProfileRoutes.MESSAGES}`),
50+
value: t('common:header.popover.notifications'),
51+
key: 'Notifications',
52+
onClick: () => push(`${Routes.PROFILE}${ProfileRoutes.NOTIFICATIONS}`),
5953
cssExtend: styles.option,
6054
},
55+
// {
56+
// value: t('common:header.popover.settings'),
57+
// key: 'Settings',
58+
// onClick: () => push(`${Routes.PROFILE}${ProfileRoutes.ACCOUNT_SETTINGS}`),
59+
// cssExtend: styles.option,
60+
// },
61+
// {
62+
// value: t('common:header.popover.messages'),
63+
// key: 'Messages',
64+
// onClick: () => push(`${Routes.PROFILE}${ProfileRoutes.MESSAGES}`),
65+
// cssExtend: styles.option,
66+
// },
6167
{
6268
value: t('common:header.popover.support'),
6369
key: 'Support',
64-
onClick: () => push(`${Routes.PROFILE}${ProfileRoutes.SUPPORT}`),
70+
onClick: () =>
71+
(location.href = 'mailto:[email protected]?subject=Support'),
6572
cssExtend: styles.option,
6673
},
6774
];

packages/frontend/components/header/profile-info/sub-components/popover-content.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ export const PopoverContent = ({ handleClose }: PopoverContentProps) => {
4545
<Icon icon={IconName.LIST} color={IconColor.YELLOW} />
4646
<span>{t('common:header.popover.myList')}</span>
4747
</button>
48-
<button
48+
{/* <button
4949
css={styles.popoverContentItem}
5050
onClick={handleClick}
5151
path-label={`${Routes.PROFILE}${ProfileRoutes.ACCOUNT_SETTINGS}`}
5252
data-variant="icon"
5353
>
5454
<Icon icon={IconName.SETTINGS} color={IconColor.YELLOW} />
5555
<span>{t('common:header.popover.settings')}</span>
56-
</button>
56+
</button> */}
5757
<button
5858
css={styles.popoverContentItem}
5959
onClick={handleClick}
@@ -63,18 +63,20 @@ export const PopoverContent = ({ handleClose }: PopoverContentProps) => {
6363
<Icon icon={IconName.BELL} color={IconColor.YELLOW} />
6464
<span>{t('common:header.popover.notifications')}</span>
6565
</button>
66-
<button
66+
{/* <button
6767
css={styles.popoverContentItem}
6868
onClick={handleClick}
6969
path-label={`${Routes.PROFILE}${ProfileRoutes.MESSAGES}`}
7070
data-variant="icon"
7171
>
7272
<Icon icon={IconName.MESSAGE} color={IconColor.YELLOW} />
7373
<span>{t('common:header.popover.messages')}</span>
74-
</button>
74+
</button> */}
7575
<button
7676
css={styles.popoverContentItem}
77-
onClick={handleClick}
77+
onClick={() =>
78+
(location.href = 'mailto:[email protected]?subject=Support')
79+
}
7880
path-label={`${Routes.PROFILE}${ProfileRoutes.SUPPORT}`}
7981
data-variant="icon"
8082
>

packages/frontend/components/primitives/input/date-input.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as styles from './styles';
88

99
import 'react-datepicker/dist/react-datepicker.css';
1010

11-
export const SECONDS_IN_ONE_DAY = 86400000; // +1 day
11+
export const MILISECONDS_IN_ONE_DAY = 1000 * 60 * 60 * 24; // +1 day
1212

1313
const InputDate = ({
1414
value,
@@ -17,6 +17,7 @@ const InputDate = ({
1717
id,
1818
label,
1919
showTimeInput,
20+
labelRequiredMark,
2021
...props
2122
}: InputDateProps) => {
2223
const { locale } = useRouter();
@@ -30,7 +31,7 @@ const InputDate = ({
3031
month: (n) => months[n],
3132
},
3233
formatLong: {
33-
date: () => 'mm/dd/yyyy',
34+
date: () => 'dd/mm/yyyy',
3435
},
3536
};
3637

@@ -39,19 +40,22 @@ const InputDate = ({
3940
{label && (
4041
<label data-variant={variant} css={styles.label} htmlFor={id}>
4142
{label}
43+
{labelRequiredMark && <span>*</span>}
4244
</label>
4345
)}
4446
<div css={[styles.inputValueWrapper, styles.datePickerWrapper]}>
4547
<DatePicker
4648
onFocus={(e) => e.target.blur()}
4749
selected={new Date(value)}
4850
css={styles.input}
49-
placeholderText={showTimeInput ? 'mm/dd/yyyy hh:mm' : 'mm/dd/yyyy'}
51+
placeholderText={'-/-/- -:-'}
5052
id={id}
5153
showTimeInput={showTimeInput}
5254
locale={customLocale as any}
53-
minDate={new Date(new Date().getTime() + SECONDS_IN_ONE_DAY)}
55+
dateFormat={showTimeInput ? 'dd/MM/yyyy HH:mm' : 'dd/MM/yyyy'}
56+
minDate={new Date(new Date().getTime() + MILISECONDS_IN_ONE_DAY)}
5457
calendarStartDay={locale === 'ua' ? 1 : 0}
58+
timeInputLabel={t('components.datePicker.time')}
5559
{...props}
5660
/>
5761
<div css={styles.iconWrapper}>

packages/frontend/components/primitives/input/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ export interface InputProps
3333
export interface InputDateProps
3434
extends ReactDatePickerProps,
3535
BaseInputProps,
36-
InputStylingProps {}
36+
InputStylingProps {
37+
labelRequiredMark?: boolean;
38+
}

packages/frontend/components/profile/user-account-layout/account-links-data.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ export const getLinksData = (userId: string): LinkData[] => [
1212
label: 'account:myList',
1313
path: `${Routes.PROFILE}${ProfileRoutes.LIST}`,
1414
},
15-
{
16-
iconPath: IconName.SETTINGS,
17-
label: 'account:settings',
18-
path: `${Routes.PROFILE}${ProfileRoutes.ACCOUNT_SETTINGS}`,
19-
},
15+
// {
16+
// iconPath: IconName.SETTINGS,
17+
// label: 'account:settings',
18+
// path: `${Routes.PROFILE}${ProfileRoutes.ACCOUNT_SETTINGS}`,
19+
// },
2020
{
2121
iconPath: IconName.BELL,
2222
label: 'account:notifications',
2323
path: `${Routes.PROFILE}${ProfileRoutes.NOTIFICATIONS}`,
2424
},
25-
{
26-
iconPath: IconName.MESSAGE,
27-
label: 'account:messages',
28-
path: `${Routes.PROFILE}${ProfileRoutes.MESSAGES}`,
29-
},
25+
// {
26+
// iconPath: IconName.MESSAGE,
27+
// label: 'account:messages',
28+
// path: `${Routes.PROFILE}${ProfileRoutes.MESSAGES}`,
29+
// },
3030
{
3131
iconPath: IconName.SUPPORT,
3232
label: 'account:support',

packages/frontend/components/profile/user-account-layout/component.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ export const AccountLayout: FC<AccountPageProps> = ({ children }) => {
2424
dispatch(showMakePostModal());
2525
};
2626

27+
const getClickHandler = (label: string) => {
28+
if (label === 'account:signOut') {
29+
return () => dispatch(logoutUser());
30+
}
31+
32+
if (label === 'account:support') {
33+
return () =>
34+
(location.href = 'mailto:[email protected]?subject=Support');
35+
}
36+
37+
return null;
38+
};
39+
2740
return (
2841
<Layout>
2942
<Container>
@@ -65,11 +78,7 @@ export const AccountLayout: FC<AccountPageProps> = ({ children }) => {
6578
label={tLabel}
6679
location={location}
6780
path={path}
68-
onClick={
69-
label === 'account:signOut'
70-
? () => dispatch(logoutUser())
71-
: null
72-
}
81+
onClick={getClickHandler(label)}
7382
/>
7483
);
7584
})}

packages/frontend/components/save-post/auction-form.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,9 @@ export default function ProductForm({ edit }: { edit: boolean }) {
174174
<div css={styles.inputRow}>
175175
<Input
176176
error={errors.recommendedPrice?.message}
177-
required
178177
labelRequiredMark
179178
id="post-price"
180-
type="text"
179+
type="number"
181180
name="price"
182181
variant="primary"
183182
label={t('create-post:label.recommendedPrice')}
@@ -203,10 +202,9 @@ export default function ProductForm({ edit }: { edit: boolean }) {
203202
<div css={styles.inputRow}>
204203
<Input
205204
error={errors.minimalBid?.message}
206-
required
207205
labelRequiredMark
208206
id="post-price"
209-
type="text"
207+
type="number"
210208
name="price"
211209
variant="primary"
212210
label={t('create-post:label.minimalBid')}
@@ -221,6 +219,7 @@ export default function ProductForm({ edit }: { edit: boolean }) {
221219
name="endDate"
222220
render={({ field }) => (
223221
<InputDate
222+
labelRequiredMark
224223
required
225224
variant="primary"
226225
label={t('create-post:label.endDate')}
@@ -230,6 +229,7 @@ export default function ProductForm({ edit }: { edit: boolean }) {
230229
value={endDate}
231230
showTimeInput
232231
onChange={(date) => {
232+
console.log(date);
233233
setEndDate(date);
234234
field.onChange(date);
235235
}}

packages/frontend/components/save-post/form-utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const initialProductFormState: IPostForms = {
99
condition: '',
1010
title: '',
1111
description: '',
12-
price: 0,
12+
price: null,
1313
currency: 'UAH',
1414
country: '',
1515
city: '',
@@ -25,8 +25,8 @@ export const initialAuctionFormState: ICreateAuction = {
2525
condition: '',
2626
title: '',
2727
description: '',
28-
recommendedPrice: 0,
29-
minimalBid: 0,
28+
recommendedPrice: null,
29+
minimalBid: null,
3030
minimalBidCurrency: 'UAH',
3131
recommendedPriceCurrency: 'UAH',
3232
currency: 'UAH',

packages/frontend/components/save-post/product-form.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ export default function ProductForm({ edit }: { edit: boolean }) {
166166
<div css={styles.inputRow}>
167167
<Input
168168
error={errors.price?.message}
169-
required
169+
labelRequiredMark
170170
tooltip={t('create-post:tooltip.price')}
171171
id="post-price"
172-
type="text"
172+
type="number"
173173
name="price"
174174
variant="primary"
175175
label={t('create-post:label.price')}

packages/frontend/public/locales/en/common.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
},
114114
"badge": {
115115
"removeLabel": "Remove filter {{param}}"
116+
},
117+
"datePicker": {
118+
"time": "Time"
116119
}
117120
},
118121
"notifications": {
@@ -234,4 +237,4 @@
234237
"seconds": "s",
235238
"text": "Send reset link"
236239
}
237-
}
240+
}

packages/frontend/public/locales/en/create-post.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"deleteImage": "Delete image"
1616
},
1717
"caption": {
18-
"uploadPhotos": "You can add to 30 pics"
18+
"uploadPhotos": "You can add from 2 up to 30 pics"
1919
},
2020
"tooltip": {
2121
"price": "Make sure that you enter the correct price in digits!",
@@ -90,7 +90,7 @@
9090
"empty": "Description cannot be empty"
9191
},
9292
"price": {
93-
"base": "Wrong price format",
93+
"base": "Price cannot be empty",
9494
"empty": "Price cannot be empty"
9595
},
9696
"country": {

packages/frontend/public/locales/ua/common.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
},
114114
"badge": {
115115
"removeLabel": "Видалити фільтр {{param}}"
116+
},
117+
"datePicker": {
118+
"time": "Час"
116119
}
117120
},
118121
"verify": {
@@ -219,4 +222,4 @@
219222
"seconds": "с",
220223
"text": "Отримати посилання"
221224
}
222-
}
225+
}

packages/frontend/public/locales/ua/create-post.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"deleteImage": "Видалити зображення"
1616
},
1717
"caption": {
18-
"uploadPhotos": "Ви можете додати до 30 фотографій"
18+
"uploadPhotos": "Ви можете додати від 2 до 30 фотографій"
1919
},
2020
"tooltip": {
2121
"price": "Переконайтеся, що ви ввели ціну цифрами!",
@@ -89,7 +89,7 @@
8989
"pattern": "Неправильний формат телефону"
9090
},
9191
"price": {
92-
"base": "Неправильний формат ціни",
92+
"base": "Поле з ціною не може бути порожнім",
9393
"empty": "Поле з ціною не може бути порожнім"
9494
},
9595
"country": {
@@ -102,7 +102,7 @@
102102
"empty": "Стан не може бути порожнім"
103103
},
104104
"date": {
105-
"base": "Введіть дату після сьогоднішньої"
105+
"base": "Введіть дату на день більше сьогоднішньої"
106106
}
107107
},
108108
"sellerSelect": {

packages/frontend/validation-schemas/post/create-auction.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ValidationRanges } from '@vse-bude/shared';
2-
import { SECONDS_IN_ONE_DAY } from '@components/primitives/input/date-input';
2+
import { MILISECONDS_IN_ONE_DAY } from '@components/primitives/input/date-input';
33
import Joi from 'joi';
44
import type { TFunction } from 'next-i18next';
55

@@ -80,7 +80,7 @@ export const createAuctionSchema = (t: TFunction) =>
8080
.required()
8181
.messages({
8282
'number.base': t('create-post:validation.price.base'),
83-
'number.empty': t('create-post:validation.price.empty'),
83+
'number.required': t('create-post:validation.price.empty'),
8484
}),
8585
minimalBid: Joi.number()
8686
.min(1)
@@ -90,7 +90,7 @@ export const createAuctionSchema = (t: TFunction) =>
9090
'number.empty': t('create-post:validation.price.empty'),
9191
}),
9292
endDate: Joi.date()
93-
.min(Date.now() + SECONDS_IN_ONE_DAY)
93+
.min(Date.now() + MILISECONDS_IN_ONE_DAY)
9494
.required()
9595
.messages({
9696
'date.min': t('create-post:validation.date.base'),

0 commit comments

Comments
 (0)