Skip to content

Commit

Permalink
Merge pull request #24 from MOVIEJOJO7/feature/#23
Browse files Browse the repository at this point in the history
Feat : 환경변수 사용 X, 쿠키로 대체 pr
  • Loading branch information
LikeFireAndSky authored Nov 10, 2023
2 parents ea2874b + a3ce535 commit ca4537a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Components/Open/ChatGenerator/ChatGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import { useRecoilState } from 'recoil';
import { Inputs } from './ChatGenerator.type';
import { useFetchPostNewChat } from '@/hooks/Open/useFetchPostNewChat';
import { useCurrentSearchParams } from '@/hooks/Open/useCurrentSearchParmas';
import { getCookie } from '@/Components/Login/Cookie';

const ChatGenerator = () => {
const accessToken = process.env.NEXT_PUBLIC_ACCESS_TOKEN as string;
const accessToken = getCookie('accessToken');
const mutation = useFetchPostNewChat(accessToken);
const params = useCurrentSearchParams('type');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import {
} from '@material-tailwind/react';
import { useFetchAllUserHook } from '@/hooks/Open/useFetchAllUserHook';
import { User } from '@/types';
import { getCookie } from '@/Components/Login/Cookie';
import { RegisterFn } from '../ChatGenerator.type';

const ChatGeneratorMenu = ({ register }: RegisterFn) => {
const accessToken = process.env.NEXT_PUBLIC_ACCESS_TOKEN;
const accessToken = getCookie('accessToken');
const { data } = useFetchAllUserHook(accessToken as string);

return (
Expand Down
6 changes: 4 additions & 2 deletions Components/Open/ChatList/ChatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import { Chat } from '@/app/open/open.type';
import { filterChat } from '@/app/open/open.utils';
import ChatItem from './ChatItem';
import { useQuery } from '@tanstack/react-query';
import { getCookie } from '@/Components/Login/Cookie';
import { fetchAllChat } from '@/app/open/open.utils';

const ChatList = ({ myChatList }: ChatListProps) => {
const accessToken = getCookie('accessToken');
const { data: chatList } = useQuery({
queryKey: ['myChatList'],
queryFn: () => fetchAllChat(process.env.NEXT_PUBLIC_ACCESS_TOKEN as string),
queryFn: () => fetchAllChat(accessToken),
initialData: myChatList,
staleTime: 1000 * 60,
refetchInterval: 1000 * 120,
refetchInterval: 1000 * 60,
});
const filteredChatList = filterChat(chatList.chats);
return (
Expand Down
6 changes: 5 additions & 1 deletion app/open/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import ChatList from '@/Components/Open/ChatList/ChatList';
import SpeedDialWithTextInside from '@/Components/Open/SpeedDial/SpeedDial';
import ChatGenerator from '@/Components/Open/ChatGenerator/ChatGenerator';
import Link from 'next/link';
import { cookies } from 'next/headers';

const Open = async () => {
const accessToken = process.env.NEXT_PUBLIC_ACCESS_TOKEN as string;
const cookieStore = cookies();
const accessTokens = cookieStore.get('accessToken');
const accessToken = accessTokens?.value as string;

const result = await fetchAllChat(accessToken);

return (
Expand Down

0 comments on commit ca4537a

Please sign in to comment.