Skip to content

Commit

Permalink
refctor component
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffibm committed Nov 6, 2023
1 parent 8814a08 commit 2cde17d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/javascript/components/vm-edit-form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ const VmEditForm = ({
if (displayName === 'Image' || displayName === 'Instance') {
returnURL = '/vm_cloud/explorer/';
}

let URL = `/api/vms/${recordId}`;
if (isTemplate) {
URL = `/api/templates/${recordId}`;
}

const [{
initialValues, parentOptions, isLoading,
}, setState] = useState({
Expand All @@ -43,7 +49,6 @@ const VmEditForm = ({
/** Function to update just the description of the record on form submit. */
const updateDescription = (values) => {
const data = descriptionData(values);
const URL = `/api/vms/${recordId}`;
return API.post(URL, data)
.then(() => {
miqSparkleOn();
Expand All @@ -56,10 +61,6 @@ const VmEditForm = ({
/** Function to update the entire record on form submit. */
const updateRecord = (values) => {
const data = getSubmitData(values);
let URL = `/api/vms/${recordId}`;
if (isTemplate) {
URL = `/api/templates/${recordId}`;
}
return API.post(URL, data)
.then(() => {
miqSparkleOn();
Expand Down

0 comments on commit 2cde17d

Please sign in to comment.