Skip to content

Commit

Permalink
chore: refetch training history table after submitting new request
Browse files Browse the repository at this point in the history
  • Loading branch information
jeafreezy committed Nov 19, 2024
1 parent 71504b5 commit 447b86e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/features/model-creation/hooks/use-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const useCreateModel = ({ mutationConfig }: useCreateModelOptions) => {
});
};

type useCreateModelTrainingOptions = {
export type useCreateModelTrainingOptions = {
mutationConfig?: MutationConfig<typeof createTrainingRequest>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
useModelsContext,
} from "@/app/providers/models-provider";
import { useEffect } from "react";
import { PAGE_LIMIT } from "@/components/pagination";
import { useTrainingHistory } from "../../hooks/use-training";

type ModelEnhancementDialogProps = {
isOpened: boolean;
Expand All @@ -35,7 +37,6 @@ const ModelTrainingSettingsDialog: React.FC<ModelEnhancementDialogProps> = ({
Update the base model in the state since it's required for enabling/disabling some advanced settings.
*/
}

useEffect(() => {
if (!data) return;
handleChange(
Expand All @@ -45,6 +46,11 @@ const ModelTrainingSettingsDialog: React.FC<ModelEnhancementDialogProps> = ({
}, [data?.base_model]);

const disableButton = formData.zoomLevels.length === 0;
const { refetch: refetchTrainingHistory } = useTrainingHistory(
modelId as string,
0,
PAGE_LIMIT,
);

const handleClick = () => {
createNewTrainingRequestMutation.mutate(
Expand All @@ -58,6 +64,7 @@ const ModelTrainingSettingsDialog: React.FC<ModelEnhancementDialogProps> = ({
},
{
onSuccess: () => {
refetchTrainingHistory();
closeDialog();
},
onError: () => {
Expand Down

0 comments on commit 447b86e

Please sign in to comment.