Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kimeodml committed Apr 10, 2024
2 parents c89e749 + 646c36c commit 166f08e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/page/Auth/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Login() {
const { login, isError: isServerError } = useLogin();
const [isFormError, setIsFormError] = useState(false);
const navigate = useNavigate();
const { loginError, loginErrorCode } = useErrorMessageStore();
const { loginError, loginErrorStatus } = useErrorMessageStore();
const [emailError, setEmailError] = useState('');
const { value: isModalOpen, changeValue: toggle } = useBooleanState(false);
const isError = isServerError || isFormError;
Expand Down Expand Up @@ -134,7 +134,7 @@ export default function Login() {
</div>
</form>
</div>
{loginErrorCode === 100005 && isModalOpen && <ApprovalModal toggle={toggle} />}
{loginErrorStatus === 403 && isModalOpen && <ApprovalModal toggle={toggle} />}
</div>
);
}
2 changes: 1 addition & 1 deletion src/page/MyShopPage/components/EditShopInfoModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ EditShopInfoModalProps) {
<label htmlFor="deliveryPrice" className={styles['main-info__label']}>
<span className={styles['main-info__header']}>배달금액</span>
<input
type="text"
type="number"
id="deliveryPrice"
value={deliveryPrice === 0 ? '' : deliveryPrice}
onChange={(e) => setDeliveryPrice(Number(e.target.value))}
Expand Down
2 changes: 1 addition & 1 deletion src/page/ShopRegistration/view/Mobile/Sub/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function Sub() {
>
배달금액
<input
type="text"
type="number"
id="deliveryPrice"
onChange={(e) => setDeliveryPrice(Number(e.target.value))}
value={deliveryPrice}
Expand Down
3 changes: 1 addition & 2 deletions src/query/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface ErrorResponse {

export const useLogin = () => {
const { setUserType } = useUserTypeStore();
const { setLoginError, setLoginErrorCode } = useErrorMessageStore();
const { setLoginError } = useErrorMessageStore();

const {
mutate, error, isError, isSuccess,
Expand Down Expand Up @@ -67,7 +67,6 @@ export const useLogin = () => {
}
sessionStorage.removeItem('access_token');
localStorage.removeItem('refresh_token');
setLoginErrorCode(err.code);
}
},
});
Expand Down
4 changes: 4 additions & 0 deletions src/store/errorMessageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface ErrorMessageStore {
setLogoutError: (error: string) => void;
logoutErrorCode: number;
setLogoutErrorCode: (error: number) => void;
loginErrorStatus: number;
setLoginErrorStatus: (error: number) => void;
}

export const useErrorMessageStore = create<ErrorMessageStore>((set) => ({
Expand All @@ -28,4 +30,6 @@ export const useErrorMessageStore = create<ErrorMessageStore>((set) => ({
setLogoutError: (error) => set({ loginError: error }),
logoutErrorCode: 0,
setLogoutErrorCode: (error) => set({ loginErrorCode: error }),
loginErrorStatus: 0,
setLoginErrorStatus: (error) => set({ loginErrorStatus: error }),
}));
7 changes: 6 additions & 1 deletion src/store/userType.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isKoinError } from '@bcsdlab/koin';
import { getUserType } from 'api/auth';
import { UserType } from 'model/auth';
import { create } from 'zustand';
import { useErrorMessageStore } from './errorMessageStore';

interface UserTypeStore {
userType: UserType;
Expand All @@ -19,8 +21,11 @@ const useUserTypeStore = create<UserTypeStore>((set) => ({
}
return state;
});
} catch {
} catch (err) {
set((state) => (state.userType !== null ? { userType: null } : state));
if (isKoinError(err)) {
useErrorMessageStore.getState().setLoginErrorStatus(err.status);
}
}
},
}));
Expand Down

0 comments on commit 166f08e

Please sign in to comment.