Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create financial reports guide #1091

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/components/PeriodicReports/FinancialReportCheckList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Checkbox, FormControl, FormControlLabel } from '@material-ui/core';
import React from 'react';
import {
FinancialReportsQuery,
NarrativeReportsQuery,
} from '../../scenes/Projects/Reports/ProjectReports.generated';

const ReportGuideAction = {
SET_RANGE: 'SET_RANGE',
ADD_MANAGING_PARTNER: 'ADD_MANAGING_PARTNER',
SET_REPORT_FREQUENCY: 'SET_REPORT_FREQUENCY',
};
zkhin marked this conversation as resolved.
Show resolved Hide resolved

export const FinancialReportCheckList = ({
zkhin marked this conversation as resolved.
Show resolved Hide resolved
data: { project },
}: {
data: FinancialReportsQuery | NarrativeReportsQuery;
}) => {
const checkList = Object.keys(ReportGuideAction).map((action) => {
switch (action) {
case ReportGuideAction.SET_RANGE:
return {
label: `Define the project's date range`,
checked:
!!project.mouRange.value.start && !!project.mouRange.value.end,
};
case ReportGuideAction.ADD_MANAGING_PARTNER:
return {
label: 'Add a managing partner',
checked: project.partnerships.items.length > 0,
};
default:
return {
label: `Set the managing partner's reporting frequency`,
checked: !!project.financialReportPeriod.value,
};
}
});
return (
<>
{checkList.map((item, index) => (
<FormControl key={`check-list-${index}`} fullWidth>
<FormControlLabel
label={item.label}
control={
<Checkbox
name={`check-list-${index}`}
checked={item.checked}
disabled
/>
}
/>
</FormControl>
))}
</>
);
};
113 changes: 65 additions & 48 deletions src/components/PeriodicReports/PeriodicReportCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,18 @@ export interface PeriodicReportCardProps {
dueNext?: SecuredPeriodicReportFragment;
disableIcon?: boolean;
hasDetailPage?: boolean;
metRequirement?: boolean;
}

const PeriodicReportCardInContext = (props: PeriodicReportCardProps) => {
const { type, dueCurrently, dueNext, disableIcon, hasDetailPage } = props;
const {
type,
dueCurrently,
dueNext,
disableIcon,
hasDetailPage,
metRequirement = true,
} = props;
const classes = useStyles();

const currentFile = dueCurrently?.value?.reportFile;
Expand Down Expand Up @@ -119,63 +127,72 @@ const PeriodicReportCardInContext = (props: PeriodicReportCardProps) => {
<Typography color="initial" variant="h4" paragraph>
{`${type} Reports`}
</Typography>
<div className={classes.relevantReports}>
<ReportInfo
title="Current"
report={dueCurrently}
className={classes.relevantReport}
/>
<Divider orientation="vertical" flexItem variant="middle" />
<ReportInfo
title="Next"
report={dueNext}
className={classes.relevantReport}
/>
</div>
{metRequirement ? (
<div className={classes.relevantReports}>
<ReportInfo
title="Current"
report={dueCurrently}
className={classes.relevantReport}
/>
<Divider orientation="vertical" flexItem variant="middle" />
<ReportInfo
title="Next"
report={dueNext}
className={classes.relevantReport}
/>
</div>
) : (
<div>
<span>Not all requirements have been met</span> <br />
<span>Click here to view remaining list</span>
</div>
zkhin marked this conversation as resolved.
Show resolved Hide resolved
)}
</div>
</CardActionAreaLink>
<CardActions>
<ButtonLink color="primary" to={link}>
View Reports
</ButtonLink>
{needsUpload ? (
<Tooltip
title={
<>
Upload report for <ReportLabel report={dueCurrently} />
</>
}
>
<Button color="primary" onClick={openFileBrowser}>
Upload Report
</Button>
</Tooltip>
) : currentFile?.value ? (
hasDetailPage ? (
<ButtonLink
color="primary"
to={`${link}/${dueCurrently!.value!.id}`}
>
View Report
</ButtonLink>
) : (
{metRequirement && (
<CardActions>
<ButtonLink color="primary" to={link}>
View Reports
</ButtonLink>
{needsUpload ? (
<Tooltip
title={
<>
Preview report for <ReportLabel report={dueCurrently} />
Upload report for <ReportLabel report={dueCurrently} />
</>
}
>
<Button
color="primary"
onClick={() => openFilePreview(currentFile.value!)}
>
Preview Report
<Button color="primary" onClick={openFileBrowser}>
Upload Report
</Button>
</Tooltip>
)
) : null}
</CardActions>
) : currentFile?.value ? (
hasDetailPage ? (
<ButtonLink
color="primary"
to={`${link}/${dueCurrently!.value!.id}`}
>
View Report
</ButtonLink>
) : (
<Tooltip
title={
<>
Preview report for <ReportLabel report={dueCurrently} />
</>
}
>
<Button
color="primary"
onClick={() => openFilePreview(currentFile.value!)}
>
Preview Report
</Button>
</Tooltip>
)
) : null}
</CardActions>
)}
<DropOverlay report={dueCurrently} show={isDragActive} />
<input {...getInputProps()} name="report_file_uploader" />
</Card>
Expand Down
8 changes: 7 additions & 1 deletion src/components/PeriodicReports/PeriodicReportsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ export const PeriodicReportsList = ({
breadcrumbs = [],
pageTitleSuffix,
reports,
requirementCheckList,
onRowClick,
}: {
type: ReportType;
breadcrumbs?: ReactNode[];
pageTitleSuffix?: string;
reports?: readonly PeriodicReportFragment[];
requirementCheckList?: ReactNode;
zkhin marked this conversation as resolved.
Show resolved Hide resolved
onRowClick?: (rowData: ReportRow) => void;
}) => {
const classes = useStyles();
Expand All @@ -52,7 +54,11 @@ export const PeriodicReportsList = ({
{reportTypeName}
</Typography>

<PeriodicReportsTable data={reports} onRowClick={onRowClick} />
{requirementCheckList ? (
requirementCheckList
) : (
<PeriodicReportsTable data={reports} onRowClick={onRowClick} />
)}
</main>
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions src/scenes/Projects/Overview/ProjectOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { CreateInternshipEngagement } from '../../Engagement/InternshipEngagemen
import { CreateLanguageEngagement } from '../../Engagement/LanguageEngagement/Create/CreateLanguageEngagement';
import { useProjectCurrentDirectory, useUploadProjectFiles } from '../Files';
import { ProjectListQueryVariables } from '../List/projects.generated';
import { FinancialReportsDocument } from '../Reports/ProjectReports.generated';
import { EditableProjectField, UpdateProjectDialog } from '../Update';
import { ProjectWorkflowDialog } from '../Update/ProjectWorkflowDialog';
import { useProjectId } from '../useProjectId';
Expand Down Expand Up @@ -159,6 +160,10 @@ export const ProjectOverview: FC = () => {
},
});

const { data: financialReportsData } = useQuery(FinancialReportsDocument, {
variables: { projectId, changeset: changesetId },
});
zkhin marked this conversation as resolved.
Show resolved Hide resolved

const projectName = projectOverviewData?.project.name;
const isTranslation = projectOverviewData
? projectOverviewData.project.__typename === 'TranslationProject'
Expand Down Expand Up @@ -496,6 +501,11 @@ export const ProjectOverview: FC = () => {
projectOverviewData?.project.currentFinancialReportDue
}
dueNext={projectOverviewData?.project.nextFinancialReportDue}
metRequirement={
projectOverviewData?.project &&
financialReportsData?.project.reports.canRead === true &&
financialReportsData.project.reports.items.length > 0
}
/>
</Grid>
<Grid item xs={12} md={6}>
Expand Down
23 changes: 23 additions & 0 deletions src/scenes/Projects/Reports/ProjectReports.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ query NarrativeReports($projectId: ID!, $changeset: ID) {
...PeriodicReport
}
}
mouRange {
...securedDateRange
}
financialReportPeriod {
canRead
canEdit
value
}
partnerships {
...PartnershipSummary
zkhin marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

Expand All @@ -16,6 +27,18 @@ query FinancialReports($projectId: ID!, $changeset: ID) {
items {
...PeriodicReport
}
canRead
}
mouRange {
...securedDateRange
}
financialReportPeriod {
canRead
canEdit
value
}
partnerships {
...PartnershipSummary
}
}
}
8 changes: 8 additions & 0 deletions src/scenes/Projects/Reports/ProjectReports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useQuery } from '@apollo/client';
import React from 'react';
import { ReportType } from '../../../api';
import { Error } from '../../../components/Error';
import { FinancialReportCheckList } from '../../../components/PeriodicReports/FinancialReportCheckList';
import { PeriodicReportsList } from '../../../components/PeriodicReports/PeriodicReportsList';
import { ProjectBreadcrumb } from '../../../components/ProjectBreadcrumb';
import { useProjectId } from '../useProjectId';
Expand Down Expand Up @@ -36,6 +37,13 @@ export const ProjectReports = ({ type }: { type: ReportType }) => {
reports={data?.project.reports.items}
breadcrumbs={[<ProjectBreadcrumb data={data?.project} />]}
pageTitleSuffix={data?.project.name.value ?? 'A Project'}
requirementCheckList={
data &&
data.project.reports.items.length === 0 &&
type === 'Financial' ? (
<FinancialReportCheckList data={data} />
) : null
}
/>
);
};