Preview:
setDraftsmanUploadedDocumentList: (state, { payload }) => {
      state.loading = false;
      if (state.draftsmanGUID !== '') {
        if (payload[0]?.documentTypeID === 409) {
          payload.forEach((item: any) => {
            state.draftsmanUploadedDocumentList.push(item);
          });
        } else {
          state.draftsmanUploadedDocumentList = state.draftsmanUploadedDocumentList.filter((item: any) => item.documentTypeID !== payload[0]?.documentTypeID);
          state.draftsmanUploadedDocumentList.push(payload[0]);
        }
      } else {
        payload.forEach((item: any) => {
          // Replace passport size photo
          if (item?.documentTypeID !== 4) {
            state.draftsmanUploadedDocumentList.push(item);
          }
        });
        if (payload[0]?.documentTypeID === 4) {
          state.draftsmanUploadedDocumentList = state.draftsmanUploadedDocumentList.filter((doc: any) => doc.documentTypeID !== payload?.documentTypeID);
          const fileExtension = payload[0].name.split('.').pop();
          const passportSizePhotoValidDocTypes = ['jpeg', 'png', 'jpg', 'bmp'];
          const isValid = passportSizePhotoValidDocTypes.includes(fileExtension);
          if (isValid) state.draftsmanUploadedDocumentList.push(payload[0]);
        }
      }
      state.isDocumentsChanged = !state.isDocumentsChanged;
    },
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter