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

[주변 상점] 비밀번호 찾기 진입오류 수정 #356

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/page/Auth/FindPassword/ChangePassword/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function ChangePassword() {
register, formState: { errors, isValid }, getValues, clearErrors,
} = useFormContext<ChangePasswordForm>();

const steps: OutletProps = useOutletContext();
const steps = useOutletContext<OutletProps>();
const { setIsStepComplete } = steps;

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/page/Auth/FindPassword/Verify/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function Verify() {

const [isSent, setIsSent] = useState(false);
const debounce = useDebounce<SendCode>(code, { getValues, setError, setIsSent });
const steps: OutletProps = useOutletContext();
const steps = useOutletContext<OutletProps>();

const { setCertificationCode, isCertified } = useCheckCode(
steps.setIsStepComplete,
Expand Down
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>>;
}
2 changes: 1 addition & 1 deletion src/page/Auth/FindPassword/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OutletProps } from './entity';
import Verify from './Verify';

export default function FindPassword() {
const steps: OutletProps = useOutletContext();
const steps = useOutletContext<OutletProps>();
const { index } = steps;
return (
<>
Expand Down
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 = useOutletContext<OutletProps>();
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 = useOutletContext<OutletProps >();
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
Loading