Skip to content

Commit

Permalink
Merge branch 'fix/upload' of github.com:b2wads/bitservices-theme into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
lucasdomi committed Sep 25, 2019
2 parents ab245fb + 5272714 commit 39e50b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
14 changes: 11 additions & 3 deletions source/components/button-upload/button-upload-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import CSSModules from 'react-css-modules';

import { omit } from 'helpers';

import Button from '../button';
import Icon from '../icon';

Expand Down Expand Up @@ -57,10 +59,15 @@ class ButtonUpload extends PureComponent {
fileValidation(file) {
const { formatWhiteList, maxFileSize } = this.props;
const extension = file.name.split('.').pop();
return {
valid: formatWhiteList.includes(`.${extension}`) && file.size <= maxFileSize,
const validation = {
validFormat: formatWhiteList.includes(`.${extension}`),
validSize: file.size <= maxFileSize,
hasNoRepeat: !this.state.list.filter(currentFile => currentFile.name === file.name).length,
};

return {
...validation,
valid: validation.validFormat && validation.validSize && validation.hasNoRepeat,
};
}

Expand Down Expand Up @@ -116,7 +123,7 @@ class ButtonUpload extends PureComponent {
const hasMaxFiles = this.state.list.length === limit;

return (
<div {...rest}>
<div {...omit(rest, ['onChange'])}>
<Button loading={loading} disabled={disabled || hasMaxFiles} iconLeft="publish" className={styles.button}>
{btnText}
<input
Expand All @@ -126,6 +133,7 @@ class ButtonUpload extends PureComponent {
disabled={disabled || hasMaxFiles}
multiple
accept={accept || formatWhiteList.join(', ')}
key={this.state.list.length}
/>
</Button>

Expand Down
1 change: 1 addition & 0 deletions source/components/select/elements/select-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SelectOption.propTypes = {
onSelect: PropTypes.func,
selected: PropTypes.bool,
children: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
noCurrentValue: PropTypes.bool,
};

export default SelectOption;
3 changes: 2 additions & 1 deletion source/components/select/select-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Select extends Component {
sortItems: PropTypes.bool,
isMobile: PropTypes.bool,
active: PropTypes.bool,
noCurrentValue: PropTypes.bool,
};

static defaultProps = {
Expand Down Expand Up @@ -277,7 +278,7 @@ class Select extends Component {
selected={selectedValue === option.value}
onSelect={this.onSelectItem}
value={option.value}
noneValue={noCurrentValue && selectedValue === option.value}
noCurrentValue={noCurrentValue && selectedValue === option.value}
>
{option.name}
</SelectOption>
Expand Down
2 changes: 1 addition & 1 deletion source/components/select/select.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ stories.add('Select disabled', () => {
);
});

stories.add('Select - None atual value', () => {
stories.add('Select - No Current Value', () => {
return (
<Select
label="Opções"
Expand Down

0 comments on commit 39e50b5

Please sign in to comment.