Skip to content

Commit

Permalink
fix: undefined to null
Browse files Browse the repository at this point in the history
  • Loading branch information
soomin9106 committed Jun 30, 2024
1 parent 5b741cd commit d2c9d32
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/app/unsubscribe/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { useRouter } from "next/navigation";

import React, { ReactNode } from "react";
Expand Down
4 changes: 2 additions & 2 deletions src/subscription/hooks/useArticleInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useEffect, useState } from "react"
import { getCookie } from "@subscription/utils"

export const useArticleInfo = () =>{
const [articleId, setArticleId] = useState<string | undefined>(undefined)
const [workbookId, setWorkbookId] = useState<string | undefined>(undefined)
const [articleId, setArticleId] = useState<string | null>(null)
const [workbookId, setWorkbookId] = useState<string | null>(null)

useEffect(function getArticleInfo () {
const curArticleId = getCookie('articleId');
Expand Down
2 changes: 1 addition & 1 deletion src/subscription/hooks/useUnsubscribeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { zodResolver } from "@hookform/resolvers/zod";

export const useUnsubscribeForm = () => {
const { toast } = useToast();
const [email, setEmail] = useState<string | undefined>(undefined);
const [email, setEmail] = useState<string | null>(null);

useEffect(function getEmailFromCookie() {
const userEmail = getCookie('user-email');
Expand Down
2 changes: 1 addition & 1 deletion src/subscription/remotes/postUnsubscriptionQueryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const unsubscribeWorkbook = (
return axiosRequest("post", API_ROUTE.UNSUBSCRIBE(), body);
};

export const unsubscribeWorkbookOptions = (email: string | undefined): UseMutationOptions<
export const unsubscribeWorkbookOptions = (email: string | null): UseMutationOptions<
ApiResponse<MessageOnlyResponse>,
Error,
UnsubscribeBody
Expand Down
6 changes: 3 additions & 3 deletions src/subscription/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const getCookie = (name: string): string | undefined => {
export const getCookie = (name: string): string | null => {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) {
return parts.pop()?.split(";").shift();
return parts.pop()?.split(";").shift() as string
}
return undefined;
return null;
};

0 comments on commit d2c9d32

Please sign in to comment.