Skip to content

Commit 4c2cf2f

Browse files
committed
feat: dedupe claim modal checks
1 parent 5e1361c commit 4c2cf2f

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

app/components/ClaimPackageModal.vue

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script setup lang="ts">
2-
import type { CheckNameResult } from '~/utils/package-name'
32
import { checkPackageName } from '~/utils/package-name'
43
54
const props = defineProps<{
@@ -20,12 +19,13 @@ const {
2019
2120
const isPublishing = shallowRef(false)
2221
const publishSuccess = shallowRef(false)
22+
const publishError = shallowRef<string | null>(null)
2323
2424
const {
2525
data: checkResult,
2626
refresh: checkAvailability,
2727
status,
28-
error,
28+
error: checkError,
2929
} = useAsyncData(
3030
(_nuxtApp, { signal }) => {
3131
return checkPackageName(props.packageName, { signal })
@@ -37,14 +37,20 @@ const isChecking = computed(() => {
3737
return status.value === 'pending'
3838
})
3939
40-
const publishError = computed(() => {
41-
return error.value instanceof Error ? error.value.message : $t('claim.modal.failed_to_check')
40+
const mergedError = computed(() => {
41+
return (
42+
publishError.value ??
43+
(checkError.value instanceof Error
44+
? checkError.value.message
45+
: $t('claim.modal.failed_to_check'))
46+
)
4247
})
4348
4449
async function handleClaim() {
4550
if (!checkResult.value?.available || !isConnected.value) return
4651
4752
isPublishing.value = true
53+
publishError.value = null
4854
4955
try {
5056
// Add the operation
@@ -61,7 +67,7 @@ async function handleClaim() {
6167
6268
// Auto-approve and execute
6369
await approveOperation(operation.id)
64-
const result = await executeOperations()
70+
await executeOperations()
6571
6672
// Refresh state and check if operation completed successfully
6773
await refreshState()
@@ -93,7 +99,6 @@ async function handleClaim() {
9399
// Check availability when modal opens
94100
watch(open, isOpen => {
95101
if (isOpen) {
96-
checkResult.value = null
97102
publishError.value = null
98103
publishSuccess.value = false
99104
checkAvailability()
@@ -318,11 +323,11 @@ const connectorModalOpen = shallowRef(false)
318323

319324
<!-- Error message -->
320325
<div
321-
v-if="publishError"
326+
v-if="mergedError"
322327
role="alert"
323328
class="p-3 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-md"
324329
>
325-
{{ publishError }}
330+
{{ mergedError }}
326331
</div>
327332

328333
<!-- Actions -->
@@ -402,12 +407,12 @@ const connectorModalOpen = shallowRef(false)
402407
</div>
403408

404409
<!-- Error state -->
405-
<div v-else-if="publishError" class="space-y-4">
410+
<div v-else-if="mergedError" class="space-y-4">
406411
<div
407412
role="alert"
408413
class="p-3 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-md"
409414
>
410-
{{ publishError }}
415+
{{ mergedError }}
411416
</div>
412417
<button
413418
type="button"

0 commit comments

Comments
 (0)