Skip to content

Commit 0ea50d0

Browse files
refactor(vue3): migrate RenewEmail to script setup ts
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent dc23281 commit 0ea50d0

1 file changed

Lines changed: 35 additions & 40 deletions

File tree

src/views/RenewEmail.vue

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
</div>
3939
</template>
4040

41-
<script>
41+
<script setup lang="ts">
4242
import { t } from '@nextcloud/l10n'
43+
import { ref } from 'vue'
4344
import {
4445
mdiArrowRight,
4546
} from '@mdi/js'
@@ -53,48 +54,42 @@ import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
5354
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
5455
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
5556
56-
export default {
57+
defineOptions({
5758
name: 'RenewEmail',
59+
})
5860
59-
components: {
60-
NcButton,
61-
NcNoteCard,
62-
NcIconSvgWrapper,
63-
NcLoadingIcon,
64-
},
65-
setup() {
66-
return {
67-
t,
68-
mdiArrowRight,
69-
}
70-
},
71-
data() {
72-
return {
73-
title: loadState('libresign', 'title'),
74-
body: loadState('libresign', 'body'),
75-
renewButton: loadState('libresign', 'renewButton'),
76-
uuid: loadState('libresign', 'uuid'),
77-
hasLoading: false,
78-
response: '',
79-
error: '',
80-
}
81-
},
82-
methods: {
83-
async renew() {
84-
this.hasLoading = true
85-
this.error = ''
86-
try {
87-
const response = await axios.post(generateOcsUrl('/apps/libresign/api/v1/sign/uuid/{uuid}/renew/email', {
88-
uuid: this.uuid,
89-
}))
90-
this.response = response.data.ocs.data.message
91-
} catch (e) {
92-
this.error = e.response.data.ocs.data.message
93-
}
94-
this.hasLoading = false
95-
},
96-
},
61+
const title = loadState('libresign', 'title')
62+
const body = loadState('libresign', 'body')
63+
const renewButton = loadState('libresign', 'renewButton')
64+
const uuid = loadState('libresign', 'uuid')
65+
const hasLoading = ref(false)
66+
const response = ref('')
67+
const error = ref('')
68+
69+
async function renew() {
70+
hasLoading.value = true
71+
error.value = ''
72+
try {
73+
const result = await axios.post(generateOcsUrl('/apps/libresign/api/v1/sign/uuid/{uuid}/renew/email', {
74+
uuid,
75+
}))
76+
response.value = result.data.ocs.data.message
77+
} catch (caughtError) {
78+
error.value = (caughtError as { response?: { data?: { ocs?: { data?: { message?: string } } } } }).response?.data?.ocs?.data?.message ?? ''
79+
}
80+
hasLoading.value = false
9781
}
82+
83+
defineExpose({
84+
title,
85+
body,
86+
renewButton,
87+
uuid,
88+
hasLoading,
89+
response,
90+
error,
91+
renew,
92+
})
9893
</script>
9994

10095
<style lang="scss">

0 commit comments

Comments
 (0)