-
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.
- Loading branch information
Showing
29 changed files
with
299 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
import { GranteeProjectDefaultPage } from '@/grants/pages/grantee-project-default-page'; | ||
import { getGranteeDetails } from '@/grants/data/get-grantee-details'; | ||
import { getGranteeProject } from '@/grants/data/get-grantee-project'; | ||
|
||
import { GranteeDefaultSection } from '@/grants/pages/grantee-default-section'; | ||
|
||
interface Props { | ||
params: { granteeId: string }; | ||
params: { grantId: string; granteeId: string }; | ||
} | ||
|
||
const Page = ({ params: { granteeId } }: Props) => ( | ||
<GranteeProjectDefaultPage granteeId={granteeId} /> | ||
); | ||
const Page = async ({ params: { grantId, granteeId } }: Props) => { | ||
const { data: grantee } = await getGranteeDetails(granteeId); | ||
|
||
// Default to the first project | ||
const project = await getGranteeProject(grantee.id); | ||
const stats = project.data.tabs[0].stats; | ||
|
||
return ( | ||
<GranteeDefaultSection grantId={grantId} grantee={grantee} stats={stats} /> | ||
); | ||
}; | ||
|
||
export default Page; |
22 changes: 17 additions & 5 deletions
22
src/app/grants/[grantId]/grantees/[granteeId]/projects/page.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 |
---|---|---|
@@ -1,10 +1,22 @@ | ||
import { GranteeProjectDefaultPage } from '@/grants/pages/grantee-project-default-page'; | ||
import { getGranteeDetails } from '@/grants/data/get-grantee-details'; | ||
import { getGranteeProject } from '@/grants/data/get-grantee-project'; | ||
|
||
import { GranteeDefaultSection } from '@/grants/pages/grantee-default-section'; | ||
|
||
interface Props { | ||
params: { granteeId: string }; | ||
params: { grantId: string; granteeId: string }; | ||
} | ||
|
||
const Page = ({ params: { granteeId } }: Props) => ( | ||
<GranteeProjectDefaultPage granteeId={granteeId} /> | ||
); | ||
const Page = async ({ params: { grantId, granteeId } }: Props) => { | ||
const { data: grantee } = await getGranteeDetails(granteeId); | ||
|
||
// Default to the first project | ||
const project = await getGranteeProject(grantee.id); | ||
const stats = project.data.tabs[0].stats; | ||
|
||
return ( | ||
<GranteeDefaultSection grantId={grantId} grantee={grantee} stats={stats} /> | ||
); | ||
}; | ||
|
||
export default Page; |
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 |
---|---|---|
@@ -1,10 +1,23 @@ | ||
import { GranteeDefaultPage } from '@/grants/pages/grantee-default-page'; | ||
import { getDefaultGrantee } from '@/grants/data/get-default-grantee'; | ||
import { getGranteeProject } from '@/grants/data/get-grantee-project'; | ||
|
||
import { GranteeDefaultSection } from '@/grants/pages/grantee-default-section'; | ||
|
||
interface Props { | ||
params: { grantId: string }; | ||
} | ||
|
||
const Page = ({ params: { grantId } }: Props) => ( | ||
<GranteeDefaultPage grantId={grantId} /> | ||
); | ||
const Page = async ({ params: { grantId } }: Props) => { | ||
const grantee = await getDefaultGrantee(grantId); | ||
|
||
if (!grantee) return <p>TODO: Empty Default Grantee UI</p>; | ||
|
||
// Default to the first project | ||
const project = await getGranteeProject(grantee.id); | ||
const stats = project.data.tabs[0].stats; | ||
|
||
return ( | ||
<GranteeDefaultSection grantId={grantId} grantee={grantee} stats={stats} /> | ||
); | ||
}; | ||
export default Page; |
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 |
---|---|---|
@@ -1,10 +1,23 @@ | ||
import { GranteeDefaultPage } from '@/grants/pages/grantee-default-page'; | ||
import { getDefaultGrantee } from '@/grants/data/get-default-grantee'; | ||
import { getGranteeProject } from '@/grants/data/get-grantee-project'; | ||
|
||
import { GranteeDefaultSection } from '@/grants/pages/grantee-default-section'; | ||
|
||
interface Props { | ||
params: { grantId: string }; | ||
} | ||
|
||
const Page = ({ params: { grantId } }: Props) => ( | ||
<GranteeDefaultPage grantId={grantId} /> | ||
); | ||
const Page = async ({ params: { grantId } }: Props) => { | ||
const grantee = await getDefaultGrantee(grantId); | ||
|
||
if (!grantee) return <p>TODO: Empty Default Grantee UI</p>; | ||
|
||
// Default to the first project | ||
const project = await getGranteeProject(grantee.id); | ||
const stats = project.data.tabs[0].stats; | ||
|
||
return ( | ||
<GranteeDefaultSection grantId={grantId} grantee={grantee} stats={stats} /> | ||
); | ||
}; | ||
export default Page; |
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,16 @@ | ||
import { getGrantDetails } from '@/grants/data/get-grant-details'; | ||
import { getGranteeDetails } from '@/grants/data/get-grantee-details'; | ||
import { getGranteesList } from '@/grants/data/get-grantees-list'; | ||
|
||
export const getDefaultGrantee = async (grantId: string) => { | ||
const { data: grant } = await getGrantDetails(grantId); | ||
const { data: grantees } = await getGranteesList({ | ||
page: 1, | ||
grantId: grant.id, | ||
}); | ||
|
||
if (grantees.length === 0) return null; | ||
const { data: firstGrantee } = await getGranteeDetails(grantees[0].id); | ||
|
||
return firstGrantee; | ||
}; |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
import { Grantee, GranteeProjectStat } from '@/grants/core/schemas'; | ||
import { GranteeProjectStats } from '@/grants/components/grantee-project/project-stats'; | ||
|
||
import { GranteePageLayout } from '@/grants/pages/grantee-page-layout'; | ||
|
||
interface Props { | ||
grantId: string; | ||
grantee: Grantee; | ||
stats: GranteeProjectStat[]; | ||
} | ||
|
||
/** | ||
* Display first grantee details by default for the following routes: | ||
* - /grants/:grantId | ||
* - /grants/:grantId/grantees | ||
* - /grants/:grantId/grantees/:granteeId | ||
* - /grants/:grantId/grantees/:granteeId/projects | ||
* */ | ||
export const GranteeDefaultSection = ({ grantId, grantee, stats }: Props) => { | ||
// TODO: JOB-683 | ||
// TODO: JOB-684 | ||
|
||
const baseHref = `/grants/${grantId}/grantees/${grantee.id}/projects`; | ||
|
||
return ( | ||
<GranteePageLayout baseHref={baseHref} grantee={grantee}> | ||
<GranteeProjectStats stats={stats} /> | ||
</GranteePageLayout> | ||
); | ||
}; |
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 was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.