Skip to content

Commit

Permalink
fix : steps 객체로 감싸서 생긴 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
(hoooooony) committed Jun 20, 2024
1 parent 0190800 commit 2f7201a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/page/Auth/FindPassword/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ export interface OutletProps {
setIsComplete: React.Dispatch<React.SetStateAction<boolean>>;
isStepComplete: boolean;
setIsStepComplete: React.Dispatch<React.SetStateAction<boolean>>;
isSearch: boolean;
setIsSearch: React.Dispatch<React.SetStateAction<boolean>>;
isShopSelect: boolean;
setIsShopSelect: React.Dispatch<React.SetStateAction<boolean>>;
}
9 changes: 3 additions & 6 deletions src/page/Auth/Signup/components/searchShop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ import { ChangeEvent, useEffect, useState } from 'react';
import { useFormContext } from 'react-hook-form';
import { useOutletContext } from 'react-router-dom';
import cn from 'utils/ts/className';
import { OutletProps } from 'page/Auth/FindPassword/entity';
import styles from './searchShop.module.scss';

interface Step {
isShopSelect: boolean;
setIsShopSelect: (state: boolean) => void;
}
interface ShopInfo {
shop_name: string;
shop_id: number | null;
}
export default function SearchShop() {
const [searchText, setSearchText] = useState('');
const { steps, setValue } = useOutletContext<{ steps: Step; setValue: Function }>();
const steps : OutletProps = useOutletContext();
const { shopList, isError } = useShopList();
const {
watch,
watch, setValue,
} = useFormContext<ShopInfo>();
function handleClickShop(e: React.MouseEvent<HTMLButtonElement>) {
const { name, id } = JSON.parse(e.currentTarget.value);
Expand Down
11 changes: 2 additions & 9 deletions src/page/Auth/Signup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { useEffect, useState } from 'react';
import { useOutletContext } from 'react-router-dom';
import { OutletProps } from 'page/Auth/FindPassword/entity';
import AgreeStep from './components/agreeStep';
import OwnerInfoStep from './components/ownerInfoStep';
import PhoneStep from './components/phoneStep';
import SearchShop from './components/searchShop';

interface Step {
index: number;
previousStep: () => void;
setIsStepComplete: (state: boolean) => void;
isSearch: boolean;
setIsSearch: (state: boolean) => void;
}

interface SelectOptions {
personal: boolean;
koin: boolean;
Expand All @@ -25,7 +18,7 @@ const initialSelectOption: SelectOptions = {

export default function SignUp() {
const [selectItems, setSelectItems] = useState<SelectOptions>(initialSelectOption);
const { steps } = useOutletContext<{ steps: Step; }>();
const steps:OutletProps = useOutletContext();
const [stepPhoneComplete, setStepPhoneComplete] = useState(false);

const handleSelect = (option: keyof SelectOptions | 'all') => {
Expand Down
4 changes: 2 additions & 2 deletions src/page/Auth/components/Common/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function CommonLayout() {
mode: 'onChange',
});
const {
formState: { errors }, setError, getValues, setValue,
formState: { errors }, setError, getValues,
} = method;

const steps = useStep(isFindPassword ? 'find' : 'register');
Expand Down Expand Up @@ -159,7 +159,7 @@ export default function CommonLayout() {
<div className={styles.content}>
{isComplete
? <Done isFindPassword={isFindPassword} />
: <Outlet context={{ steps, setValue, getValues }} />}
: <Outlet context={steps} />}
</div>
{!isComplete && !isSearch && (
<button
Expand Down

0 comments on commit 2f7201a

Please sign in to comment.