Skip to content

Commit

Permalink
feature-081: 비회원일 때 이동하는 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
gs0428 committed Feb 19, 2024
1 parent 1630ad3 commit 331ec06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
32 changes: 17 additions & 15 deletions src/components/layout/header/alarm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { modelingStatusState } from '@/stores/model-controller';
import * as HeaderStyle from '@/styles/layout/header';

import AlarmList from './AlarmList';
import { userTokenState } from '@/stores/user';

type Props = {
isDark: boolean;
};

const Alarm = ({ isDark }: Props) => {
const status = useRecoilValue(modelingStatusState);
const userToken = useRecoilValue(userTokenState);
const [isOpen, setIsOpen] = useState(false);
const [alarmList, setAlarmList] = useState<IAlarm[]>([]);

Expand All @@ -41,24 +43,24 @@ const Alarm = ({ isDark }: Props) => {

useEffect(() => {
if (status === 'ERROR' || status === 'COMPLETE') {
console.log(status, 'dd');
callAPI();
userToken && callAPI();
}

if (status === 'CONTINUE') {
setAlarmList([
{
state: 'success',
type: 'video',
alarm_id: 999,
title: '열심히 영상을 변환하는 중이에요!',
content: '잠시후 멋진 글을 만날 수 있어요:)',
is_confirm: 0,
created_at: new Date().toString(),
updated_at: new Date().toString(),
},
...alarmList,
]);
userToken &&
setAlarmList([
{
state: 'success',
type: 'video',
alarm_id: 999,
title: '열심히 영상을 변환하는 중이에요!',
content: '잠시후 멋진 글을 만날 수 있어요:)',
is_confirm: 0,
created_at: new Date().toString(),
updated_at: new Date().toString(),
},
...alarmList,
]);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [status]);
Expand Down
16 changes: 6 additions & 10 deletions src/hooks/useCreateVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ const useCreateVideo = () => {
const createVideo = async () => {
if (!modelingData) return;

if (userToken) {
try {
const { video_id } = (await createVideoAPI(modelingData)).data.result;
try {
const { video_id } = (await createVideoAPI(modelingData)).data.result;

navigate(`/summary/${video_id}`);
setModelingData(null);
} catch (e) {
console.error(e);
}
} else {
navigate('/summary/guest');
navigate(`/summary/${video_id}${!userToken && '?insight=true'}`);
setModelingData(null);
} catch (e) {
console.error(e);
}

setVideoLink(null);
Expand Down

0 comments on commit 331ec06

Please sign in to comment.