Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalabbad committed Feb 5, 2025
1 parent e086d34 commit 9c32377
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
9 changes: 0 additions & 9 deletions frontend/app/src/entities/diff/api/diff-update.ts

This file was deleted.

19 changes: 14 additions & 5 deletions frontend/app/src/entities/diff/ui/diff-refresh-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {
useUpdateDiffMutation,
} from "@/entities/diff/domain/update-diff.mutation";
import { Button, ButtonProps } from "@/shared/components/buttons/button-primitive";
import { ALERT_TYPES, Alert } from "@/shared/components/ui/alert";
import { classNames } from "@/shared/utils/common";
import { Icon } from "@iconify-icon/react";
import { useMutationState } from "@tanstack/react-query";
import { toast } from "react-toastify";

export interface DiffRefreshButtonProps extends Omit<ButtonProps, "onClick"> {
branchName: string;
Expand All @@ -20,12 +22,19 @@ export function DiffRefreshButton({ branchName, ...props }: DiffRefreshButtonPro

const isLoading = allUpdatingDiffs.includes(branchName);

const handleRefreshDiff = async () => {
try {
await updateDiffMutation.mutateAsync(branchName);
toast(<Alert type={ALERT_TYPES.SUCCESS} message="Diff updated!" />);
} catch (error: unknown) {
if (error instanceof Error) {
toast(<Alert type={ALERT_TYPES.ERROR} message={error.message} />);
}
}
};

return (
<Button
variant="primary-outline"
onClick={() => updateDiffMutation.mutate(branchName)}
{...props}
>
<Button variant="primary-outline" onClick={handleRefreshDiff} {...props}>
<Icon icon="mdi:reload" className={classNames("mr-1", isLoading && "animate-spin")} />
{isLoading ? "Refreshing diff..." : "Refresh diff"}
</Button>
Expand Down

0 comments on commit 9c32377

Please sign in to comment.