Blueprints: Add blueprint editing
This commit is contained in:
parent
2464dab29e
commit
45d50b2440
19 changed files with 519 additions and 79 deletions
42
src/Components/CreateImageWizardV2/EditImageWizard.tsx
Normal file
42
src/Components/CreateImageWizardV2/EditImageWizard.tsx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import React, { useEffect } from 'react';
|
||||
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import CreateImageWizard from './CreateImageWizard';
|
||||
import { mapRequestToState } from './utilities/requestMapper';
|
||||
|
||||
import { useAppDispatch } from '../../store/hooks';
|
||||
import { useGetBlueprintQuery } from '../../store/imageBuilderApi';
|
||||
import { loadWizardState, initializeWizard } from '../../store/wizardSlice';
|
||||
import { resolveRelPath } from '../../Utilities/path';
|
||||
|
||||
type EditImageWizardProps = {
|
||||
blueprintId: string;
|
||||
};
|
||||
|
||||
const EditImageWizard = ({ blueprintId }: EditImageWizardProps) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { data: blueprintDetails, error } = useGetBlueprintQuery({
|
||||
id: blueprintId,
|
||||
});
|
||||
useEffect(() => {
|
||||
if (blueprintId && blueprintDetails) {
|
||||
const editBlueprintState = mapRequestToState(blueprintDetails);
|
||||
dispatch(loadWizardState(editBlueprintState));
|
||||
} else {
|
||||
dispatch(initializeWizard());
|
||||
}
|
||||
}, [blueprintId, blueprintDetails, dispatch]);
|
||||
useEffect(() => {
|
||||
// redirect to the main page if the composeId is invalid
|
||||
|
||||
if (error) {
|
||||
navigate(resolveRelPath(''));
|
||||
}
|
||||
}, [error, navigate]);
|
||||
return <CreateImageWizard startStepIndex={12} />;
|
||||
};
|
||||
|
||||
export default EditImageWizard;
|
||||
Loading…
Add table
Add a link
Reference in a new issue