-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from frankduandou/20240603_gantt-chart_ads-man…
…agement ads management gantt chart and some update on ad details
- Loading branch information
Showing
16 changed files
with
694 additions
and
162 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
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,93 @@ | ||
'use client'; | ||
import React, { FC, useState, useEffect } from 'react'; | ||
import Grid from '@/components/ui/gantt-chart/grid'; | ||
import Tasks from '@/components/ui/gantt-chart/tasks'; | ||
import TimeTable from '@/components/ui/gantt-chart/time-table'; | ||
import { GetAllTaskDurations, GetAllTasks } from '@/lib/data'; | ||
|
||
interface TimeTableProps { | ||
|
||
timeRange: { | ||
fromSelectYear: string; | ||
fromSelectMonth: number; | ||
toSelectYear: string; | ||
toSelectMonth: number; | ||
}; | ||
tasks: { | ||
id: string; | ||
name: string; | ||
}[]; | ||
taskDurations: { | ||
task: string; | ||
start: string; | ||
end: string; | ||
id: string; | ||
headline: string; | ||
channel: string; | ||
url: string; | ||
budget: number; | ||
}[]; | ||
|
||
setTaskDurations: (taskDurations: { | ||
task: string; | ||
start: string; | ||
end: string; | ||
id: string; | ||
headline: string; | ||
channel: string; | ||
url: string; | ||
budget: number; | ||
}[]) => void; | ||
} | ||
|
||
const GanttChart: FC = () => { | ||
const [tasks, setTasks] = useState<null | any>(null); | ||
const [taskDurations, setTaskDurations] = useState<null | any>(null); | ||
const [timeRange, setTimeRange] = useState<TimeTableProps["timeRange"]>({ | ||
fromSelectMonth: 0, | ||
fromSelectYear: '2024', | ||
toSelectMonth: 5, | ||
toSelectYear: '2024', | ||
}); | ||
|
||
useEffect(() => { | ||
const tasktemp = GetAllTasks(); | ||
setTasks(tasktemp); | ||
const taskDurationtemp = GetAllTaskDurations(); | ||
setTaskDurations(taskDurationtemp); | ||
}, []); | ||
|
||
return ( | ||
<div id="gantt-container"> | ||
<Grid> | ||
<Tasks | ||
tasks={tasks} | ||
setTasks={setTasks} | ||
setTaskDurations={setTaskDurations} | ||
/> | ||
<TimeTable | ||
timeRange={timeRange} | ||
tasks={tasks} | ||
taskDurations={taskDurations} | ||
setTaskDurations={setTaskDurations} | ||
/> | ||
</Grid> | ||
<style jsx>{` | ||
#gantt-container { | ||
--color-text: #272a2e; | ||
--color-primary-dark: #0195e4; | ||
--color-primary-light: #9ddcff; | ||
--color-secondary: #4be35a; | ||
--color-tertiary: #f7f7f7; | ||
--color-orange: #ef5350; | ||
--color-outline: #e9eaeb; | ||
--border-radius: 5px; | ||
--cell-height: 40px; | ||
padding: 1rem; | ||
} | ||
`}</style> | ||
</div> | ||
); | ||
} | ||
|
||
export default GanttChart; |
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,24 @@ | ||
import React, { FC, ReactNode } from 'react'; | ||
|
||
interface GridProps { | ||
children: ReactNode; | ||
} | ||
|
||
const Grid: FC<GridProps> = ({ children }) => { | ||
return ( | ||
<div id="gantt-grid-container" className='grid grid-cols-[150px_1fr] shadow-[3px_3px_3px_rgba(0,0,0,0.05)] rounded-[5px]'> | ||
{children} | ||
<style jsx>{` | ||
#gantt-grid-container { | ||
display: grid; | ||
grid-template-columns: 150px 1fr; | ||
outline: 2px solid var(--color-outline); | ||
border-radius: 5px; | ||
box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.05); | ||
} | ||
`}</style> | ||
</div> | ||
); | ||
} | ||
|
||
export default Grid; |
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,64 @@ | ||
import React, { FC, useEffect, useRef } from 'react'; | ||
|
||
interface Task { | ||
id: number; | ||
name: string; | ||
} | ||
|
||
interface TasksProps { | ||
tasks: Task[]; | ||
setTasks: (tasks: Task[]) => void; | ||
setTaskDurations: (durations: number[]) => void; | ||
} | ||
|
||
const Tasks: FC<TasksProps> = ({ tasks, setTasks, setTaskDurations }) => { | ||
const inputRef = useRef<HTMLInputElement[]>([]); | ||
const indexRef = useRef<number | null>(null); | ||
|
||
useEffect(() => { | ||
if (inputRef.current.length && indexRef.current !== null) { | ||
inputRef.current[indexRef.current]?.focus(); | ||
} | ||
}); | ||
|
||
return ( | ||
<div id="gantt-grid-container__tasks"> | ||
<div className="gantt-task-row"></div> | ||
<div className="gantt-task-row"></div> | ||
<div className="gantt-task-row"></div> | ||
{tasks && | ||
tasks.map((tsk, i) => ( | ||
<div key={`${i}-${tsk?.id}-${tsk.name}`} className="gantt-task-row"> | ||
<input | ||
data-task-id={tsk?.id} | ||
value={tsk?.name} | ||
ref={(el) => (inputRef.current[i] = el as HTMLInputElement)} | ||
/> | ||
</div> | ||
))} | ||
<style jsx>{` | ||
#gantt-grid-container__tasks { | ||
outline: 0.5px solid var(--color-outline); | ||
} | ||
.gantt-task-row { | ||
display: flex; | ||
outline: 0.5px solid var(--color-outline); | ||
text-align: center; | ||
height: var(--cell-height); | ||
border: none; | ||
} | ||
input { | ||
width: 127px; | ||
border: none; | ||
outline: none; | ||
background: none; | ||
font-size: 0.875rem; | ||
} | ||
`}</style> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Tasks; |
Oops, something went wrong.