Skip to content

Commit

Permalink
fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
simenandre committed Sep 3, 2021
1 parent c7018ba commit bd95e33
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"react-icons": "^4.2.0",
"react-modal": "^3.14.3",
"react-table": "^7.7.0",
"slate": "^0.65.3",
"slate-react": "^0.65.3",
"slate": "^0.58.1",
"slate-react": "^0.58.2",
"storybook-addon-theme-ui": "^0.1.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/file-upload/document-file-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const DocumentFileUpload: React.FC<FileUploadProps> = (props) => {
justifyContent: 'center',
}}
>
{value?.length > 0 ? (
{value && value?.length > 0 ? (
value.map(i => (
<div key={i} sx={{ my: 1 }}>
{i.split('/').pop()}
Expand Down
30 changes: 19 additions & 11 deletions src/components/file-upload/image-file-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ const defaultProps = {
accept: 'image/*',
};

export const ImageFileUpload: React.FC<ImageFileUploadProps> = (props) => {
const { value, user, id, accept, buttonComponent, validate, upload, remove } = props;
export const ImageFileUpload: React.FC<ImageFileUploadProps> = props => {
const { value, user, id, accept, buttonComponent, validate, upload, remove } =
props;

const [loading, setLoading] = useState(false);
const [errors, setErrors] = useState([] as string[]);
Expand All @@ -42,13 +43,16 @@ export const ImageFileUpload: React.FC<ImageFileUploadProps> = (props) => {
return;
}
if (validate) {
const validationErrors = Array.from(filesToUpload).reduce((acc: string[], file) => {
const err = validate(file);
if (err) {
acc.push(err);
}
return acc;
}, []);
const validationErrors = Array.from(filesToUpload).reduce(
(acc: string[], file) => {
const err = validate(file);
if (err) {
acc.push(err);
}
return acc;
},
[],
);
if (validationErrors.length) {
setErrors(validationErrors);
return;
Expand All @@ -59,7 +63,9 @@ export const ImageFileUpload: React.FC<ImageFileUploadProps> = (props) => {
try {
if (filesToUpload.length !== 0) {
const url = await upload(filesToUpload[0]);
setImage(url);
if (url) {
setImage(url);
}
}
} catch (err) {
setErrors([err.message]);
Expand Down Expand Up @@ -116,7 +122,9 @@ export const ImageFileUpload: React.FC<ImageFileUploadProps> = (props) => {
<FileDeleteButton
mt={3}
onClick={() => {
remove(value);
if (value && remove) {
remove(value);
}
setImage('');
}}
>
Expand Down
33 changes: 13 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8061,10 +8061,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656"
integrity sha512-aqXhGP7//Gui2+UrEtvxZxSquQVXTpZ7KDxfCcKAF3Vysvw0CViVaW9RZ1j1xlIYqaaaipBoqdqeibkc18PNvA==

immer@^8.0.1:
version "8.0.4"
resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.4.tgz#3a21605a4e2dded852fb2afd208ad50969737b7a"
integrity sha512-jMfL18P+/6P6epANRvRk6q8t+3gGhqsJ9EuJ25AXE+9bNTYtssvzeYbEd0mXRYWCmmXSIbnlpz6vd6iJlmGGGQ==
immer@^5.0.0:
version "5.3.6"
resolved "https://registry.yarnpkg.com/immer/-/immer-5.3.6.tgz#51eab8cbbeb13075fe2244250f221598818cac04"
integrity sha512-pqWQ6ozVfNOUDjrLfm4Pt7q4Q12cGw2HUZgry4Q5+Myxu9nmHRkWBpI0J4+MK0AxbdFtdMTwEGVl7Vd+vEiK+A==

import-cwd@^2.0.0:
version "2.1.0"
Expand Down Expand Up @@ -13112,10 +13112,10 @@ slash@^3.0.0:
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==

slate-react@^0.65.3:
version "0.65.3"
resolved "https://registry.yarnpkg.com/slate-react/-/slate-react-0.65.3.tgz#f652e4780b4304189a8a8ecc8feca723f31173a3"
integrity sha512-lyiZD7Rrt0LInvK4xhIemnCEx/N7jt+e/eHlsFor+rif/K0RT9wSPXWajTI9RglbvN9XHTEuB2BFx2cQLKiomw==
slate-react@^0.58.2:
version "0.58.4"
resolved "https://registry.yarnpkg.com/slate-react/-/slate-react-0.58.4.tgz#ecde34dd322af8413c2f23f0f0a577fed2422f46"
integrity sha512-3JXWHVPmYrR/EMcH1qtmwXZtYxxCtuokQg+r/4wD1Ab9J3zRmW4UGLoaRP9/uQrZOAOvr8mMh4IgmrxV2dQskw==
dependencies:
"@types/is-hotkey" "^0.1.1"
"@types/lodash" "^4.14.149"
Expand All @@ -13124,17 +13124,15 @@ slate-react@^0.65.3:
is-plain-object "^3.0.0"
lodash "^4.17.4"
scroll-into-view-if-needed "^2.2.20"
tiny-invariant "1.0.6"

slate@^0.65.3:
version "0.65.3"
resolved "https://registry.yarnpkg.com/slate/-/slate-0.65.3.tgz#8178cdf28a10a3a4e6858b13bc2ffa7c3d003e7a"
integrity sha512-n8wa2MKyWhCMRyVkXuMf67MmOYSeoHnqS1qYivor+/y0puNvQgXDUjC7TJJqUjhVqJ6zg2IeuYd0WfSYdAJs4g==
slate@^0.58.1:
version "0.58.4"
resolved "https://registry.yarnpkg.com/slate/-/slate-0.58.4.tgz#4259387e632b45b00cf88bcecf5570d7d16ddd8b"
integrity sha512-XxKwNJgCMf7S2sDT8CVJy0zYm95MiYorJo9Hah05zKjItrw0VVeCc2BGKDZSlNGcaIfM3xcfFUN7XE+c8ehAbA==
dependencies:
"@types/esrever" "^0.2.0"
esrever "^0.2.0"
fast-deep-equal "^3.1.3"
immer "^8.0.1"
immer "^5.0.0"
is-plain-object "^3.0.0"
tiny-warning "^1.0.3"

Expand Down Expand Up @@ -13928,11 +13926,6 @@ tiny-emitter@^2.0.0:
resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423"
integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==

[email protected]:
version "1.0.6"
resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.0.6.tgz#b3f9b38835e36a41c843a3b0907a5a7b3755de73"
integrity sha512-FOyLWWVjG+aC0UqG76V53yAWdXfH8bO6FNmyZOuUrzDzK8DI3/JRY25UD7+g49JWM1LXwymsKERB+DzI0dTEQA==

tiny-warning@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
Expand Down

0 comments on commit bd95e33

Please sign in to comment.