36 lines
999 B
TypeScript
36 lines
999 B
TypeScript
import { useMutation } from "@tanstack/react-query";
|
|
import { LinkApi } from "@/entities/link";
|
|
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
|
import { Button } from "@common/components";
|
|
|
|
const QuickStartButton: React.FC<{ linkSn: string }> = ({ linkSn }) => {
|
|
const { setMessage: alert } = useAlertStore((state) => state);
|
|
|
|
const { mutateAsync: updateQuickStart } = useMutation({
|
|
mutationFn: (linkSn: string) => LinkApi.linkQuickStart(linkSn),
|
|
onSuccess: (result) => {
|
|
if (result === 'succ') {
|
|
alert('즉시 실행 요청이 완료되었습니다.');
|
|
} else {
|
|
alert('기존 요청이 실행 대기중입니다.');
|
|
}
|
|
},
|
|
onError: () => {
|
|
alert('즉시 실행 요청을 실패했습니다.');
|
|
},
|
|
});
|
|
|
|
return (
|
|
<Button
|
|
color="sky"
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
updateQuickStart(linkSn);
|
|
}}
|
|
>
|
|
즉시 실행
|
|
</Button>
|
|
);
|
|
};
|
|
|
|
export default QuickStartButton; |