Skip to content

Commit

Permalink
handle insights when there are no events
Browse files Browse the repository at this point in the history
  • Loading branch information
xvvvyz committed Jun 27, 2024
1 parent cc8c0c6 commit 7d8d9bb
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/_components/event-type-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const EventTypeForm = ({
isMulti
label="Inputs"
name={field.name}
noOptionsMessage={() => 'Type to create a new input'}
noOptionsMessage={() => 'Type to create a new input.'}
onBlur={field.onBlur}
onChange={field.onChange}
onCreateOption={(value) =>
Expand Down
2 changes: 1 addition & 1 deletion app/_components/form-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const FormBanner = <T extends FieldValues>({
<Select
className="mt-16 text-left"
instanceId="template-select"
noOptionsMessage={() => 'No templates'}
noOptionsMessage={() => 'No templates.'}
onChange={(t) => {
const template = (
t as NonNullable<ListTemplatesWithDataData>[0]
Expand Down
2 changes: 1 addition & 1 deletion app/_components/input-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const InputForm = ({
isMulti
label="For"
name={field.name}
noOptionsMessage={() => 'No subjects'}
noOptionsMessage={() => 'No subjects.'}
onBlur={field.onBlur}
onChange={(value) => field.onChange(value)}
options={subjects as IOption[]}
Expand Down
1 change: 1 addition & 0 deletions app/_components/insight-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const InsightForm = ({ events, insight, subjectId }: InsightFormProps) => {
isClearable={false}
label="Input"
name={field.name}
noOptionsMessage={() => 'No inputs have been recorded.'}
onBlur={field.onBlur}
onChange={(value) => field.onChange((value as IOption).id)}
options={inputOptions}
Expand Down
4 changes: 2 additions & 2 deletions app/_components/module-form-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const ModuleFormSection = <T extends FieldValues, U extends ArrayPath<T>>({
isCreatable
isMulti
name={field.name}
noOptionsMessage={() => 'Type to create a new input'}
noOptionsMessage={() => 'Type to create a new input.'}
onBlur={field.onBlur}
onChange={field.onChange}
onCreateOption={(value) =>
Expand All @@ -208,7 +208,7 @@ const ModuleFormSection = <T extends FieldValues, U extends ArrayPath<T>>({
<Select
className="mt-16 text-left"
instanceId="template-select"
noOptionsMessage={() => 'No templates'}
noOptionsMessage={() => 'No templates.'}
onChange={(t) => {
const template = (
t as NonNullable<ListTemplatesWithDataData>[0]
Expand Down
4 changes: 2 additions & 2 deletions app/_components/subject-insights-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const SubjectInsightsPage = async ({
getCurrentUser(),
]);

if (!subject) return null;
if (!subject || !events) return null;
const isTeamMember = !!user && subject.team_id === user.id;
const shareOrSubjects = isPublic ? 'share' : 'subjects';
const searchObject = new URLSearchParams(searchParams);
Expand All @@ -58,7 +58,7 @@ const SubjectInsightsPage = async ({
Create insight
</Button>
)}
{!events?.length || !insights?.length ? (
{!insights?.length ? (
<Empty className="mt-4">
<InformationCircleIcon className="w-7" />
No insights.
Expand Down
2 changes: 1 addition & 1 deletion app/_components/template-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const TemplateForm = ({
isMulti
label="Inputs"
name={field.name}
noOptionsMessage={() => 'Type to create a new input'}
noOptionsMessage={() => 'Type to create a new input.'}
onBlur={field.onBlur}
onChange={(value) => field.onChange(value)}
onCreateOption={(value) =>
Expand Down

0 comments on commit 7d8d9bb

Please sign in to comment.