@@ -10,6 +10,7 @@ import { SimpleTitle } from "../../components/Typography";
1010
1111const Apply = ( ) => {
1212 const [ currentPeriods , setCurrentPeriods ] = useState < periodType [ ] > ( [ ] ) ;
13+ const [ upcomingPeriods , setUpcomingPeriods ] = useState < periodType [ ] > ( [ ] )
1314
1415 const {
1516 data : periodsData ,
@@ -33,6 +34,14 @@ const Apply = () => {
3334 return startDate <= today && endDate >= today ;
3435 } )
3536 ) ;
37+
38+ setUpcomingPeriods (
39+ periodsData . periods . filter ( ( period : periodType ) => {
40+ const startDate = new Date ( period . applicationPeriod . start || "" ) ;
41+
42+ return startDate >= today
43+ } )
44+ )
3645 } , [ periodsData ] ) ;
3746
3847 if ( periodsIsLoading ) return < PeriodSkeletonPage /> ;
@@ -41,7 +50,7 @@ const Apply = () => {
4150 return (
4251 < div className = "flex flex-col justify-between overflow-x-hidden text-online-darkBlue dark:text-white" >
4352 < div className = "flex flex-col items-center justify-center gap-5 px-5" >
44- { currentPeriods . length === 0 ? (
53+ { currentPeriods . length === 0 && upcomingPeriods . length === 0 ? (
4554 < div className = "flex flex-col items-center justify-center gap-8" >
4655 < SimpleTitle title = "Ingen åpne opptak for øyeblikket" />
4756 < p className = "w-10/12 max-w-2xl text-center text-md " >
@@ -74,15 +83,30 @@ const Apply = () => {
7483 </ p >
7584 </ div >
7685 ) : (
77- < div className = "flex flex-col gap-10" >
78- < SimpleTitle title = "Nåværende opptaksperioder" />
79- < div className = "flex flex-col items-center max-w-full gap-5" >
80- { currentPeriods . map ( ( period : periodType , index : number ) => (
81- < PeriodCard key = { index } period = { period } />
82- ) ) }
83- </ div >
84- </ div >
85- ) }
86+ < >
87+ { currentPeriods . length > 0 ? (
88+ < div className = "flex flex-col gap-10" >
89+ < SimpleTitle title = "Nåværende opptaksperioder" />
90+ < div className = "flex flex-col items-center max-w-full gap-5" >
91+ { currentPeriods . map ( ( period : periodType , index : number ) => (
92+ < PeriodCard key = { index } period = { period } active = { true } />
93+ ) ) }
94+ </ div >
95+ </ div >
96+ ) : < > </ > }
97+ { upcomingPeriods . length > 0 ? (
98+ < div className = "flex flex-col gap-10 mt-16" >
99+ < SimpleTitle title = "Kommende opptaksperioder" />
100+ < div className = "flex flex-col items-center max-w-full gap-5" >
101+ { upcomingPeriods . map ( ( period : periodType , index : number ) => (
102+ < PeriodCard key = { index } period = { period } active = { false } />
103+ ) ) }
104+ </ div >
105+ </ div >
106+ ) : < > </ > }
107+ </ >
108+ )
109+ }
86110 </ div >
87111 </ div >
88112 ) ;
0 commit comments