-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moved code from PHP files into controller (#2791)
- Loading branch information
Showing
21 changed files
with
508 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { create, update } from '../api'; | ||
import { serialize } from '../../../../assets/src/utils'; | ||
import { pushErrorNotification, pushNotification } from '../utils'; | ||
|
||
export const handleSaveFaqData = () => { | ||
const submitButton = document.getElementById('faqEditorSubmit'); | ||
|
||
if (submitButton) { | ||
submitButton.addEventListener('click', async (event) => { | ||
event.preventDefault(); | ||
const form = document.getElementById('faqEditor'); | ||
const formData = new FormData(form); | ||
|
||
const serializedData = serialize(formData); | ||
|
||
let response; | ||
if (serializedData.faqId === '0') { | ||
response = await create(serializedData); | ||
} else { | ||
response = await update(serializedData); | ||
} | ||
|
||
if (response.success) { | ||
const data = JSON.parse(response.data); | ||
const faqId = document.getElementById('faqId'); | ||
const revisionId = document.getElementById('revisionId'); | ||
|
||
faqId.value = data.id; | ||
revisionId.value = data.revisionId; | ||
|
||
pushNotification(response.success); | ||
} else { | ||
pushErrorNotification(response.error); | ||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.