Commit fbc0ac74 authored by Max Alekseenko's avatar Max Alekseenko

fix rating records duplication

parent 2d26d672
......@@ -28,7 +28,7 @@ export type MarketplaceAppOverview = MarketplaceAppPreview & MarketplaceAppSocia
export type AppRating = {
recordId: string;
value: number;
value: number | undefined;
}
export type MarketplaceAppWithSecurityReport = MarketplaceAppOverview & {
......
......@@ -57,7 +57,7 @@ const Rating = ({
<Popover isOpen={ isOpen } placement="bottom" isLazy>
<PopoverTrigger>
<TriggerButton
rating={ rating }
rating={ rating?.value }
fullView={ fullView }
isActive={ isOpen }
onClick={ onToggle }
......
import { Button, chakra, useColorModeValue, Tooltip, useDisclosure } from '@chakra-ui/react';
import React from 'react';
import type { AppRating } from 'types/client/marketplace';
import useIsMobile from 'lib/hooks/useIsMobile';
import usePreventFocusAfterModalClosing from 'lib/hooks/usePreventFocusAfterModalClosing';
import IconSvg from 'ui/shared/IconSvg';
type Props = {
rating?: AppRating;
rating?: number;
fullView?: boolean;
isActive: boolean;
onClick: () => void;
......@@ -78,7 +76,7 @@ const TriggerButton = (
) }
{ (rating && !fullView) ? (
<chakra.span color={ textColor } transition="inherit">
{ rating.value }
{ rating }
</chakra.span>
) : (
'Rate it!'
......
......@@ -26,11 +26,9 @@ export type RateFunction = (
function formatRatings(data: Airtable.Records<Airtable.FieldSet>) {
return data.reduce((acc: Record<string, AppRating>, record) => {
const fields = record.fields as { appId: string; rating: number };
if (!fields.appId || typeof fields.rating !== 'number') {
return acc;
}
acc[fields.appId] = {
const fields = record.fields as { appId: string | Array<string>; rating: number | undefined };
const appId = Array.isArray(fields.appId) ? fields.appId[0] : fields.appId;
acc[appId] = {
recordId: record.id,
value: fields.rating,
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment