Skip to content

Commit

Permalink
chore: use store
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Apr 12, 2024
1 parent 83d4831 commit 8122fcf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 33 deletions.
27 changes: 11 additions & 16 deletions src/views/SignPDF/_partials/ModalEmailManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import md5 from 'blueimp-md5'
import { onError } from '../../../helpers/errors.js'
import { validateEmail } from '../../../utils/validators.js'
import { useSignMethodsStore } from '../../../store/signMethods.js'
import { useSignStore } from '../../../store/sign.js'
const sanitizeNumber = val => {
val = val.replace(/\D/g, '')
Expand All @@ -88,21 +89,10 @@ export default {
EmailIcon,
NcButton,
},
props: {
fileId: {
type: Number,
required: false,
default: 0,
},
uuid: {
type: String,
required: false,
default: '',
},
},
setup() {
const signStore = useSignStore()
const signMethodsStore = useSignMethodsStore()
return { signMethodsStore }
return { signStore, signMethodsStore }
},
data: () => ({
loading: false,
Expand Down Expand Up @@ -153,9 +143,11 @@ export default {
await this.$nextTick()
try {
if (this.fileId.length > 0) {
if (this.signStore.document.fileId) {
const { data } = await axios.post(
generateOcsUrl('/apps/libresign/api/v1/sign/file_id/{fileId}/code', { fileId: this.fileId }),
generateOcsUrl('/apps/libresign/api/v1/sign/file_id/{fileId}/code', {
fileId: this.signStore.document.fileId,
}),
{
identify: this.sendTo,
identifyMethod: this.signMethodsStore.settings.emailToken.identifyMethod,
Expand All @@ -164,8 +156,11 @@ export default {
)
showSuccess(data.message)
} else {
const signer = this.signStore.document.signers.find(row => row.me) || {}
const { data } = await axios.post(
generateOcsUrl('/apps/libresign/api/v1/sign/uuid/{uuid}/code', { uuid: this.uuid }),
generateOcsUrl('/apps/libresign/api/v1/sign/uuid/{uuid}/code', {
uuid: signer.sign_uuid,
}),
{
identify: this.sendTo,
identifyMethod: this.signMethodsStore.settings.emailToken.identifyMethod,
Expand Down
22 changes: 9 additions & 13 deletions src/views/SignPDF/_partials/ModalSMSManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { confirmPassword } from '@nextcloud/password-confirmation'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { onError } from '../../../helpers/errors.js'
import { settingsService } from '../../../domains/settings/index.js'
import { useSignStore } from '../../../store/sign.js'
const sanitizeNumber = val => {
val = val.replace(/\D/g, '')
Expand All @@ -74,16 +75,10 @@ export default {
type: String,
required: true,
},
fileId: {
type: Number,
required: false,
default: 0,
},
uuid: {
type: String,
required: false,
default: '',
},
},
setup() {
const signStore = useSignStore()
return { signStore }
},
data: () => ({
token: '',
Expand Down Expand Up @@ -123,14 +118,15 @@ export default {
await this.$nextTick()
try {
if (this.fileId.length > 0) {
if (this.signStore.document.fileId) {
const { data } = await axios.post(generateOcsUrl('/apps/libresign/api/v1/sign/file_id/{fileId}/code', {
fileId: this.fileId,
fileId: this.signStore.document.fileId,
}))
showSuccess(data.message)
} else {
const signer = this.signStore.document.signers.find(row => row.me) || {}
const { data } = await axios.post(generateOcsUrl('/apps/libresign/api/v1/sign/uuid/{fileId}/code', {
uuid: this.uuid,
uuid: signer.sign_uuid,
}))
showSuccess(data.message)
}
Expand Down
4 changes: 0 additions & 4 deletions src/views/SignPDF/_partials/Sign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,11 @@
<CreatePassword @password:created="signMethodsStore.setHasSignatureFile" />
<SMSManager v-if="signMethodsStore.modal.sms"
:phone-number="user?.account?.phoneNumber"
:uuid="signStore.uuid"
:file-id="signStore.document.fileId"
@change="signWithSMSCode"
@update:phone="val => $emit('update:phone', val)"
@close="signMethodsStore.closeModal('sms')" />

<EmailManager v-if="signMethodsStore.modal.emailToken"
:uuid="signStore.uuid"
:file-id="signStore.document.fileId"
@change="signWithEmailToken"
@close="signMethodsStore.closeModal('emailToken')" />
</div>
Expand Down

0 comments on commit 8122fcf

Please sign in to comment.