1- import { useQuery } from "@apollo/client" ;
21import type React from "react" ;
32import { Link } from "react-router" ;
4- import { toast } from "react-toastify" ;
53
64import { QSP } from "@/config/qsp" ;
75
86import { constructPath } from "@/shared/api/rest/fetch" ;
7+ import { Row } from "@/shared/components/container" ;
98import ErrorScreen from "@/shared/components/errors/error-screen" ;
10- import { ALERT_TYPES , Alert } from "@/shared/components/ui/alert" ;
119
10+ import { useGetDiffSummary } from "@/entities/diff/domain/get-diff-summary.query" ;
11+ import { DIFF_STATUS , type DiffStatus } from "@/entities/diff/node-diff/types" ;
1212import { DiffBadge } from "@/entities/diff/node-diff/utils" ;
13- import { getProposedChangesDiffSummary } from "@/entities/proposed-changes/api/getProposedChangesDiffSummary" ;
14-
15- import { DIFF_STATUS , type DiffStatus } from "../../diff/node-diff/types" ;
16-
17- interface DiffTreeSummary {
18- num_added : number ;
19- num_removed : number ;
20- num_updated : number ;
21- num_conflicts : number ;
22- }
2313
2414interface ProposedChangeDiffSummaryProps {
2515 branchName : string ;
@@ -50,24 +40,9 @@ export const ProposedChangeDiffSummary: React.FC<ProposedChangeDiffSummaryProps>
5040 proposedChangeId,
5141 branchName,
5242} ) => {
53- const { error, data, loading } = useQuery < { DiffTreeSummary : DiffTreeSummary } > (
54- getProposedChangesDiffSummary ,
55- {
56- skip : ! branchName ,
57- variables : { branch : branchName } ,
58- context : {
59- processErrorMessage : ( message : string ) => {
60- if ( ! message . includes ( "not found" ) ) {
61- toast ( < Alert type = { ALERT_TYPES . ERROR } message = { message } /> , {
62- toastId : "alert-error" ,
63- } ) ;
64- }
65- } ,
66- } ,
67- }
68- ) ;
43+ const { error, data, isPending } = useGetDiffSummary ( { branchName } ) ;
6944
70- if ( loading ) {
45+ if ( isPending ) {
7146 return < DiffSummarySkeleton /> ;
7247 }
7348
@@ -81,40 +56,42 @@ export const ProposedChangeDiffSummary: React.FC<ProposedChangeDiffSummaryProps>
8156 ) ;
8257 }
8358
84- const { DiffTreeSummary } = data || { } ;
59+ if ( ! data ) {
60+ return null ;
61+ }
8562
8663 return (
87- < div className = "inline-flex gap-2" >
64+ < Row >
8865 < BadgeLink
8966 status = { DIFF_STATUS . ADDED }
90- count = { DiffTreeSummary ? .num_added }
67+ count = { data . num_added }
9168 proposedChangeId = { proposedChangeId }
9269 />
9370 < BadgeLink
9471 status = { DIFF_STATUS . REMOVED }
95- count = { DiffTreeSummary ? .num_removed }
72+ count = { data . num_removed }
9673 proposedChangeId = { proposedChangeId }
9774 />
9875 < BadgeLink
9976 status = { DIFF_STATUS . UPDATED }
100- count = { DiffTreeSummary ? .num_updated }
77+ count = { data . num_updated }
10178 proposedChangeId = { proposedChangeId }
10279 />
10380 < BadgeLink
10481 status = { DIFF_STATUS . CONFLICT }
105- count = { DiffTreeSummary ? .num_conflicts }
82+ count = { data . num_conflicts }
10683 proposedChangeId = { proposedChangeId }
10784 />
108- </ div >
85+ </ Row >
10986 ) ;
11087} ;
11188
11289const DiffSummarySkeleton : React . FC = ( ) => {
11390 return (
114- < div className = "flex gap-2" >
91+ < Row >
11592 { [ ...Array ( 4 ) ] . map ( ( _ , index ) => (
11693 < div key = { index } className = "h-6 w-9 animate-pulse rounded-full bg-gray-200" />
11794 ) ) }
118- </ div >
95+ </ Row >
11996 ) ;
12097} ;
0 commit comments