-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Area specific Descrition and skill level
- Loading branch information
1 parent
9d35c33
commit 4708d1d
Showing
8 changed files
with
204 additions
and
13 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
31 changes: 31 additions & 0 deletions
31
apps/dashboard-app/app/(dashboard)/skill-trees/_action/summary.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,31 @@ | ||
'use server' | ||
export const calculateTotalLength = async (skillTree:any, skillTrees:any) => { | ||
let totalNotes = skillTree["Self"] | ||
let totalAttachments = skillTree["Others"] | ||
let totalVideos = skillTree["Videos"] | ||
let totalProjects = skillTree["Projects"] | ||
let children = skillTree["Sub-tasks"] | ||
while (children.length > 0) { | ||
const childId = children.pop() | ||
const child = skillTrees.find((item:any) => item.id === childId) | ||
totalNotes.push(...child["Self"]) | ||
totalAttachments.push(...child["Others"]) | ||
totalVideos.push(...child["Videos"]) | ||
totalProjects.push(...child["Projects"]) | ||
children.push(...child["Sub-tasks"]) | ||
} | ||
return {totalNotes, totalAttachments, totalVideos, totalProjects} | ||
} | ||
|
||
export const calculateTotalLengthPerType = async (skillTrees:any, skillTreeItems:any) => { | ||
let notes:any = [] | ||
let attachments:any = [] | ||
let videos:any = [] | ||
for (let skillTree of skillTrees){ | ||
const {totalNotes, totalAttachments, totalVideos, totalProjects: projects} = await calculateTotalLength(skillTree, skillTreeItems) | ||
notes.push(...totalNotes) | ||
attachments.push(...totalAttachments) | ||
videos.push(...totalVideos) | ||
} | ||
return {notes, attachments, videos} | ||
} |
18 changes: 18 additions & 0 deletions
18
apps/dashboard-app/app/(dashboard)/skill-trees/_components/Settings.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,18 @@ | ||
'use client' | ||
import React from 'react' | ||
import DbSelection from '../../../../components/DbSelection' | ||
|
||
const Settings = () => { | ||
|
||
return ( | ||
<div className='my-4 flex flex-col w-[95%] mx-[2.5%] '> | ||
<h1 className='text-2xl font-medium my-4 text-center'>Create or Attach your Knowledge Base Notion DBs</h1> | ||
<div className='flex flex-wrap'> | ||
<DbSelection title='Areas Notion Db' name='Areas' fieldName="areasDb"/> | ||
<DbSelection title='Skill Treees Notion Db' name='Skill Trees' fieldName="skillTreesDb"/> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Settings |
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
75 changes: 75 additions & 0 deletions
75
apps/dashboard-app/app/(dashboard)/skill-trees/_components/SkillTreeDialog.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,75 @@ | ||
'use client' | ||
import React, { useContext, useState } from 'react'; | ||
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '@repo/ui/molecules/shadcn/Dialog'; | ||
import { Button } from '@repo/ui/molecules/shadcn/Button'; | ||
import { queryNotionPageAction } from '../../../../actions/notion/notion'; | ||
import { ConnectionsContext } from '../../../../providers/connections-provider'; | ||
import { format } from 'date-fns'; | ||
|
||
|
||
const SkillTreeDialog = ({ title, content }: any) => { | ||
|
||
const [pages, setPages] = useState<any>([]); | ||
const connectionsContext = useContext(ConnectionsContext); | ||
const apiToken = connectionsContext?.notionNode?.accessToken | ||
const [selectedPageId, setSelectedPageId] = useState<string | null>(null); // State to track selected page ID | ||
|
||
const handleClick = (event: React.MouseEvent) => { | ||
event.stopPropagation(); | ||
const fetchPages = async () => { | ||
console.log(content, apiToken) | ||
if (!content || !apiToken) return; | ||
for (let page of content) { | ||
const data = await queryNotionPageAction({apiToken, pageId: page }); | ||
console.log(data) | ||
setPages((pages: any) => [...pages, data]); | ||
} | ||
} | ||
setPages([]); | ||
fetchPages(); | ||
event.stopPropagation(); // Prevent the event from bubbling up to the Card | ||
}; | ||
|
||
const handlePageClick = (page: any) => { | ||
let id = page.Name.replaceAll(' ','-').replaceAll('/','-') + '-'+ page.id.replaceAll('-',''); | ||
console.log(id) | ||
const url = `https://www.notion.so/${id}`; // Replace with your desired URL | ||
window.open(url, '_blank'); | ||
}; | ||
|
||
|
||
return ( | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button variant='outline' onClick={handleClick}>{title}</Button> | ||
</DialogTrigger> | ||
<DialogContent className='h-[90vh] min-w-[80%] flex flex-col'> | ||
<DialogHeader> | ||
<DialogTitle className='text-center mb-4'>{title}</DialogTitle> | ||
</DialogHeader> | ||
<div className='flex-1 overflow-y-auto'> | ||
{pages && pages.length > 0 ? ( | ||
<div className='flex flex-col'> | ||
{pages.map((page: any, index: number) => ( | ||
<div key={index} className='cursor-pointer hover:bg-gray-800 p-4' onClick={() => handlePageClick(page)}> | ||
<div className='flex items-center justify-start gap-2'> | ||
{page.Name} | ||
<DialogDescription>{page['Review Date'] ? format(page['Review Date'], "dd MMMyy") : ''} | </DialogDescription> | ||
<DialogDescription>{page?.['Self Grade Name']}</DialogDescription> | ||
</div> | ||
<DialogDescription>{page.Description ? page.Description : 'No Description Available'}</DialogDescription> | ||
</div> | ||
))} | ||
</div> | ||
) : ( | ||
<p>No {title.toLowerCase()} available.</p> | ||
)} | ||
</div> | ||
<DialogFooter> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default SkillTreeDialog; |
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