Skip to content

Commit

Permalink
added a lock to the start button
Browse files Browse the repository at this point in the history
  • Loading branch information
RGBKnights committed Jan 8, 2025
1 parent 0b69e07 commit d3bb1e5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/components/ActionSection.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
<script setup lang="ts">
import ProgressBar from '@/components/ProgressBar.vue';
import { useIterateStore } from '@/stores/iterate'
import { ref, watch } from 'vue';
const iterate = useIterateStore()
const isLocked = ref(false)
const start = () => {
isLocked.value = true
iterate.start()
}
watch(() => iterate.isRunning, (value) => {
if(value) {
isLocked.value = false
}
})
</script>

<template>
Expand All @@ -17,10 +32,10 @@ const iterate = useIterateStore()
</div>
<div v-if="iterate.isPending || iterate.isDone" class="w-full">
<button
@click="iterate.start"
:disabled="iterate.isLocked"
@click="start"
:disabled="iterate.isLocked || isLocked"
:class="[
'py-2 px-6 w-full rounded transition-colors inline-flex items-center justify-center bg-green-600 hover:bg-green-700 text-white',
'py-2 px-6 w-full rounded transition-colors inline-flex items-center justify-center disabled:bg-zinc-500 bg-green-600 hover:bg-green-700 text-white',
iterate.isLocked ? 'opacity-50 cursor-not-allowed' : ''
]">
<span>Start</span>
Expand Down

0 comments on commit d3bb1e5

Please sign in to comment.