Skip to content

Commit

Permalink
fix: close function
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Jul 20, 2022
1 parent 47c60fe commit 06aab7b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions apps/storefront/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ body {
const HeaderContainer = styled('div')(() => ({
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
justifyContent: 'flex-end',
marginBottom: '1rem',
}))

export default function App() {
Expand All @@ -35,8 +36,7 @@ export default function App() {
{isOpen ? (
<Layout close={() => setIsOpen(false)}>
<HeaderContainer>
<p>bundle b2b</p>
<RegisteredCloseButton />
<RegisteredCloseButton setIsOpen={setIsOpen} />
</HeaderContainer>
<Routes>
<Route
Expand All @@ -49,7 +49,7 @@ export default function App() {
/>
<Route
path="/registered"
element={<Registered />}
element={<Registered setIsOpen={setIsOpen} />}
/>
</Routes>
</Layout>
Expand Down
5 changes: 3 additions & 2 deletions apps/storefront/src/components/RegisteredCloseButton.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useNavigate } from 'react-router-dom'
import { Close } from '@mui/icons-material'

export function RegisteredCloseButton() {
export function RegisteredCloseButton(props: any) {
const { setIsOpen } = props
const navigate = useNavigate()

const handleCloseForm = () => {
const isHasFrontPage = window?.history?.length > 2

setIsOpen(false)
if (isHasFrontPage) {
navigate(-1)
} else {
Expand Down
10 changes: 8 additions & 2 deletions apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
useEffect, useState, useContext,
useEffect, useState, useContext, Dispatch, SetStateAction,
} from 'react'
import { useNavigate } from 'react-router-dom'

Expand Down Expand Up @@ -32,7 +32,12 @@ import {

import { RegisteredContainer, RegisteredImage } from './styled'

export default function Registered() {
interface RegisteredProps {
setIsOpen: Dispatch<SetStateAction<boolean>>,
}

export default function Registered(props: RegisteredProps) {
const { setIsOpen } = props
const [activeStep, setActiveStep] = useState(0)
const navigate = useNavigate()

Expand Down Expand Up @@ -135,6 +140,7 @@ export default function Registered() {
})
}

setIsOpen(false)
if (isHasFrontPage) {
navigate(-1)
} else {
Expand Down

0 comments on commit 06aab7b

Please sign in to comment.