1
1
import styled from "styled-components" ;
2
2
import { COLOR } from "../../../styles/color" ;
3
3
import { useState } from "react" ;
4
+ import { useNavigate } from "react-router-dom" ;
4
5
import { useRecoilState , useRecoilValue } from "recoil" ;
5
6
import { Box , Button , DialogContent , DialogTitle } from "@mui/material" ;
6
7
import TaskAltRoundedIcon from "@mui/icons-material/TaskAltRounded" ;
@@ -11,7 +12,7 @@ import {
11
12
} from "../../../recoil/repoData" ;
12
13
import { templateContent } from "../../../recoil/templateState" ;
13
14
import { issueSelectedState } from "../../../recoil/issueState" ;
14
- import { modalState } from "../../../recoil/commonState" ;
15
+ import { activeState , modalState } from "../../../recoil/commonState" ;
15
16
import { LoadingCompleted } from "../LoadingCompleted" ;
16
17
17
18
export const FinishDialog = ( props ) => {
@@ -29,8 +30,11 @@ export const FinishDialog = (props) => {
29
30
const readme = useRecoilValue ( templateContent ( "readme" ) ) ;
30
31
31
32
const [ dialogValue , setDialogValue ] = useRecoilState ( modalState ( props . type ) ) ;
33
+ const [ activeStep , setActiveStep ] = useRecoilState ( activeState ) ;
32
34
const [ clickDisabled , setClickDisabled ] = useState ( false ) ;
33
35
36
+ const navigate = useNavigate ( ) ;
37
+
34
38
async function checkDuplication ( ) {
35
39
try {
36
40
const response = await axios . post (
@@ -117,8 +121,8 @@ export const FinishDialog = (props) => {
117
121
}
118
122
119
123
const handlePost = async ( ) => {
120
- setClickDisabled ( true ) ;
121
- if ( clickDisabled ) {
124
+ if ( ! clickDisabled ) {
125
+ setClickDisabled ( true ) ;
122
126
setLoading ( true ) ;
123
127
const isUnique = await checkDuplication ( ) ;
124
128
if ( isUnique ) {
@@ -127,10 +131,15 @@ export const FinishDialog = (props) => {
127
131
await postEmail ( ) ;
128
132
localStorage . removeItem ( "recoil-persist" ) ;
129
133
setDialogValue ( false ) ;
134
+ setLoading ( false ) ;
130
135
} else {
131
136
alert (
132
- `Your repository '${ owner } /${ repoName } ' is already exists!\nPlease delete repository and try again!` ,
137
+ `Your repository '${ owner } /${ repoName } ' already exists!\nPlease delete repository and try again!` ,
133
138
) ;
139
+ setDialogValue ( false ) ;
140
+ setLoading ( false ) ;
141
+ setActiveStep ( 1 ) ;
142
+ navigate ( "/step1" ) ;
134
143
}
135
144
}
136
145
} ;
0 commit comments