Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 저장하기 버튼을 누르면 즉시 버튼을 disabled 처리해 중복 저장 방지 #91

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/cardMaker/CardEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CardEditor from './CardEditor';
import Inner from '../Inner';
import { addDocument, getCountDocument } from '@/lib/firebaseQuery';
import useUserStore from '@/store/useUsersStore';
import { MouseEvent } from 'react';
import { MouseEvent, useState } from 'react';
import { filteredPokemonData } from '@/lib/type';
import { useGetAllPokemon } from '@/query/qeuries';
import SearchPokemon from './searchPokemon/SearchPokemon';
Expand All @@ -16,6 +16,7 @@ import SelectPokemonMobile from './selectPokemon/SelectPokemonMobile';
import { useNavigate } from 'react-router-dom';

const CardEditPage = () => {
const [isSaving, setIsSaving] = useState<boolean>(false);
const { user } = useUserStore();
const navigate = useNavigate();
const {
Expand Down Expand Up @@ -48,6 +49,7 @@ const CardEditPage = () => {

const onSave = async (event: MouseEvent) => {
event.preventDefault();
setIsSaving(true);
if (user) {
const count = await getCountDocument(`cards/${user.uid}/pokemonCards`);

Expand All @@ -68,6 +70,7 @@ const CardEditPage = () => {
});
}

setIsSaving(false);
navigate('/mypage');
};

Expand Down Expand Up @@ -99,7 +102,7 @@ const CardEditPage = () => {
<SelectPokemonRandom />
</div>
<button
disabled={!pokemonName?.length}
disabled={!pokemonName?.length || isSaving}
className={styles.save_button}
onClick={onSave}
>
Expand Down
Loading