Compare commits

..

No commits in common. "07289a5dc92b35980aa0e624bfeeb2beb3a6a29a" and "646e3cc9d8fbd9403b01ce50973cff9fe73e3620" have entirely different histories.

10 changed files with 121 additions and 96 deletions

View File

@ -27,20 +27,3 @@ a.white-link:active {
.nav-link { .nav-link {
cursor: pointer; cursor: pointer;
} }
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: rgb(155, 155, 155);
opacity: 1; /* Firefox */
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: rgb(155, 155, 155);;
}
::-ms-input-placeholder { /* Microsoft Edge */
color: rgb(155, 155, 155);;
}
.input-field [type=text] {
color: white;
}

View File

@ -15,6 +15,7 @@ import IDSingle from "./root/Pages/IDSingle";
// Components // Components
import Home from "./root/Home"; import Home from "./root/Home";
import Navigation from "./root/Navigation"; import Navigation from "./root/Navigation";
import Autobook from "./root/Pages/Autobook";
// Main app component, react-router comes from here, // Main app component, react-router comes from here,
// and links to all of the sub pages // and links to all of the sub pages
@ -73,6 +74,7 @@ class App extends Component {
path="/booked" path="/booked"
render={(props) => <GenericList {...props} APILINK="/booked/" />} render={(props) => <GenericList {...props} APILINK="/booked/" />}
/> />
<Route exact path="/check" component={Autobook} />
</Switch> </Switch>
</div> </div>
</Router> </Router>

View File

@ -4,15 +4,13 @@ import FormPage from "../common/Forms/FormPage";
import { callAPI } from "../../actions/API"; import { callAPI } from "../../actions/API";
import { GenericForm } from "../common/Forms/GenericForm"; import { GenericForm } from "../common/Forms/GenericForm";
import moment from "moment"; import moment from "moment";
import Msgbox from "../../actions/Msgbox";
export default class Autobook extends Component { export default class Book extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
data: null, data: null,
timeslots: [], timeslots: [],
error: "",
}; };
} }
preBookedData = { preBookedData = {
@ -39,24 +37,21 @@ export default class Autobook extends Component {
this.setState({ this.setState({
timeslots: response.data, timeslots: response.data,
}); });
// console.log(response.data);
}); });
} }
credCallback = (credData) => { credCallback = (credData) => {
if (credData[0].data.Error) { console.log(credData);
this.setState({ this.setState({
error: credData[0].data.Error, data: credData,
}); });
} else { console.log(this.state.data);
this.setState({ this.preBookedData.domain = this.state.data[0].data.main_domain;
data: credData, this.preBookedData.additional_domains = this.state.data[0].data.other_domains;
error: "", this.preBookedData.username = this.state.data[1].username;
}); this.preBookedData.original_server = this.state.data[1].hostname;
this.preBookedData.domain = this.state.data[0].data.main_domain; console.log(this.preBookedData);
this.preBookedData.additional_domains = this.state.data[0].data.other_domains;
this.preBookedData.username = this.state.data[1].username;
this.preBookedData.original_server = this.state.data[1].hostname;
}
}; };
render() { render() {
if (this.state.data) { if (this.state.data) {
@ -74,12 +69,7 @@ export default class Autobook extends Component {
</div> </div>
); );
} else { } else {
return ( return <CredChecker credCallback={this.credCallback} />;
<div>
<CredChecker credCallback={this.credCallback} />
{this.state.error ? <Msgbox error={[this.state.error]} /> : null}
</div>
);
} }
} }
} }

View File

@ -2,38 +2,30 @@ import React from "react";
import { callAPI } from "../../../actions/API"; import { callAPI } from "../../../actions/API";
export const CredChecker = (props) => { export const CredChecker = (props) => {
const sendit = () => {
let values = { const sendit = () => {
hostname: document.getElementById("Host").value, let values = {
username: document.getElementById("User").value, hostname: document.getElementById("Host").value,
password: document.getElementById("Pass").value, username: document.getElementById("User").value,
}; password: document.getElementById("Pass").value,
callAPI.post("/checkcpanel/", values).then((resp) => { }
props.credCallback([resp, values]); callAPI
}); .post('/checkcpanel/', values)
console.log(); .then( (resp) => {
}; props.credCallback([resp, values])
return ( })
<div> console.log()
<div className="row">
<div className="col s3"> }
<label htmlFor="Host">Hostname</label> return (
<input id="Host"></input> <div>
<div className="row">
<div className="col s3"><label htmlFor="Host">Hostname</label><input id="Host" ></input></div>
<div className="col s3"><label htmlFor="User">Username</label><input id="User" ></input></div>
<div className="col s3"><label htmlFor="Pass">Password</label><input id="Pass" ></input></div>
</div>
<div className="row"><button className="" onClick={sendit}>Check Deets homie</button></div>
</div> </div>
<div className="col s3"> )
<label htmlFor="User">Username</label> }
<input id="User"></input>
</div>
<div className="col s3">
<label htmlFor="Pass">Password</label>
<input id="Pass"></input>
</div>
</div>
<div className="row">
<button className="btn btn-secondary" onClick={sendit}>
Check Deets homie
</button>
</div>
</div>
);
};

View File

@ -12,7 +12,6 @@ import classnames from "classnames";
import EmailBooking from "./EmailBooking"; import EmailBooking from "./EmailBooking";
import { GenericForm } from "./GenericForm"; import { GenericForm } from "./GenericForm";
import AutoBook from "../../Pages/Autobook";
const FormPage = ({ timeslots, item }) => { const FormPage = ({ timeslots, item }) => {
const [activeTab, setActiveTab] = useState("1"); const [activeTab, setActiveTab] = useState("1");
@ -34,7 +33,7 @@ const FormPage = ({ timeslots, item }) => {
toggle("1"); toggle("1");
}} }}
> >
Auto cPanel Booking Web hosting Migration
</NavLink> </NavLink>
</NavItem> </NavItem>
<NavItem> <NavItem>
@ -43,16 +42,6 @@ const FormPage = ({ timeslots, item }) => {
onClick={() => { onClick={() => {
toggle("2"); toggle("2");
}} }}
>
Web hosting Migration
</NavLink>
</NavItem>
<NavItem>
<NavLink
className={classnames({ active: activeTab === "3" })}
onClick={() => {
toggle("3");
}}
> >
Email Migration Email Migration
</NavLink> </NavLink>
@ -60,14 +49,6 @@ const FormPage = ({ timeslots, item }) => {
</Nav> </Nav>
<TabContent activeTab={activeTab}> <TabContent activeTab={activeTab}>
<TabPane tabId="1"> <TabPane tabId="1">
<Row>
<Col>
{/* <CPanelForm timeslots={timeslots} key={timeslots.id} /> */}
<AutoBook />
</Col>
</Row>
</TabPane>
<TabPane tabId="2">
<Row> <Row>
<Col> <Col>
{/* <CPanelForm timeslots={timeslots} key={timeslots.id} /> */} {/* <CPanelForm timeslots={timeslots} key={timeslots.id} /> */}
@ -75,7 +56,7 @@ const FormPage = ({ timeslots, item }) => {
</Col> </Col>
</Row> </Row>
</TabPane> </TabPane>
<TabPane tabId="3"> <TabPane tabId="2">
<Row> <Row>
<Col sm="12"> <Col sm="12">
<EmailBooking />{" "} <EmailBooking />{" "}

View File

@ -14,7 +14,11 @@ export const GenericForm = (props) => {
const [set, setSet] = useState(false); const [set, setSet] = useState(false);
useEffect(() => { useEffect(() => {
// console.log(initial);
// console.log(initial.domain);
if (!set) { if (!set) {
console.log(typeof initial.domain);
if (props.data) { if (props.data) {
setInitial(props.data); setInitial(props.data);
setSet(true); setSet(true);
@ -42,6 +46,11 @@ export const GenericForm = (props) => {
} }
}); });
const getInitial = () => {
// return initial;
};
console.log(initial);
if (set) { if (set) {
return ( return (
<Formik <Formik
@ -150,7 +159,7 @@ export const GenericForm = (props) => {
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
className={ className={
"form-control input-field" + "form-control" +
(errors.booked_date && touched.booked_date (errors.booked_date && touched.booked_date
? " is-invalid" ? " is-invalid"
: "") : "")
@ -173,6 +182,7 @@ export const GenericForm = (props) => {
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
className={ className={
"form-control" +
(errors.domain && touched.domain ? " is-invalid" : "") (errors.domain && touched.domain ? " is-invalid" : "")
} }
/> />
@ -193,6 +203,7 @@ export const GenericForm = (props) => {
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
className={ className={
"form-control" +
(errors.original_server && touched.original_server (errors.original_server && touched.original_server
? " is-invalid" ? " is-invalid"
: "") : "")
@ -215,6 +226,7 @@ export const GenericForm = (props) => {
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
className={ className={
"form-control" +
(errors.ticket_id && touched.ticket_id (errors.ticket_id && touched.ticket_id
? " is-invalid" ? " is-invalid"
: "") : "")
@ -267,6 +279,7 @@ export const GenericForm = (props) => {
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
className={ className={
"form-control" +
(errors.username && touched.username ? " is-invalid" : "") (errors.username && touched.username ? " is-invalid" : "")
} }
/> />
@ -288,6 +301,7 @@ export const GenericForm = (props) => {
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
className={ className={
"form-control" +
(errors.new_server && touched.new_server (errors.new_server && touched.new_server
? " is-invalid" ? " is-invalid"
: "") : "")
@ -337,6 +351,7 @@ export const GenericForm = (props) => {
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
className={ className={
"form-control" +
(errors.additional_domains && touched.additional_domains (errors.additional_domains && touched.additional_domains
? " is-invalid" ? " is-invalid"
: "") : "")
@ -360,6 +375,7 @@ export const GenericForm = (props) => {
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
className={ className={
"form-control" +
(errors.agent_booked && touched.agent_booked (errors.agent_booked && touched.agent_booked
? " is-invalid" ? " is-invalid"
: "") : "")

View File

@ -0,0 +1,3 @@
export const GET_MIGRATIONS = "GET_MIGRATIONS";
export const DATA_LOADED = "DATA_LOADED";
export const API_ERRORED = "API_ERRORED";

View File

@ -0,0 +1,21 @@
import { GET_MIGRATIONS } from "../constants/action-types";
const forbiddenWords = ["spam", "money"];
export function forbiddenWordsMiddleware({ dispatch }) {
return function (next) {
return function (action) {
// do your stuff
if (action.type === GET_MIGRATIONS) {
const foundWord = forbiddenWords.filter((word) =>
action.payload.title.includes(word)
);
if (foundWord.length) {
return dispatch({ type: "FOUND_BAD_WORD" });
}
}
return next(action);
};
};
}

View File

@ -0,0 +1,24 @@
import { GET_MIGRATIONS, DATA_LOADED } from "../constants/action-types";
const initialState = {
migs: [],
timeslots: [],
error: false,
};
function rootReducer(state = initialState, action) {
if (action.type === GET_MIGRATIONS) {
return Object.assign({}, state, {
migs: state.migs.concat(action.payload),
});
}
if (action.type === DATA_LOADED) {
return Object.assign({}, state, {
timeslots: state.timeslots.concat(action.payload),
});
}
return state;
}
export default rootReducer;

13
src/redux/store/index.js Normal file
View File

@ -0,0 +1,13 @@
import { createStore, applyMiddleware, compose } from "redux";
import rootReducer from "../reducers";
import { forbiddenWordsMiddleware } from "../middleware";
import thunk from "redux-thunk";
const storeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
rootReducer,
storeEnhancers(applyMiddleware(forbiddenWordsMiddleware, thunk))
);
export default store;