Skip to content

Commit

Permalink
Merge pull request #242 from cardanoapi/hotfix/frontend-issues
Browse files Browse the repository at this point in the history
Hotfix/frontend issues
  • Loading branch information
JosephRana11 authored Oct 22, 2024
2 parents e5b959e + 2d11a1b commit 612dc4b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 25 deletions.
8 changes: 0 additions & 8 deletions api/backend/app/services/trigger_history_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,6 @@ def process_chart_data(self, raw_data: List[Dict[str, Any]], max_range: int) ->
else:
result[index]["values"][function_name] = item["successful_triggers"]

if 0 <= index < max_range:
result[index]["count"] += item["successful_triggers"]
function_name = item.get("functionName", "Unknown")
if function_name in result[index]["values"]:
result[index]["values"][function_name] += item["successful_triggers"]
else:
result[index]["values"][function_name] = item["successful_triggers"]

return result

def build_query(
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/app/(pages)/dRep-directory/components/DRepCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ const DRepCard: React.FC<DRepCardProps> = ({ dRep }) => {
<div className="flex space-x-4 sm:space-x-6 xl:space-x-12 2xl:space-x-10 4xl:space-x-20">
<div className="flex flex-col space-y-2">
<div className="flex gap-2">
<TypographyH2 className={`font-semibold ${isDataMissing}`}>
{isDataMissing ? 'Data Missing' : dRep.givenName}
</TypographyH2>
{dRep.givenName && (
<TypographyH2 className={`font-semibold`}>
{dRep.givenName}
</TypographyH2>
)}
<Badge variant={getBadgeVariant(dRep.status)}>
{dRep.status}
</Badge>
Expand Down Expand Up @@ -136,7 +138,7 @@ const DRepCard: React.FC<DRepCardProps> = ({ dRep }) => {
</AppDialog>

<AppDialog isOpen={isDrepDetailsOpen} toggleDialog={toggleDrepDetailDialog}>
<DrepDetailDialogContent dRep={dRep} />
<DrepDetailDialogContent dRep={dRep} onClose={toggleDrepDetailDialog} />
</AppDialog>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { CopyIcon, ExternalLink } from 'lucide-react';
import { AppDialogContent } from '@app/app/components/AppDialog';
import { SuccessToast } from '@app/components/molecules/CustomToasts';

export default function DrepDetailDialogContent({ dRep }: { dRep: IDRepInternal }) {
export default function DrepDetailDialogContent({
dRep,
onClose
}: {
dRep: IDRepInternal;
onClose?: (value: boolean) => void;
}) {
const formattedVotingPower = convertLovelaceToAda(dRep.votingPower).toLocaleString(
'en-US'
);
Expand All @@ -18,7 +24,7 @@ export default function DrepDetailDialogContent({ dRep }: { dRep: IDRepInternal
};

return (
<AppDialogContent className=" pt-0">
<AppDialogContent className=" pt-0" onClose={onClose}>
<div className="mb-4 flex items-center gap-2">
<span className="text-lg font-semibold">
{dRep.givenName || 'Data Missing'}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/AgentActionDialogContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const AgentsActionDialogContent = ({
const userOwnedAgents = filterUserOwnedAgents(activeAgents);

return (
<AppDialogContent title={title} description={description}>
<AppDialogContent title={title} description={description} onClose={handleClose}>
<div className="space-y-2' flex w-full flex-col">
{userOwnedAgents.length === 0 ? (
<EmptyAgent />
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/app/components/AppDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

import { X } from 'lucide-react';

import {
Dialog,
DialogContent,
Expand All @@ -17,13 +19,18 @@ interface AppDialogContentProps extends React.PropsWithChildren {
title?: string;
description?: string;
className?: string;
onClose?: (open: boolean) => void;
}

export const AppDialogContent: React.FC<AppDialogContentProps> = (props) => {
const { title, description, children, className } = props;
const { title, description, children, className, onClose } = props;

return (
<DialogContent className={className}>
<DialogContent className={className} defaultCross={false}>
<X
className="absolute right-2 top-2 cursor-pointer"
onClick={() => onClose?.(false)}
/>
<DialogHeader className="mb-2">
{title && <DialogTitle>{title}</DialogTitle>}
{description && <DialogDescription>{description}</DialogDescription>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { updateTrigger } from '@api/trigger';
import { TemplateFunctions } from '@models/types/functions';
import { Dialog, DialogContent } from '@mui/material';
import { useMutation } from '@tanstack/react-query';
import { Edit, Trash2 } from 'lucide-react';
import { Edit, OctagonAlert, Trash2 } from 'lucide-react';

import { FunctionForm } from '@app/app/(pages)/templates/create-template/components/FunctionForm';
import {
Expand All @@ -22,6 +22,7 @@ import { queryClient } from '@app/utils/providers/ReactQueryProvider';
import { SuccessToast } from '../../molecules/CustomToasts';
import { ErrorToast } from '../../molecules/CustomToasts';
import CustomCopyBox from '../shared/CustomCopyBox';
import ErrorPlaceholder from '../shared/ErrorPlaceholder';

const AgentFunctionsDetailComponent = ({
agent,
Expand Down Expand Up @@ -96,9 +97,12 @@ const AgentFunctionsDetailComponent = ({
<div className="flex items-center gap-4"></div>
<div className="flex flex-row flex-wrap gap-6">
{!agentConfigurations?.length ? (
<span className="text-xs text-brand-Black-300">
Click edit button to add functions
</span>
<ErrorPlaceholder
title="No Functions"
content="Agent seems to have no functions configured."
icon={OctagonAlert}
className="absolute h-full w-full border-0"
/>
) : (
agentConfigurations.map((config) => (
<div
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Agent/AgentContent/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TextDisplayField from '@app/components/molecules/TextDisplayField';
import { useModal } from '../../Modals/context';
import { Button } from '../../atoms/Button';
import CustomCopyBox from '../shared/CustomCopyBox';
import AgentHistoryComponent from '../shared/TriggerChart';
import AgentHistoryChart from '../shared/TriggerChart';
import HeaderContent from './ContentHeader';

interface AgentOverViewProps {
Expand Down Expand Up @@ -154,7 +154,7 @@ const AgentOverViewComponent: React.FC<AgentOverViewProps> = ({
</div>
</div>
<div className="mt-8">
<AgentHistoryComponent chartClassName="w-full h-[550px]" />
<AgentHistoryChart chartClassName="w-full h-[550px]" agent={agent} />
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Agent/shared/TriggerChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { convertDictToGraphDataFormat } from '../../Chart/ChartFilter';
import AgentFunctionsDropDown from '../../Common/AgentFunctionsDropDown';
import { cn } from '../../lib/utils';

const AgentHistoryComponent = ({
const AgentHistoryChart = ({
agent,
chartClassName
}: {
Expand Down Expand Up @@ -141,4 +141,4 @@ const AgentHistoryComponent = ({
);
};

export default AgentHistoryComponent;
export default AgentHistoryChart;

0 comments on commit 612dc4b

Please sign in to comment.