Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into renovate/react-monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdcruz authored Nov 18, 2024
2 parents f992543 + 392a2d6 commit 778149f
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/app/eval/_components/Forms/BeneficiariesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const BeneficiariesForm = ({

const form = useForm<BeneficiariesFeedbackProps>({
mode: 'uncontrolled',
validateInputOnChange: true,
validateInputOnBlur: true,

initialValues: {
idempotencyKey: uuid,
Expand Down
2 changes: 1 addition & 1 deletion src/app/eval/_components/Forms/ImplementersForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ImplementersForm = ({

const form = useForm<ImplementerFeedbackProps>({
mode: 'uncontrolled',
validateInputOnChange: true,
validateInputOnBlur: true,

initialValues: {
idempotencyKey: uuid,
Expand Down
2 changes: 1 addition & 1 deletion src/app/eval/_components/Forms/PartnersForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const PartnersForm = ({

const form = useForm<PartnersFeedbackProps>({
mode: 'uncontrolled',
validateInputOnChange: true,
validateInputOnBlur: true,

initialValues: {
idempotencyKey: uuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function ActivityAnalyticsShell({
<Box>
<StatRatings id={id!} />

<Grid align="flex-start" columns={3} justify="space-between">
<Grid.Col span="auto">
<Grid align="flex-start" justify="space-between">
<Grid.Col span={{ base: 'auto', md: 12, lg: 8 }}>
{/* Respondents Table */}
<Paper
bg="light-dark(
Expand All @@ -67,7 +67,7 @@ function ActivityAnalyticsShell({
</Paper>
</Grid.Col>

<Grid.Col span={{ base: 'auto', sm: 1 }}>
<Grid.Col span={{ base: 'auto', md: 12, lg: 4 }}>
<Paper
bg="light-dark(
var(--mantine-color-gray-0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function EmotionsRadarComponent({ id }: { id: string }) {
.from('activity_feedback')
.select('type, score_emotions->emotions')
.eq('activity_id', id)
.not('score_emotions', 'is', null)
.limit(1000)
.returns<EmotionsResponse[]>();

Expand Down Expand Up @@ -52,7 +53,6 @@ function EmotionsRadarComponent({ id }: { id: string }) {
data={data}
dataKey="label"
h={360}
miw={300}
series={[
{
label: 'Partners',
Expand All @@ -73,6 +73,7 @@ function EmotionsRadarComponent({ id }: { id: string }) {
opacity: 0.2,
},
]}
w="100%"
withLegend
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import {
Table,
Text,
TextInput,
Tooltip,
} from '@mantine/core';
import { useDebouncedValue, useDisclosure } from '@mantine/hooks';
import {
IconDownload,
IconFileSpreadsheet,
IconHelpCircle,
IconSearch,
} from '@tabler/icons-react';
import { createBrowserClient } from '@/libs/supabase/client';
Expand Down Expand Up @@ -51,8 +53,8 @@ interface EvaluationProps
| BeneficiariesFeedbackProps
| PartnersFeedbackProps
| ImplementerFeedbackProps;
score_emotions: EmotionsResponse;
score_sentiment: SentimentResponse;
score_emotions: EmotionsResponse | null;
score_sentiment: SentimentResponse | null;
}

const BeneficiariesForm = dynamic(
Expand Down Expand Up @@ -174,17 +176,26 @@ export const EvaluationsTable = memo(
score_sentiment: sentiments,
} = row;

const sentimentValues = {
negative: sentiments?.negative ?? 0,
neutral: sentiments?.neutral ?? 0,
positive: sentiments?.positive ?? 0,
};

const totalSentiment =
sentiments?.negative + sentiments?.neutral + sentiments?.positive;
sentimentValues.negative +
sentimentValues.neutral +
sentimentValues.positive;

const sentimentData = {
negative: (sentiments?.negative / totalSentiment) * 100,
neutral: (sentiments?.neutral / totalSentiment) * 100,
positive: (sentiments?.positive / totalSentiment) * 100,
negative: (sentimentValues.negative / totalSentiment) * 100,
neutral: (sentimentValues.neutral / totalSentiment) * 100,
positive: (sentimentValues.positive / totalSentiment) * 100,
};

const emotionTags: string[] = emotions.emotions.map(
const emotionTags: string[] = emotions?.emotions.map(
(emotion) => emotion.label,
);
) ?? ['N/A'];

return (
<Table.Tr key={row.id}>
Expand Down Expand Up @@ -237,46 +248,59 @@ export const EvaluationsTable = memo(

{/* Sentiment Bar */}
<Table.Td>
<Group justify="space-between">
<Text c="red" fw={700} fz="xs">
<NumberFormatter
decimalScale={1}
suffix="%"
value={sentimentData.negative}
/>
</Text>
<Text c="gray" fw={700} fz="xs">
<NumberFormatter
decimalScale={1}
suffix="%"
value={sentimentData.neutral}
/>
</Text>
<Text c="teal" fw={700} fz="xs">
<NumberFormatter
decimalScale={1}
suffix="%"
value={sentimentData.positive}
/>
</Text>
</Group>
<Progress.Root>
<Progress.Section
className={classes.progressSection}
color="red"
value={sentimentData.negative}
/>
<Progress.Section
className={classes.progressSection}
color="gray"
value={sentimentData.neutral}
/>
<Progress.Section
className={classes.progressSection}
color="teal"
value={sentimentData.positive}
/>
</Progress.Root>
{totalSentiment === 0 ? (
<Tooltip
label="Check trigger.dev instance for more details."
withArrow
>
<Text c="gray" fw={700} fz="xs" ta="center">
No sentiment data <IconHelpCircle size={16} />
</Text>
</Tooltip>
) : (
<>
<Group justify="space-between">
<Text c="red" fw={700} fz="xs">
<NumberFormatter
decimalScale={1}
suffix="%"
value={sentimentData.negative}
/>
</Text>
<Text c="gray" fw={700} fz="xs">
<NumberFormatter
decimalScale={1}
suffix="%"
value={sentimentData.neutral}
/>
</Text>
<Text c="teal" fw={700} fz="xs">
<NumberFormatter
decimalScale={1}
suffix="%"
value={sentimentData.positive}
/>
</Text>
</Group>
<Progress.Root>
<Progress.Section
className={classes.progressSection}
color="red"
value={sentimentData.negative}
/>
<Progress.Section
className={classes.progressSection}
color="gray"
value={sentimentData.neutral}
/>
<Progress.Section
className={classes.progressSection}
color="teal"
value={sentimentData.positive}
/>
</Progress.Root>
</>
)}
</Table.Td>
</Table.Tr>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function StatsSegmentsComponent({ id }: { id: string }) {
.from('activity_feedback')
.select('score_sentiment')
.eq('activity_id', id)
.not('score_sentiment', 'is', null)
.limit(1000);

if (results)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const StatsRingComponent = ({ id }: { id: string }) => {
.from('activity_feedback_view')
.select('type, score_ratings, max_ratings')
.eq('activity_id', id)
.not('score_ratings', 'is', null)
.limit(1000)
.returns<RatingResult[]>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,12 @@ function ActivityDetailsHeader({
className="object-contain shadow-sm"
component={NextImage}
fallbackSrc="/assets/no-image.png"
height={260}
mb={16}
h="auto"
height={200}
radius="md"
src={activity.image_url}
width={360}
w="auto"
width={280}
/>
</Group>
</>
Expand Down
6 changes: 3 additions & 3 deletions src/trigger/analyze-feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function analyzeFeedback(
export const analyzePartner = task({
id: 'analyze-partner',
machine: {
preset: 'small-2x',
preset: 'medium-1x',
},
run: async (payload: {
id: string;
Expand Down Expand Up @@ -86,7 +86,7 @@ export const analyzePartner = task({
export const analyzeImplementer = task({
id: 'analyze-implementer',
machine: {
preset: 'small-2x',
preset: 'medium-1x',
},
run: async (payload: {
id: string;
Expand Down Expand Up @@ -134,7 +134,7 @@ export const analyzeImplementer = task({
export const analyzeBeneficiary = task({
id: 'analyze-beneficiary',
machine: {
preset: 'small-2x',
preset: 'medium-1x',
},
run: async (payload: {
id: string;
Expand Down

0 comments on commit 778149f

Please sign in to comment.