Skip to content

Commit

Permalink
[Fix] FutureTimeLine
Browse files Browse the repository at this point in the history
  • Loading branch information
Najah7 committed Mar 11, 2024
1 parent 79181de commit 5a80aa8
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/components/organisms/FutureTimeLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import TimeLineItem from '../molecules/TimeLineItem'
import Line from '../atoms/Line'

type MileStone = {
type MileStone = {
userId: string;
milestoneId: string;
title: string;
Expand All @@ -16,22 +16,27 @@ function FutureTimeLine({ milestones }: { milestones: MileStone[] }) {
if (milestones.length === 0) {
return <div>まだイベントがありません</div>
}
else if (milestones.length === 1) {
return (
<TimeLineItem key={milestones[0].milestoneId} {...milestones[0]} />
)
}

const finalMilestone: MileStone | undefined = milestones && milestones.length > 0 ? milestones.pop() : undefined;

const finalMilestone: MileStone = milestones[-1]
const milestonesWithoutFinal: MileStone[] = milestones.slice(0, -1)

return (
<>
{milestones.length > 0 && milestones.map((milestone) => {
return (
<>
<TimeLineItem key={milestone.milestoneId} {...milestone} />
<Line />
</>
{milestonesWithoutFinal.length > 0 && milestones.map((milestone) => {
return (
<>
<TimeLineItem key={milestone.milestoneId} {...milestone} />
<Line />
</>

)
})}
{finalMilestone && <TimeLineItem key={finalMilestone.milestoneId} {...finalMilestone} />}
)
})}
{<TimeLineItem key={finalMilestone.milestoneId} {...finalMilestone} />}
</>
)
}
Expand Down

0 comments on commit 5a80aa8

Please sign in to comment.