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

enhance(apps/analytics): add overview of element feedbacks on activities and instances #4401

Merged
merged 9 commits into from
Dec 20, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { SelectField } from '@uzh-bf/design-system'
import { useTranslations } from 'next-intl'
import { Dispatch, SetStateAction } from 'react'

function PerformanceActivityTypeFilter({
function ActivityTypeFilter({
activityType,
setActivityType,
}: {
activityType: ActivityType | 'all'
setActivityType: Dispatch<SetStateAction<'all' | ActivityType>>
setActivityType: Dispatch<SetStateAction<ActivityType | 'all'>>
}) {
const t = useTranslations()

Expand All @@ -33,4 +33,4 @@ function PerformanceActivityTypeFilter({
)
}

export default PerformanceActivityTypeFilter
export default ActivityTypeFilter
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { H1, UserNotification } from '@uzh-bf/design-system'
import { useTranslations } from 'next-intl'
import React from 'react'
import Layout from '~/components/Layout'
import Layout from '../Layout'

function AnalyticsErrorView({
title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Loader from '@klicker-uzh/shared-components/src/Loader'
import { useTranslations } from 'next-intl'
import Layout from '~/components/Layout'
import Layout from '../Layout'

function AnalyticsLoadingView({
title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { TextField } from '@uzh-bf/design-system'
import { useTranslations } from 'next-intl'

interface PerformanceSearchFieldProps {
interface AnalyticsSearchFieldProps {
type: 'activity' | 'instance'
value: string
onChange: (value: string) => void
}

function PerformanceSearchField({
function AnalyticsSearchField({
type,
value,
onChange,
}: PerformanceSearchFieldProps) {
}: AnalyticsSearchFieldProps) {
const t = useTranslations()

return (
Expand All @@ -31,4 +31,4 @@ function PerformanceSearchField({
)
}

export default PerformanceSearchField
export default AnalyticsSearchField
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SelectField } from '@uzh-bf/design-system'
import { useTranslations } from 'next-intl'
import { Dispatch, SetStateAction } from 'react'

function PerformanceElementTypeFilter({
function ElementTypeFilter({
elementType,
setElementType,
}: {
Expand All @@ -29,4 +29,4 @@ function PerformanceElementTypeFilter({
)
}

export default PerformanceElementTypeFilter
export default ElementTypeFilter
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function StackedBarChartLabel({
value,
x,
width,
y,
height,
}: {
value: number
x: number
y: number
width: number
height: number
}) {
return (
<text
x={x + width / 2}
y={y + height / 2 + 1}
fill="white"
fontSize={14}
textAnchor="middle"
dominantBaseline="middle"
className="font-bold"
>
{value} %
</text>
)
}

export default StackedBarChartLabel
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { Button, H2, UserNotification } from '@uzh-bf/design-system'
import { useTranslations } from 'next-intl'
import { useState } from 'react'
import { Legend } from 'recharts'
import ActivitiesElementsSwitch from './ActivitiesElementsSwitch'
import PerformanceActivityTypeFilter from './PerformanceActivityTypeFilter'
import ActivitiesElementsSwitch from '../ActivitiesElementsSwitch'
import ActivityTypeFilter from '../ActivityTypeFilter'
import AnalyticsSearchField from '../AnalyticsSearchField'
import ElementTypeFilter from '../ElementTypeFilter'
import PerformanceAttemptsFilter from './PerformanceAttemptsFilter'
import PerformanceElementTypeFilter from './PerformanceElementTypeFilter'
import PerformanceRatesBarChart from './PerformanceRatesBarChart'
import PerformanceSearchField from './PerformanceSearchField'

interface PerformanceRatesProps {
activityPerformances: ActivityPerformance[]
Expand Down Expand Up @@ -79,7 +79,9 @@ function PerformanceRates({
<ActivitiesElementsSwitch type={type} setType={setType} />
</div>
<Button
className={{ root: 'flex h-8 flex-row items-center gap-2' }}
className={{
root: 'py-0.25 flex h-8 flex-row items-center gap-2 px-2',
}}
disabled={
type === defaultFilters.type &&
attemptsType === defaultFilters.attemptsType &&
Expand All @@ -105,11 +107,11 @@ function PerformanceRates({
attemptsType={attemptsType}
setAttemptsType={setAttemptsType}
/>
<PerformanceActivityTypeFilter
<ActivityTypeFilter
activityType={activityType}
setActivityType={setActivityType}
/>
<PerformanceSearchField
<AnalyticsSearchField
type={type}
value={activitySearch}
onChange={(value) => setActivitySearch(value)}
Expand All @@ -121,11 +123,11 @@ function PerformanceRates({
attemptsType={attemptsType}
setAttemptsType={setAttemptsType}
/>
<PerformanceElementTypeFilter
<ElementTypeFilter
elementType={elementType}
setElementType={setElementType}
/>
<PerformanceSearchField
<AnalyticsSearchField
type={type}
value={instanceSearch}
onChange={(value) => setInstanceSearch(value)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from 'recharts'

const BarLabel = ({
value,
x,
width,
y,
height,
}: {
value: number
x: number
y: number
width: number
height: number
}) => (
<text
x={x + width / 2}
y={y + height / 2 + 1}
fill="white"
fontSize={14}
textAnchor="middle"
dominantBaseline="middle"
className="font-bold"
>
{value} %
</text>
)
import StackedBarChartLabel from '../StackedBarChartLabel'

interface PerformanceRatesBarChartProps {
title: string
Expand Down Expand Up @@ -61,7 +36,7 @@ function PerformanceRatesBarChart({
stackId="1"
fill={colors.incorrect}
label={(props) => (
<BarLabel {...props} value={roundedErrorRate} />
<StackedBarChartLabel {...props} value={roundedErrorRate} />
)}
/>
)}
Expand All @@ -71,7 +46,7 @@ function PerformanceRatesBarChart({
stackId="1"
fill={colors.partial}
label={(props) => (
<BarLabel {...props} value={roundedPartialRate} />
<StackedBarChartLabel {...props} value={roundedPartialRate} />
)}
/>
)}
Expand All @@ -81,7 +56,7 @@ function PerformanceRatesBarChart({
stackId="1"
fill={colors.correct}
label={(props) => (
<BarLabel {...props} value={roundedCorrectRate} />
<StackedBarChartLabel {...props} value={roundedCorrectRate} />
)}
/>
)}
Expand Down
Loading
Loading