Skip to content

Commit

Permalink
regn ut totalstørrelse på valgte filer før opplasting
Browse files Browse the repository at this point in the history
  • Loading branch information
tidnav committed Jan 17, 2025
1 parent 3edcdfc commit 5e4bc00
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/aap-felles-css/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.2.3

## 4.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-css/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.2.2",
"version": "4.2.3",
"name": "@navikt/aap-felles-css",
"author": "NAV",
"homepage": "https://github.com/navikt/aap-felles-frontend#readme",
Expand Down
2 changes: 2 additions & 0 deletions packages/aap-felles-prettier/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.2.3

## 4.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@navikt/aap-felles-prettier",
"author": "NAV",
"version": "4.2.2",
"version": "4.2.3",
"main": "index.json",
"license": "MIT",
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/aap-felles-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 4.2.3

### Patch Changes

- totalsize-fileinputinnsending

## 4.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-react/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.2.2",
"version": "4.2.3",
"name": "@navikt/aap-felles-react",
"author": "NAV",
"homepage": "https://github.com/navikt/aap-felles-frontend#readme",
Expand Down
16 changes: 15 additions & 1 deletion packages/aap-felles-react/src/FileInput/FileInputInnsending.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,23 @@ export const FileInputInnsending = (props: FileInputProps) => {
}

async function validateAndSetFiles(filelist: FileList) {
const fileArray = Array.from(filelist);
const totalSize = fileArray.reduce((acc, curr) => acc + curr.size, 0);
if(totalSize > MAX_TOTAL_FILE_SIZE) {
setIsUploading(false);
onUpload([
{
vedleggId: uuidV4(),
errorMessage: tekster.fileInputErrors.fileTooLarge,
type: '',
size: totalSize,
name: `${fileArray.length} filer`,
}
]);
}
setIsUploading(true);
const uploadedFiles: Vedlegg[] = await Promise.all(
Array.from(filelist).map(async (file) => {
fileArray.map(async (file) => {
const internalErrorMessage = internalValidate(file);
let uploadResult: Vedlegg = {
vedleggId: uuidV4(),
Expand Down
2 changes: 2 additions & 0 deletions packages/aap-felles-utils-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.2.3

## 4.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-utils-client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.2.2",
"version": "4.2.3",
"name": "@navikt/aap-felles-utils-client",
"author": "NAV",
"homepage": "https://github.com/navikt/aap-felles-frontend#readme",
Expand Down
2 changes: 2 additions & 0 deletions packages/aap-felles-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.2.3

## 4.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/aap-felles-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.2.2",
"version": "4.2.3",
"name": "@navikt/aap-felles-utils",
"author": "NAV",
"homepage": "https://github.com/navikt/aap-felles-frontend#readme",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config-aap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 4.2.3

## 4.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-aap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@navikt/eslint-config-aap",
"author": "NAV",
"version": "4.2.2",
"version": "4.2.3",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\"",
Expand Down

0 comments on commit 5e4bc00

Please sign in to comment.