-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: Add portfolio view page
- Loading branch information
Showing
15 changed files
with
288 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
'use client'; | ||
import axios from 'axios'; | ||
import IntroSidebarStore from '@/store/introSidebarStore'; | ||
import { useSidebarIconsStore } from '@/store/sidebarIconsStore'; | ||
import experienceSectionStore from '@/store/experienceSectionStore'; | ||
import { useProjectsStore } from '@/store/projectStore'; | ||
import ContactSidebarStore from '@/store/contactSidebarStore'; | ||
|
||
const API_URL = 'https://gitlio.fly.dev/api/'; | ||
|
||
export async function getPortfolioDataByDomain(domainName: string) { | ||
const response = await axios.get(API_URL + 'portfolios/domain/' + domainName); | ||
return response.data; // 백엔드에서 포트폴리오 데이터를 반환한다고 가정 | ||
} | ||
|
||
export const updateStoresWithPortfolioData = async (domainName: string) => { | ||
const portfolioData = await getPortfolioDataByDomain(domainName); | ||
|
||
console.log('Fetched portfolio data:', portfolioData); | ||
|
||
if (!portfolioData) { | ||
console.error('Failed to fetch portfolio data'); | ||
|
||
return; | ||
} | ||
|
||
// Assuming `portfolioData` includes sections that correspond to data needed for each store | ||
IntroSidebarStore.setState({ profile: portfolioData.introData }); | ||
useSidebarIconsStore.setState({ dropAreas: portfolioData.skillData }); | ||
experienceSectionStore.setState({ sections: portfolioData.experienceData }); | ||
useProjectsStore.setState({ projects: portfolioData.projectData }); | ||
ContactSidebarStore.setState({ contactInfo: portfolioData.contactData }); | ||
}; |
This file contains 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
46 changes: 46 additions & 0 deletions
46
gitlio/app/editor/_components/(skill)/DraggableIconView.tsx
This file contains 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,46 @@ | ||
import React from 'react'; | ||
import { useDraggable } from '@dnd-kit/core'; | ||
import { IconType } from 'react-icons'; | ||
import { FaTimes } from 'react-icons/fa'; | ||
import { useSidebarIconsStore } from '@/store/sidebarIconsStore'; | ||
import usePreviewStore from '@/store/previewStore'; | ||
import { icons } from '@/app/editor/_components/(skill)/icons'; | ||
|
||
interface DraggableIconProps { | ||
id: string; | ||
IconComponent?: IconType; | ||
label: string; | ||
areaId?: string; | ||
} | ||
|
||
const DraggableIcon: React.FC<DraggableIconProps> = ({ | ||
id, | ||
IconComponent, | ||
label, | ||
areaId, | ||
}) => { | ||
const logoExists = icons.hasOwnProperty(label); | ||
if (logoExists) { | ||
IconComponent = icons[label as keyof typeof icons]; | ||
} | ||
|
||
const areaClass = areaId ? `area-${areaId}` : 'default-area'; | ||
|
||
return ( | ||
<div | ||
className={`p-2 text-md font-semibold flex justify-between items-center bg-gray-200 rounded-lg ${areaClass}`} | ||
aria-label={`Draggable icon for ${label}`} | ||
role="button" | ||
tabIndex={0} | ||
> | ||
<div className="flex-grow-1 flex items-center justify-start"> | ||
{' '} | ||
{/* 드래그 리스너를 이 부분에만 적용 */} | ||
{IconComponent && <IconComponent />} | ||
<span className="ml-2 mr-2">{label}</span> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DraggableIcon; |
30 changes: 30 additions & 0 deletions
30
gitlio/app/editor/_components/(skill)/DropAreaComponentView.tsx
This file contains 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,30 @@ | ||
import React from 'react'; | ||
import { useSidebarIconsStore } from '@/store/sidebarIconsStore'; | ||
import DropArea from './DropArea'; | ||
import useLayoutStore from '@/store/layoutDesignStore'; | ||
import DropAreaView from '@/app/editor/_components/(skill)/DropAreaView'; | ||
|
||
const DropAreaComponent: React.FC = () => { | ||
const { dropAreas } = useSidebarIconsStore(); | ||
const { skill } = useLayoutStore(); | ||
|
||
return ( | ||
<> | ||
{dropAreas.slice(1).map((area) => ( | ||
<div key={area.id} className="mb-4 last:mb-0"> | ||
<div className="bg-white rounded-lg overflow-hidden"> | ||
{/* 타이틀 표시 추가 */} | ||
<div | ||
className={`p-2 ${skill.option === 'option2' ? 'bg-red-400' : 'bg-blue-500'} text-white text-center font-bold`} | ||
> | ||
{area.title} | ||
</div> | ||
<DropAreaView id={area.id} /> | ||
</div> | ||
</div> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default DropAreaComponent; |
This file contains 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,35 @@ | ||
'use client'; | ||
import React from 'react'; | ||
import { useSidebarIconsStore } from '@/store/sidebarIconsStore'; | ||
import DraggableIcon from './DraggableIcon'; | ||
import DraggableIconView from '@/app/editor/_components/(skill)/DraggableIconView'; | ||
|
||
interface DropAreaProps { | ||
id: string; | ||
} | ||
|
||
const DropArea: React.FC<DropAreaProps> = ({ id }) => { | ||
const { dropAreas } = useSidebarIconsStore(); | ||
const area = dropAreas.find((area) => area.id === id) || { icons: [] }; | ||
|
||
return ( | ||
<div className="min-w-[200px] min-h-[60px] h-auto bg-neutral-content/30 rounded flex flex-wrap items-center justify-center p-2"> | ||
{area.icons.length > 0 ? ( | ||
area.icons.map((icon) => ( | ||
<div className="m-2" key=""> | ||
<DraggableIconView | ||
key={icon.id} | ||
id={icon.id} | ||
IconComponent={icon.logo} | ||
label={icon.label} | ||
/> | ||
</div> | ||
)) | ||
) : ( | ||
<p className="text-gray-500">Drop icons here</p> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default DropArea; |
This file contains 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 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 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 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 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 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,46 @@ | ||
'use client'; | ||
import React, { useEffect, useState } from 'react'; | ||
import IntroSection from '@/app/editor/_components/mainSection/IntroSection'; | ||
import SkillSection from '@/app/editor/_components/mainSection/SkillSection'; | ||
import ExperienceSection from '@/app/editor/_components/mainSection/ExperienceSection'; | ||
import ProjSection from '@/app/editor/_components/mainSection/ProjSection'; | ||
import ContactSection from '@/app/editor/_components/mainSection/ContactSection'; | ||
import { updateStoresWithPortfolioData } from '@/actions/viewPage'; | ||
|
||
export default function PortfolioPage({ | ||
params, | ||
}: { | ||
params: { domainName: string }; | ||
}) { | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
console.log('Fetching portfolio data for domain:', params.domainName); | ||
await updateStoresWithPortfolioData(params.domainName); | ||
setLoading(false); | ||
}; | ||
|
||
fetchData(); | ||
}, [params.domainName]); | ||
|
||
if (loading) { | ||
return ( | ||
<div className="flex flex-col space-y-4"> | ||
<div className="flex justify-center items-center min-h-screen"> | ||
<span className="loading loading-spinner loading-lg"></span> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col space-y-4"> | ||
<IntroSection /> | ||
<SkillSection /> | ||
<ExperienceSection /> | ||
<ProjSection isViewMode={true} /> | ||
<ContactSection /> | ||
</div> | ||
); | ||
} |
This file contains 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,65 @@ | ||
// EditorLayout.tsx | ||
'use client'; | ||
|
||
import { SignedIn, SignedOut, SignInButton, UserButton } from '@clerk/nextjs'; | ||
import { useRouter } from 'next/navigation'; | ||
import Image from 'next/image'; | ||
import { FaSignInAlt } from 'react-icons/fa'; | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
const EditorLayout: React.FC<{ children: React.ReactNode }> = ({ | ||
children, | ||
}) => { | ||
const router = useRouter(); | ||
const handleLogoClick = () => { | ||
router.push('/studio/dashboard'); | ||
}; | ||
|
||
const [isClient, setIsClient] = useState(false); | ||
|
||
useEffect(() => { | ||
setIsClient(true); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex flex-col min-h-screen bg-base-200"> | ||
<div className="navbar bg-neutral-800 fixed top-0 left-0 right-0 z-10"> | ||
<div className="flex-1"> | ||
<a | ||
className="btn btn-ghost text-xl text-white hover:bg-base-300/20" | ||
onClick={handleLogoClick} | ||
> | ||
<Image | ||
src={'/logo_white_lg.svg'} | ||
alt={'whiteLogo'} | ||
width={30} | ||
height={30} | ||
/> | ||
GITLIO | ||
</a> | ||
</div> | ||
<div className="flex-none gap-6 pr-4"> | ||
{isClient && ( | ||
<> | ||
<SignedOut> | ||
<SignInButton> | ||
<FaSignInAlt className="text-white size-6" /> | ||
</SignInButton> | ||
</SignedOut> | ||
<SignedIn> | ||
<UserButton /> | ||
</SignedIn> | ||
</> | ||
)} | ||
</div> | ||
</div> | ||
<div className="flex-grow flex overflow-hidden"> | ||
<div className="flex flex-col flex-grow mt-24 overflow-auto justify-center items-center"> | ||
<div className="flex mb-16">{children}</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EditorLayout; |
This file contains 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,4 +1,4 @@ | ||
import create from 'zustand'; | ||
import { create } from 'zustand'; | ||
|
||
interface BlogUrl { | ||
id: string; | ||
|
This file contains 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 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