Skip to content

Commit

Permalink
fix: dashboard project amount data
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed May 4, 2022
1 parent 9498568 commit 5b841cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/model/gantt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ISchedule } from 'tui-calendar'
import dayjs from 'dayjs'
import { scheduleCalendarMapAtom } from './schedule'
import { getPageData } from '@/util/logseq'
import { catrgorizeTask } from '@/util/schedule'

const MOCK_PROJECTS: IGroup[] = [
{ id: '111', title: 'project1', events: [ { title: 'xxxxxxx', start: '2022-05-03', end: '2022-05-04', id: 'yyyy' } ], milestones: [ {start: '2022-05-03', end: '2022-05-03', title: 'milesttttsfasfsadfasffdasf', 'id': 'xxx'} ], style: { bgColor: '#fff', borderColor: '#fff', color: '#000' } },
Expand All @@ -20,6 +21,7 @@ export const ganttDataAtom = atom<IGroup[] | null>((get) => {
const ganttData: IGroup[] = (enabledCalendarList.map(calendar => calendar.id)).map(calendarId => {
const schedules = get(scheduleCalendarMapAtom).get(calendarId)
if (!schedules) return null
const { doing, todo, done } = catrgorizeTask(schedules)
const convertScheduleToGanttEvent = (schedule: ISchedule): IEvent => {
const { raw = {}, start, end, id = '', title = '' } = schedule
const dayjsStart = dayjs(start as string)
Expand Down Expand Up @@ -57,6 +59,11 @@ export const ganttDataAtom = atom<IGroup[] | null>((get) => {
return {
id: calendarId,
title: calendarId,
amount: {
doing: doing?.length,
todo: todo?.length,
done: done?.length,
},
style: {
bgColor: schedules?.[0]?.bgColor || '#fff',
borderColor: schedules?.[0]?.borderColor || '#fff',
Expand Down
5 changes: 5 additions & 0 deletions src/packages/Gantt/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export type IGroup = {
events: IEvent[]
milestones?: IEvent[]
levelCount?: number
amount?: {
todo: number
doing: number
done: number
},
style?: {
color: string
bgColor: string
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/components/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Project: React.FC<{
<div className="ml-3">
<div className="text-lg title-text">{data.title}</div>
<div className="mt-1 description-text">
todo: 10 doing: 5 done: 5
{`doing: ${data?.amount?.doing || 0} todo: ${data?.amount?.todo || 0} done: ${data?.amount?.done || 0}`}
</div>
</div>
</div>
Expand Down

0 comments on commit 5b841cb

Please sign in to comment.