11import { type LoaderFunctionArgs , type ActionFunctionArgs , json } from "@remix-run/server-runtime" ;
2- import { type MetaFunction , Form , useFetcher } from "@remix-run/react" ;
2+ import { type MetaFunction , Form , useFetcher , useNavigation , useSubmit } from "@remix-run/react" ;
33import { BellAlertIcon } from "@heroicons/react/20/solid" ;
44import { parse } from "@conform-to/zod" ;
55import { z } from "zod" ;
@@ -657,75 +657,86 @@ function ErrorGroupActionButtons({
657657 taskIdentifier : string ;
658658 fingerprint : string ;
659659} ) {
660- const fetcher = useFetcher ( ) ;
660+ const navigation = useNavigation ( ) ;
661+ const submit = useSubmit ( ) ;
661662 const [ customIgnoreOpen , setCustomIgnoreOpen ] = useState ( false ) ;
662- const isSubmitting = fetcher . state !== "idle" ;
663-
664- const submitAction = ( data : Record < string , string > ) => {
665- fetcher . submit ( { ...data , taskIdentifier } , { method : "post" } ) ;
666- } ;
663+ const isSubmitting = navigation . state !== "idle" ;
667664
668665 return (
669- < div className = "flex items-center gap-2" >
670- < StatusBadge status = { state . status } />
666+ < >
667+ < Form className = "flex items-center gap-2" >
668+ < StatusBadge status = { state . status } />
669+
670+ { state . status === "UNRESOLVED" && (
671+ < >
672+ < Button
673+ variant = "secondary/small"
674+ disabled = { isSubmitting }
675+ onClick = { ( ) => submit ( { taskIdentifier, action : "resolve" } , { method : "post" } ) }
676+ type = "button"
677+ >
678+ Resolve
679+ </ Button >
680+ < Popover >
681+ < PopoverArrowTrigger > Ignore</ PopoverArrowTrigger >
682+ < PopoverContent className = "min-w-[180px] p-1" align = "end" >
683+ < PopoverMenuItem
684+ title = "Ignore for 1 hour"
685+ onClick = { ( ) =>
686+ submit (
687+ { taskIdentifier, action : "ignore" , duration : String ( 60 * 60 * 1000 ) } ,
688+ { method : "post" }
689+ )
690+ }
691+ />
692+ < PopoverMenuItem
693+ title = "Ignore for 24 hours"
694+ onClick = { ( ) =>
695+ submit (
696+ {
697+ taskIdentifier,
698+ action : "ignore" ,
699+ duration : String ( 24 * 60 * 60 * 1000 ) ,
700+ } ,
701+ { method : "post" }
702+ )
703+ }
704+ />
705+ < PopoverMenuItem
706+ title = "Ignore forever"
707+ onClick = { ( ) => submit ( { taskIdentifier, action : "ignore" } , { method : "post" } ) }
708+ />
709+ < PopoverMenuItem
710+ title = "Custom condition..."
711+ onClick = { ( ) => setCustomIgnoreOpen ( true ) }
712+ />
713+ </ PopoverContent >
714+ </ Popover >
715+ </ >
716+ ) }
671717
672- { state . status === "UNRESOLVED" && (
673- < >
718+ { state . status === "RESOLVED" && (
674719 < Button
675720 variant = "secondary/small"
676721 disabled = { isSubmitting }
677- onClick = { ( ) => submitAction ( { action : "resolve" } ) }
722+ onClick = { ( ) => submit ( { taskIdentifier, action : "unresolve" } , { method : "post" } ) }
723+ type = "button"
678724 >
679- Resolve
725+ Unresolve
680726 </ Button >
681- < Popover >
682- < PopoverArrowTrigger > Ignore</ PopoverArrowTrigger >
683- < PopoverContent className = "min-w-[180px] p-1" align = "end" >
684- < PopoverMenuItem
685- title = "Ignore for 1 hour"
686- onClick = { ( ) => submitAction ( { action : "ignore" , duration : String ( 60 * 60 * 1000 ) } ) }
687- />
688- < PopoverMenuItem
689- title = "Ignore for 24 hours"
690- onClick = { ( ) =>
691- submitAction ( {
692- action : "ignore" ,
693- duration : String ( 24 * 60 * 60 * 1000 ) ,
694- } )
695- }
696- />
697- < PopoverMenuItem
698- title = "Ignore forever"
699- onClick = { ( ) => submitAction ( { action : "ignore" } ) }
700- />
701- < PopoverMenuItem
702- title = "Custom condition..."
703- onClick = { ( ) => setCustomIgnoreOpen ( true ) }
704- />
705- </ PopoverContent >
706- </ Popover >
707- </ >
708- ) }
709-
710- { state . status === "RESOLVED" && (
711- < Button
712- variant = "secondary/small"
713- disabled = { isSubmitting }
714- onClick = { ( ) => submitAction ( { action : "unresolve" } ) }
715- >
716- Unresolve
717- </ Button >
718- ) }
727+ ) }
719728
720- { state . status === "IGNORED" && (
721- < Button
722- variant = "secondary/small"
723- disabled = { isSubmitting }
724- onClick = { ( ) => submitAction ( { action : "unresolve" } ) }
725- >
726- Unignore
727- </ Button >
728- ) }
729+ { state . status === "IGNORED" && (
730+ < Button
731+ variant = "secondary/small"
732+ disabled = { isSubmitting }
733+ onClick = { ( ) => submit ( { taskIdentifier, action : "unresolve" } , { method : "post" } ) }
734+ type = "button"
735+ >
736+ Unignore
737+ </ Button >
738+ ) }
739+ </ Form >
729740
730741 < Dialog open = { customIgnoreOpen } onOpenChange = { setCustomIgnoreOpen } >
731742 < DialogContent >
@@ -738,7 +749,7 @@ function ErrorGroupActionButtons({
738749 />
739750 </ DialogContent >
740751 </ Dialog >
741- </ div >
752+ </ >
742753 ) ;
743754}
744755
0 commit comments