-
Notifications
You must be signed in to change notification settings - Fork 0
[DEV] LLMInputBox 페이지별 연결 #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bd5db78
feat: LLMInputBox 페이지별 API 연결
drddyn 568eb72
feat: 프록시 우회 설정
drddyn 98d6832
Update LLMInputLayout.tsx
drddyn 8e618da
style: llm인풋박스 스타일링 변경
drddyn 07692ec
Merge branch 'develop' into dev/llm-input-api
drddyn 52ed6ca
feat: 제미나이 피드백 반영
drddyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,59 @@ | ||
| import { useLocation } from 'react-router-dom' | ||
| import { matchPath, useLocation } from 'react-router-dom' | ||
| import LLMInputBox from './LLMInputBox' | ||
| import usePostAddSection from '../hooks/usePostAddSection' | ||
| import usePostAddSectionInSectionPage from '../hooks/usePostAddSectionInSectionPage' | ||
| import usePostMagazine from '../hooks/usePostMagazine' | ||
| import { useAuthStore } from '../stores/auth' | ||
|
|
||
| export default function LLMInputLayout() { | ||
| const { isLoggedIn } = useAuthStore() | ||
| const location = useLocation() | ||
| const hiddenPath = ['/login', '/signup', '/landing', '/'] | ||
| const isHiddenPath = hiddenPath.includes(location.pathname) | ||
|
|
||
| if (!isHiddenPath) | ||
| return ( | ||
| <div className="absolute bottom-8 translate-x-1/2"> | ||
| <LLMInputBox /> | ||
| const postAddSectionMutation = usePostAddSection() | ||
| const postAddInSectionPageMutation = usePostAddSectionInSectionPage() | ||
| const postMagazineMutation = usePostMagazine() | ||
|
|
||
| const sectionMatch = matchPath('/magazine/:magazineId/section/:sectionId', location.pathname) | ||
| const magazineMatch = matchPath('/magazine/:magazineId', location.pathname) | ||
|
|
||
| const currentMagazineId = magazineMatch?.params.magazineId | ||
|
|
||
| const isNumericMagazineId = currentMagazineId && !isNaN(Number(currentMagazineId)) | ||
|
|
||
| if (!isLoggedIn || isHiddenPath) return null | ||
|
|
||
| const handleSend = (value: string) => { | ||
| if (sectionMatch) { | ||
| // 섹션 페이지 | ||
| const { magazineId, sectionId } = sectionMatch.params | ||
| postAddInSectionPageMutation.mutate({ | ||
| magazineId: Number(magazineId), | ||
| sectionId: Number(sectionId), | ||
| message: value, | ||
| }) | ||
| } else if (magazineMatch && isNumericMagazineId) { | ||
| // 매거진 페이지 | ||
| const { magazineId } = magazineMatch.params | ||
| postAddSectionMutation.mutate({ | ||
| magazineId: Number(magazineId), | ||
| message: value, | ||
| }) | ||
| } else { | ||
| // 그외 페이지 | ||
| postMagazineMutation.mutate({ | ||
| topic: value, | ||
| user_mood: '', | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <div className="fixed bottom-8 left-0 w-full flex justify-center z-50 pointer-events-none"> | ||
| <div className="pointer-events-auto"> | ||
| <LLMInputBox onSend={handleSend} /> | ||
| </div> | ||
| ) | ||
| return null | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query' | ||
| import { postAddSection } from '../api/magazine' | ||
|
|
||
| export default function usePostAddSection() { | ||
| const queryClient = useQueryClient() | ||
| return useMutation({ | ||
| mutationFn: postAddSection, | ||
| onSuccess: () => { | ||
| queryClient.invalidateQueries({ queryKey: ['mymagazines'] }) | ||
| }, | ||
| onError: (error) => { | ||
| console.log('섹션 생성:', error) | ||
| alert('섹션 생성에 실패했습니다.') | ||
| }, | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query' | ||
| import { postAddSectionInSectionPage } from '../api/magazine' | ||
|
|
||
| export default function usePostAddSectionInSectionPage() { | ||
| const queryClient = useQueryClient() | ||
| return useMutation({ | ||
| mutationFn: postAddSectionInSectionPage, | ||
| onSuccess: () => { | ||
| queryClient.invalidateQueries({ queryKey: ['mymagazines', 'sections'] }) | ||
| }, | ||
| onError: (error) => { | ||
| console.log('섹션 생성:', error) | ||
| alert('섹션 생성에 실패했습니다.') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
References
|
||
| }, | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alert()는 사용자의 흐름을 방해하고 좋지 않은 사용자 경험을 제공할 수 있습니다. 에러 메시지를 표시하기 위해 토스트 UI 컴포넌트나 페이지 내 메시지 영역을 사용하는 것을 고려해 보세요. 이는 사용자에게 더 나은 피드백을 제공하고 애플리케이션의 일관성을 유지하는 데 도움이 됩니다.References