Skip to content

Commit

Permalink
[#155] Fix: 재료 선택시 search params 소문자로 수정 (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-Jaemin420 authored Feb 12, 2024
1 parent a47be9a commit 31b96d9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/shared/CheerSuccessModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const CheerSuccessModal = ({
};

const handleClickViewMessage = () => {
setSearchParams(`?ingredient=${ingredientKey}`, { replace: true });
setSearchParams(`?ingredient=${ingredientKey?.toLowerCase()}`, { replace: true });

viewMessageOverlay.open(({ isOpen, close: handleCloseViewMessageModal }) => (
<ViewMessageModal
Expand Down
4 changes: 2 additions & 2 deletions src/components/shared/ViewMessageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface Props {

const ViewMessageModal = ({ isOpen, onClose, ingredientKey }: Props) => {
const [searchParams] = useSearchParams();
const [selectedIngredient, setSelectedIngredient] = useAtom($selectedIngredient);
const [, setSelectedIngredient] = useAtom($selectedIngredient);
const { nickname, message, isAnonymous } = useAtomValue($ingredientSupportMessage);

useEffect(() => {
Expand All @@ -38,7 +38,7 @@ const ViewMessageModal = ({ isOpen, onClose, ingredientKey }: Props) => {

const handleClickCopyLinkButton = () => {
copyLink({
path: `${location.pathname}?ingredient=${selectedIngredient}`,
path: `${location.pathname}?ingredient=${ingredientKey.toLowerCase()}`,
eventCategory: "작성한 응원 메시지 공유",
});
};
Expand Down
9 changes: 4 additions & 5 deletions src/pages/TteokgukPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const TteokgukPage = () => {
const [, setSelectedIngredient] = useAtom($selectedIngredient);

useEffect(() => {
const ingredientKey = searchParams.get("ingredient") as IngredientKey;
const ingredientKey = searchParams.get("ingredient")?.toUpperCase() as IngredientKey;
if (ingredientKey === null) return;

const { nickname, message, ingredient } = tteokgukCheerMessages.supporters[ingredientKey];
Expand Down Expand Up @@ -120,7 +120,6 @@ const TteokgukPage = () => {
tteokgukId,
memberId,
} = tteokguk;
const isLoggedIn = !!getLocalStorage("accessToken");
const isMyTteokguk = loggedInUserDetails?.id === memberId;

const handleClickAddIngredientButton = () => {
Expand Down Expand Up @@ -226,7 +225,7 @@ const TteokgukPage = () => {
setIngredientSupportMessage((previousState) => ({ ...previousState, nickname, message }));
setSelectedIngredient(ingredient);

setSearchParams(`?ingredient=${ingredientKey}`, { replace: true });
setSearchParams(`?ingredient=${ingredientKey?.toLowerCase()}`, { replace: true });

viewMessageOverlay.open(({ isOpen, close }) => {
return (
Expand Down Expand Up @@ -315,14 +314,14 @@ const TteokgukPage = () => {
</div>
</article>

{!isLoggedIn && (
{!getLocalStorage("accessToken") && (
<Link to="/login">
<Button color="primary.45" applyColorTo="outline">
소원 떡국 만들기
</Button>
</Link>
)}
{isLoggedIn && !isMyTteokguk && !completion && (
{!!getLocalStorage("accessToken") && !isMyTteokguk && !completion && (
<Button
onClick={handleClickAddIngredientButton}
color="primary.45"
Expand Down
5 changes: 4 additions & 1 deletion src/store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ export const $signup = atomWithMutation(() => ({
mutationFn: (body: SignupRequest): Promise<SignupResponse> => postSignup(body),
}));

export const $login = atomWithMutation(() => ({
export const $login = atomWithMutation((get) => ({
mutationFn: (body: LoginRequest): Promise<LoginResponse> => postLogin(body),
onSuccess: () => {
get(queryClientAtom).invalidateQueries();
},
}));

export const $postKakaoToken = atomWithMutation(() => ({
Expand Down
2 changes: 1 addition & 1 deletion src/store/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { LoggedInUserDetailsResponse, RandomUserResponse } from "@/types/user.dt

export const $getMyDetails = atomWithQuery(() => ({
queryKey: ["myDetails"],
queryFn: async () => getMyDetails(),
queryFn: getMyDetails,
}));

export const $getUserDetail = atomFamilyWithQuery("users", (id: number) => {
Expand Down

0 comments on commit 31b96d9

Please sign in to comment.