Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<<<<<<< HEAD

# Logs
logs
*.log
Expand Down Expand Up @@ -129,7 +129,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
=======
# =======
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
Expand Down Expand Up @@ -165,4 +165,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
>>>>>>> dev

5 changes: 2 additions & 3 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ body {
)
rgb(var(--background-start-rgb));
}
<<<<<<< HEAD
=======

.button:hover{
background-color: aquamarine;
}
>>>>>>> dev

7 changes: 2 additions & 5 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })

export const metadata = {
<<<<<<< HEAD
title: 'Create Next App',
=======
//title: 'Create Next App',
// title: 'Create Next App',
title: 'Flexibble',
>>>>>>> dev
description: 'Generated by create next app',
}

Expand Down
Binary file added backgroundPage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
21 changes: 0 additions & 21 deletions firebase/AuthContextProvider.js

This file was deleted.

File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions firebase/checkUser.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, query, where, getDocs } from "firebase/firestore";

const firebaseConfig = {
apiKey: "AIzaSyBI8uNmgtfKks8JR7EQznSiTIg2HBEPYXI",
authDomain: "orders-91025.firebaseapp.com",
projectId: "orders-91025",
storageBucket: "orders-91025.appspot.com",
messagingSenderId: "722773717214",
appId: "1:722773717214:web:0faa7d1a39192b3367d24f",
measurementId: "G-3N85XGDSCM"
};
const app = initializeApp(firebaseConfig);

export const checkDataExistence = async (users, email, emailToCheck) => {
try {
const db = getFirestore(app);
const collectionRef = collection(db, users);
const q = query(collectionRef, where("email", "==", emailToCheck));
const docSnap = await getDocs(q);
let snapshotData;
if (!docSnap.empty) {
snapshotData = docSnap.docs[0].data();
console.log(snapshotData);
} else {
console.log('No matching documents found.');
}
return !docSnap.empty;
} catch (error) {
console.log(error);
return false;
}
};

export const checkPassword = async (users,password,passwordToCheck) => {
try {
const db = getFirestore(app);
const collectionRef = collection(db, users);
const q = query(collectionRef, where("password", "==", passwordToCheck));
const docSnap = await getDocs(q);
let snapshotData;
if (!docSnap.empty) {
snapshotData = docSnap.docs[0].data();
console.log(snapshotData);
} else {
console.log('No matching documents found.');
}
return !docSnap.empty;
} catch (error) {
console.log(error);
return false;
}
};
18 changes: 0 additions & 18 deletions firebase/checkUser.tsx

This file was deleted.

27 changes: 24 additions & 3 deletions firebase/firebaseApp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import { initializeApp } from "firebase/app";
// import { getApps } from "firebase/app";
import { getDatabase, ref, set } from 'firebase/database'
// import { getDatabase, ref, set /} from 'firebase/database'
import firebase from "firebase/compat/app";

const firebaseConfig = {
Expand All @@ -14,11 +14,32 @@ const firebaseConfig = {
};
firebase.initializeApp(firebaseConfig);

function writeUserData(userId:any, email:any, password:any) {
export async function writeUserData(userId:any, email:any, password:any) {
// const userRef = firebase.firestore().collection("users").add()
// alert(JSON.stringify(userId))
firebase.firestore().collection("users").doc(userId).set(({
email,
password,
}))
}
writeUserData("3","k.m15@gmail.com","1546")


export const db = firebase.firestore();

// const getDataFromCollection = async () => {
// try {
// const collectionRef = db.collection('users');
// const snapshot = await collectionRef.get();
// const data = [];
// snapshot.forEach((doc) => {
// const docData = doc.data();
// data.push(docData);
// });

// console.log(data); // Process or display the extracted data
// } catch (error) {
// console.log(error);
// }
// };

// getDataFromCollection();
69 changes: 45 additions & 24 deletions firebase/signIn.jsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,70 @@
'use client'
import React, { useState } from 'react'
import { useRouter } from 'next/navigation'
import check from './checkUser'
import { checkDataExistence } from './checkUser';
import { getAuth, signInWithEmailAndPassword } from "firebase/auth";
import { checkPassword } from './checkUser';
// import Settings from '../pages/settings'
import integrations from '../pages/settings'


function Page() {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [emailToCheck, setEmailToCheck] = useState('')
const [passwordToCheck, setPasswordToCheck] = useState('')
const router = useRouter('')
const handleForm = async (event) => {
event.preventDefault()
const { result, error } = await (email, password);
if (error) {
return console.log(error)
}
console.log(result)
if (!email, !password) {
alert("sign up")
// const { result, error } = await (emailToCheck, password);
// if (error) {
// return console.log(error)
// }
// console.log(result)
// const user = { email, password };
const resultCheck = await checkDataExistence('users', 'email', emailToCheck);
const resultPass = await checkPassword('users', 'password',passwordToCheck)
// alert(JSON.stringify(resultCheck));
if (resultCheck) {
if (resultPass) {
// alert(integrations)
// alert(JSON.stringify(Settings))
// return router.push('/settings');
return router.push("listOrders")
} else {
alert("the password is wrong!")
}
} else {
return router.push("listOrders")
alert("You are not registered, please sign up")
window.location.reload();
}
// const auth = getAuth();
// signInWithEmailAndPassword(auth, email, password)
// .then((userCredential) => {
// // Signed in
// const user = userCredential.user;
// // ...
// })
// .catch((error) => {
// const errorCode = error.code;
// const errorMessage = error.message;
// });

}
async function handelSignIn() {
let user = { email, password }
alert(email)
await check(user);
}
return (<div className="wrapper">
<div className="form-wrapper">
return (<div className="wrapper" style={{ color: 'chocolate' }}>
<div className="form-wrapper" style={{ color: 'chocolate' }}>
<h1 className="mt-60 mb-30">Sign In</h1>
<form onSubmit={handleForm} className="form">
<label htmlFor="email">
<p>Email</p>
<input onChange={(e) => setEmail(e.target.value)} required type="email" name="email" id="email" placeholder="example@mail.com" />
<input onChange={(ev) => setEmailToCheck(ev.target.value)} required type="email" name="email" id="email" placeholder="example@mail.com" />
</label>
<label htmlFor="password">
<p>Password</p>
<input onChange={(e) => setPassword(e.target.value)} required type="password" name="password" id="password" placeholder="password" />
<input onChange={(ev) => setPasswordToCheck(ev.target.value)} required type="password" name="password" id="password" placeholder="password" />
</label>
<button type="submit">Sign In</button>
<button style={{ color: 'chocolate' }} type="submit">Sign In</button>
</form>
</div>

</div>
);
}

export default Page;
// onClick={handelSignIn()}
15 changes: 15 additions & 0 deletions firebase/signOut.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getAuth, signOut } from "firebase/auth"

const auth = getAuth();
signOut(auth).then(() => {
// Sign-out successful.
}).catch((error) => {
// An error happened.
});
// firebase.auth().signOut().then(() => {
// // Sign-out successful.
// }).catch((error) => {
// // An error happened.
// });


64 changes: 53 additions & 11 deletions firebase/signUp.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,71 @@
'use client'
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { useRouter } from 'next/navigation'

import { writeUserData } from '../pages/index'
import { checkDataExistence } from './checkUser';
import { getAuth, createUserWithEmailAndPassword} from "firebase/auth";
// import Button from 'react-bootstrap/Button';

function Page() {
const [email, setEmail] = useState('')
const [emailToCheck, setEmailToCheck] = useState('')
const [password, setPassword] = useState('')
const router = useRouter()
const [userId, setUserId] = useState(() => {
const hasBeenReset = localStorage.getItem('hasBeenReset');
// if (hasBeenReset) {
// return 0; // Reset the count to 0
// } else {
// const storedUserId = localStorage.getItem('userId');
// return storedUserId ? parseInt(storedUserId) : 0;
// }
// });

const storeduserId = localStorage.getItem('userId');
return storeduserId ? parseInt(storeduserId) : 0;
});


useEffect(() => {
localStorage.setItem('userId', userId.toString());
}, [userId])
const handleForm = async (event) => {
const auth = getAuth();
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
// ...
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
// ..
});
event.preventDefault()
const { result, error } = await (email, password);
if (error) {
// return alert("somthing is bad")
return console.log(error)
alert("error");
}
alert("sign up sucsses");
console.log(result)
return router.push("listOrders")
const user = { email, password };
const resultCheck = await checkDataExistence('users', 'email', emailToCheck);
if (resultCheck) {
alert("exist! please sign in")
window.location.reload();
} else {
alert("You have successfully registered!")
setUserId((prevUserId) => prevUserId + 1);
writeUserData(userId.toString(), emailToCheck, password);
return router.push("listOrders");
}

}
return (<div className="wrapper">
<div className="form-wrapper">
return (<div className="wrapper" style={{ color: 'chocolate' }}>
<div className="form-wrapper" style={{ color: 'chocolate' }}>
<h1 className="mt-60 mb-30">Sign up</h1>
<form onSubmit={handleForm} className="form" >
<label htmlFor="email">
<p>Email</p>
<input onChange={(e) => setEmail(e.target.value)} required type="email" name="email" id="email" placeholder="example@mail.com" />
<input onChange={(e) => setEmailToCheck(e.target.value)} required type="email" name="email" id="email" placeholder="example@mail.com" />
</label>
<label htmlFor="password">
<p>Password</p>
Expand Down
Loading