Skip to content

Commit dea2e17

Browse files
committed
Merge remote-tracking branch 'origin/master' into PC-93
# Conflicts: # app/javascript/components/shared/constants.js # app/javascript/components/ui/PcDropdownSelect.jsx
2 parents ee9fbd5 + f9256d4 commit dea2e17

5 files changed

Lines changed: 74 additions & 38 deletions

File tree

app/assets/images/icons/cross.svg

Lines changed: 3 additions & 0 deletions
Loading

app/assets/stylesheets/application/input.scss

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ textarea {
5050

5151
.rbt-menu.dropdown-menu.show {
5252
margin-top: 5px;
53-
border: 1px solid $primary;
53+
outline: 1px solid $primary;
54+
border-inline: 5px solid $white !important;
55+
border-block: none !important;
5456
width: calc(100% + 2px) !important;
55-
margin-left: -1px;
57+
margin-left: -2px;
58+
max-height: 185px !important;
5659
}
5760

5861
.rbt-highlight-text {
@@ -70,16 +73,21 @@ textarea {
7073
**/
7174
.pc-typeahead-customer-info {
7275
.pc-icon-reserve-place {
73-
padding-right: 26px;
74-
background-color: $white;
76+
padding-right: 60px;
7577
}
7678

77-
.pc-typeahead-toggle {
78-
width: 26px;
79-
cursor: pointer;
79+
.pc-typeahead-controls {
80+
width: 60px;
81+
}
82+
83+
.pc-typeahead-button {
84+
width: 24px;
8085
}
8186
}
8287

88+
/**
89+
*** LOGO UPLOADER ***
90+
**/
8391
.pc-logo-uploader {
8492
width: 136px;
8593
height: 117px;

app/javascript/components/shared/CustomerForm.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export const CustomerForm = () => {
4646
}
4747

4848
const handleCompanyInputChange = (text) => {
49+
text = text.trimStart()
50+
4951
if (text) {
5052
setIsNextDisabled(false)
5153
setErrors((prev) => ({...prev, company_name: ''}))
@@ -114,7 +116,6 @@ export const CustomerForm = () => {
114116
setIsNextDisabled(true)
115117
setErrors((prev) => ({...prev, logo: logoErrors.join('\n')}))
116118
} else {
117-
setIsNextDisabled(false)
118119
setCustomer((prev) => ({ ...prev, logo_url: URL.createObjectURL(file) }))
119120
setErrors((prev) => ({ ...prev, logo: '' }))
120121
}
@@ -150,6 +151,11 @@ export const CustomerForm = () => {
150151
}
151152
}
152153

154+
const handleClearInput = () => {
155+
setCustomer(prev => ({ ...prev, company_name: '' }))
156+
setIsNextDisabled(true)
157+
}
158+
153159
return (
154160
<Form onSubmit={handleNext} className={'d-flex flex-column w-100 align-items-center'}>
155161
<div className="border rounded border-primary customer-form bg-light w-100 mb-7">
@@ -180,6 +186,7 @@ export const CustomerForm = () => {
180186
error={errors.company_name}
181187
onChange={handleCompanyChange}
182188
onInputChange={handleCompanyInputChange}
189+
onClearInput={handleClearInput}
183190
hasIcon={true}
184191
/>
185192
</Col>

app/javascript/components/shared/constants.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export const STEPS = {
2323
// STEPS_DATA is for PcProgressBar component
2424
export const STEPS_DATA = [
2525
// step_id must be a number
26-
{step_id: 1, step: ROUTES.CUSTOMER_INFO, title: 'Customer Information'},
27-
{step_id: 2, step: ROUTES.ITEM_PRICING, title: 'Items & Pricing'},
26+
{ step_id: 1, step: ROUTES.CUSTOMER_INFO, title: 'Customer Information' },
27+
{ step_id: 2, step: ROUTES.ITEM_PRICING, title: 'Items & Pricing' },
2828
]
2929

3030
// Centralized storage for image assets
@@ -47,6 +47,9 @@ import trashDangerUrl from '../../../assets/images/icons/trash-danger.svg'
4747
import trashTwoUrl from '../../../assets/images/icons/trash-default.svg'
4848
import trashDefaultUrl from '../../../assets/images/icons/trash-default.svg'
4949
import trashUrl from '../../../assets/images/icons/trash.svg'
50+
import dropdownArrowDownUrl from '../../../assets/images/icons/arrow-down.svg'
51+
import dropdownArrowUpUrl from '../../../assets/images/icons/arrow-up.svg'
52+
import crossUrl from '../../../assets/images/icons/cross.svg'
5053

5154
export const IMAGE_ASSETS = {
5255
ICONS: {
@@ -68,7 +71,10 @@ export const IMAGE_ASSETS = {
6871
trashDefault: trashDefaultUrl,
6972
trashDanger: trashDangerUrl,
7073
arrowDownLight: arrowDownLightUrl,
71-
arrowUpLight: arrowUpLightUrl
74+
arrowUpLight: arrowUpLightUrl,
75+
dropdownArrowDown: dropdownArrowDownUrl,
76+
dropdownArrowUp: dropdownArrowUpUrl,
77+
cross: crossUrl,
7278
},
7379
// future asset files can be added here
7480
}
@@ -82,12 +88,12 @@ export const EMPTY_ENTITIES = {
8288
address: '',
8389
notes: '',
8490
logo_url: null,
85-
}
91+
},
8692
// future empty entities can be added here
8793
}
8894

8995
export const INPUT_VALIDATORS = {
90-
emailFormat:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,
96+
emailFormat: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
9197
maxSizeFile: 2 * 1024 * 1024,
9298
allowedFileTypes: ['image/jpeg', 'image/png'],
9399
// future validation rules can be added here

app/javascript/components/ui/PcDropdownSelect.jsx

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { normalizeName } from '../utils'
55
import { PcIcon } from './PcIcon'
66

77
export const PcDropdownSelect = ({
8-
id,
9-
options,
10-
placeholder,
11-
height,
12-
value,
13-
label,
14-
error,
15-
maxResults = 5,
16-
hasIcon = false,
17-
onChange,
18-
onInputChange,
19-
...props
20-
}) => {
8+
id,
9+
options,
10+
placeholder,
11+
height,
12+
value,
13+
label,
14+
error,
15+
hasIcon = false,
16+
onChange,
17+
onInputChange,
18+
onClearInput,
19+
...props
20+
}) => {
2121
const [isMenuOpen, setIsMenuOpen] = useState(false)
2222

2323
const selectedOption =
@@ -40,27 +40,39 @@ export const PcDropdownSelect = ({
4040
setIsMenuOpen(false)
4141
}
4242

43-
const handleChenge = (selected) => {
43+
const handleChange = (selected) => {
4444
onChange(selected)
4545

4646
if (selected.length !== 0) setIsMenuOpen(false)
4747
}
4848

4949
const handleInputChange = (t, e) => {
5050
onInputChange(t, e)
51+
5152
if (t) setIsMenuOpen(true)
5253
}
5354

54-
const DropdownToggleIcon = () => (
55-
<div className="pc-typeahead-toggle position-absolute end-0 top-0 h-100" onClick={handleOpenMenu}>
56-
<div className={'d-flex justify-content-start align-items-center h-100'}>
55+
const handleClick = (e) => {
56+
setIsMenuOpen(true)
57+
}
58+
59+
const TransparentButton = ({ children, className, ...props }) =>
60+
(<button className={`bg-transparent rounded-0 border-0 p-0 m-0 ${className}`} {...props}>
61+
{children}
62+
</button>)
63+
64+
const TypeaheadControls = () =>
65+
(<div className="pc-typeahead-controls position-absolute end-0 top-0 h-100 d-flex flex-row">
66+
<TransparentButton onClick={onClearInput} className={'pc-typeahead-button'}>
67+
<PcIcon name={'cross'} alt={'Cross'} className={'pc-icon-cross'} />
68+
</TransparentButton>
69+
<TransparentButton onClick={handleOpenMenu} className={'pc-typeahead-button'}>
5770
<PcIcon
5871
name={isMenuOpen ? 'arrowUp' : 'arrowDown'}
5972
alt={isMenuOpen ? 'Arrow pointing up' : 'Arrow pointing down'}
6073
/>
61-
</div>
62-
</div>
63-
)
74+
</TransparentButton>
75+
</div>)
6476

6577
return (
6678
<Form.Group controlId={id}>
@@ -72,23 +84,23 @@ export const PcDropdownSelect = ({
7284
filterBy={handleFilterBy}
7385
allowNew
7486
newSelectionPrefix="Add new customer: "
75-
className="pc-icon-reserve-place border border-primary rounded-1"
87+
className="pc-icon-reserve-place border border-primary rounded-1 bg-white"
7688
style={{ height }}
7789
selected={selectedOption ? [selectedOption] : []}
78-
maxResults={maxResults}
7990
paginate={false}
8091
open={isMenuOpen}
8192
onMenuToggle={(isOpen) => setIsMenuOpen(isOpen)}
8293
onFocus={handleFocus}
8394
onBlur={handleBlur}
84-
onChange={handleChenge}
95+
onChange={handleChange}
8596
onInputChange={handleInputChange}
97+
inputProps={{ onClick: handleClick }}
8698
{...props}
8799
/>
88100
<Form.Label className="border-label fw-bold fs-11 lh-sm px-1">{label}</Form.Label>
89-
{hasIcon && <DropdownToggleIcon />}
101+
{hasIcon && <TypeaheadControls />}
90102
</div>
91103
{error && <div className="text-danger fs-12">{error}</div>}
92104
</Form.Group>
93105
)
94-
}
106+
}

0 commit comments

Comments
 (0)