Skip to content

Commit

Permalink
Show cohort bucket and participant count in PersonView
Browse files Browse the repository at this point in the history
  • Loading branch information
domdomegg committed Oct 15, 2024
1 parent a841400 commit a9cb30d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type Preset = {
cohortsTableStartDateField?: string;
cohortsTableEndDateField?: string;
cohortsIterationField?: string;
cohortsBucketField?: string;
};

const createPreset = (name: string) => ({
Expand Down
7 changes: 7 additions & 0 deletions frontend/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,13 @@ const SetupPage = () => {
globalConfigKey={[...path, "cohortsIterationField"]}
/>
</FormField>
<FormField label="Bucket field">
<FieldPickerSynced
table={cohortsTable}
allowedTypes={[FieldType.MULTIPLE_RECORD_LINKS, FieldType.MULTIPLE_LOOKUP_VALUES]}
globalConfigKey={[...path, "cohortsBucketField"]}
/>
</FormField>
</div>
)}
</div>
Expand Down
10 changes: 10 additions & 0 deletions frontend/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const ViewPerson: React.FC<{ tableId: string, recordId: string }> = ({ tableId,
preset.cohortsTableStartDateField,
preset.cohortsTableEndDateField,
preset.cohortsIterationField,
preset.cohortsBucketField,
personType.cohortsTableField,
],
});
const cohortsWithTimes = rawCohorts.flatMap((cohort) => {
Expand All @@ -63,6 +65,8 @@ const ViewPerson: React.FC<{ tableId: string, recordId: string }> = ({ tableId,
name: cohort.name,
iteration: cohort.getCellValueAsString(preset.cohortsIterationField!),
timeAv: meetingDates.map((d) => fromDate(d)) as Interval,
bucket: preset.cohortsBucketField ? cohort.getCellValueAsString(preset.cohortsBucketField) : "Unknown",
participantCount: (cohort.getCellValue(personType.cohortsTableField!) as string[])?.length,
};
});

Expand Down Expand Up @@ -121,6 +125,8 @@ const ViewPerson: React.FC<{ tableId: string, recordId: string }> = ({ tableId,
<div className="w-full rounded border border-solid border-gray-200 max-h-72 overflow-auto">
<div className="flex bg-slate-100 p-1 font-medium">
<div style={{ flex: "4 1 0" }}>Cohort</div>
<div style={{ flex: "2 1 0" }}>Bucket</div>
<div style={{ flex: "1 1 0" }}># participants</div>
<div style={{ flex: "1 1 0" }}>Meeting time</div>
</div>
<div className="w-full bg-white divide-y divide-gray-200">
Expand All @@ -142,6 +148,10 @@ const ViewPerson: React.FC<{ tableId: string, recordId: string }> = ({ tableId,
>
<CohortBlob name={cohort.name} />
</div>
<div style={{ flex: "2 1 0" }}>
{cohort.bucket}
</div>
<div style={{ flex: "1 1 0" }}>{cohort.participantCount}</div>
<div style={{ flex: "1 1 0" }}>
{format(cohort.timeAv).replace(" ", " – ")}
</div>
Expand Down

0 comments on commit a9cb30d

Please sign in to comment.