work on later
This commit is contained in:
parent
4da9e49ee0
commit
da57054db1
|
|
@ -63,7 +63,6 @@ export function CreateForum(form) {
|
||||||
if (res.badInputs.length >= 1) {
|
if (res.badInputs.length >= 1) {
|
||||||
badInputs=res.badInputs;
|
badInputs=res.badInputs;
|
||||||
resolve({message: res.message, inputs: res.badInputs});
|
resolve({message: res.message, inputs: res.badInputs});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
resolve("good");
|
resolve("good");
|
||||||
}).catch(error=>{console.log(error);});
|
}).catch(error=>{console.log(error);});
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,14 @@ import { CreateAccount, LoginToAccount, CreateForum } from '../Helpers/Auth';
|
||||||
import Loader from '../Components/Loader';
|
import Loader from '../Components/Loader';
|
||||||
import { getCookie } from '../helpers/utils';
|
import { getCookie } from '../helpers/utils';
|
||||||
|
|
||||||
|
import axios from "axios";
|
||||||
|
import Config from '../config.js';
|
||||||
|
|
||||||
|
axios.defaults.withCredentials = true
|
||||||
|
|
||||||
|
var url = Config.BaseUrl.replace('http://', '');
|
||||||
|
var protocol = Config.Protocol;
|
||||||
|
|
||||||
const CreatePost = (props) => {
|
const CreatePost = (props) => {
|
||||||
|
|
||||||
const [waitingForSubmission, setWaitingForSubmission] = useState(false);
|
const [waitingForSubmission, setWaitingForSubmission] = useState(false);
|
||||||
|
|
@ -19,15 +27,16 @@ const CreatePost = (props) => {
|
||||||
{
|
{
|
||||||
form.append('creator_id', user.id);
|
form.append('creator_id', user.id);
|
||||||
setWaitingForSubmission(true);
|
setWaitingForSubmission(true);
|
||||||
await CreateForum(form).then(res=>{
|
await axios.post(`${protocol}apis.${url}/api/create/forum`, form, {headers: {'X-CSRF-TOKEN': document.querySelector(`meta[name="csrf-token"]`).content, "X-Requested-With":"XMLHttpRequest"}}).then(data=>{
|
||||||
|
const res = data.data;
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res != `good`) {
|
if (res.badInputs.length >= 1) {
|
||||||
setValidity({error: true, message:res.message, inputs: res.inputs});
|
setValidity({error: true, message:res.message, inputs: res.badInputs});
|
||||||
setTimeout(()=>{setValidity({...validity, error: false, inputs: res.inputs});}, 4000);
|
setTimeout(()=>{setValidity({...validity, error: false, inputs: res.badInputs});}, 4000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.location.href=`/forum`;
|
window.location.replace(`/forum`);
|
||||||
}).catch(error=>console.log(error));
|
}).catch(error=>{console.log(error);});
|
||||||
setWaitingForSubmission(false);
|
setWaitingForSubmission(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue