Skip to content

Commit

Permalink
feat(ui): define combo input to show just when click on save button
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Sep 30, 2023
1 parent 819fd39 commit 9f37c01
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/save-combo-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ export function SaveComboButton() {

const [comboName, setComboName] = useState('')
const [showSuccess, setShowSuccess] = useState(false)
const [showInput, setShowInput] = useState(false)

function save() {
if (!comboName) return
if (!sounds.some(sound => sound.active)) return

if (!showInput) {
setShowInput(true)
return
}

if (!comboName) return

const activeSounds = sounds.filter(sound => sound.active)

saveCombo({
Expand All @@ -30,6 +37,7 @@ export function SaveComboButton() {
})

setComboName('')
setShowInput(false)
setShowSuccess(true)

setTimeout(() => setShowSuccess(false), 2000)
Expand All @@ -39,7 +47,7 @@ export function SaveComboButton() {

return (
<div className="flex gap-1">
{sounds.some(sound => sound.active) && (
{showInput && (
<input
disabled={disabled}
type="text"
Expand Down

0 comments on commit 9f37c01

Please sign in to comment.