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
//at services/parse.js | |
import Parse from 'parse'; | |
//checking if env is browser | |
if (typeof window !== "undefined") { | |
Parse.initialize("APP_ID","JS_KEY"); | |
Parse.serverURL = 'https://parseapi.back4app.com/'; | |
} |
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
import Parse from 'parse'; | |
if (typeof window !== "undefined") { | |
Parse.initialize(process.env.PARSE_APP_ID,process.env.PARSE_JS_KEY); | |
Parse.serverURL = 'https://parseapi.back4app.com/'; | |
} | |
export default Parse; |
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
import { useState } from "react"; | |
import styles from "../styles/Home.module.css"; | |
import Parse from "../service/parse"; | |
export default function Home() { | |
const [employeeName, setEmployeeName] = useState(""); | |
const [employeeEmail, setEmployeeEmail] = useState(""); | |
const [employeePassword, setEmployeePassword] = useState(""); | |
const [employees, setEmployees] = useState([]); |
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
const employee = new Parse.Object('Employee'); | |
employee | |
.save({ | |
username: employeeName, | |
email: employeeEmail, | |
password: employeePassword, | |
}) |
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
const getEmployees = async () => { | |
const query = new Parse.Query("Employee"); | |
const res = await query.findAll(); | |
const employees = res.map((employee) => ({ name: employee.get("username") })); | |
setEmployees(employees); | |
}; |
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
import "../styles/globals.css"; | |
import { initializeParse } from "@parse/react-ssr"; | |
initializeParse( | |
"https://parsechatarticletest.b4a.io/", | |
"PARSE_APP_ID", //Insert your parse app id here | |
"PARSE_JS_KEY", //Insert your parse JS key | |
); | |
function MyApp({ Component, pageProps }) { |
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
import { useState } from "react"; | |
import styles from "../styles/Auth.module.css"; | |
export default function Auth() { | |
const [isRegistering, setIsRegistering] = useState(false); | |
const [username, setUserName] = useState(false); | |
const [password, setPassword] = useState(false); | |
const toggleIsRegistering = () => setIsRegistering(!isRegistering); |
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
const handleRegister = () => { | |
const user = new Parse.User(); | |
user | |
.save({ | |
username, | |
password, | |
}) | |
.then(() => { | |
handleLogin(); |
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
const handleLogin = () => { | |
Parse.User.logIn(username, password).then((user) => { | |
console.log(`successfully loged ${user.get("username")}`) | |
}); | |
}; |
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
export default function Home() { | |
const router = useRouter(); | |
//..rest of the code |
OlderNewer