Skip to content

Commit

Permalink
Error Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
git-sujon committed Nov 28, 2022
1 parent 6bdde7c commit 7fc856f
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 67 deletions.
31 changes: 31 additions & 0 deletions firebase-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[debug] [2022-11-28T17:11:03.694Z] ----------------------------------------------------------------------
[debug] [2022-11-28T17:11:03.697Z] Command: C:\Program Files\nodejs\node.exe C:\Users\Sujon\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js init
[debug] [2022-11-28T17:11:03.698Z] CLI Version: 11.16.1
[debug] [2022-11-28T17:11:03.698Z] Platform: win32
[debug] [2022-11-28T17:11:03.698Z] Node Version: v16.15.0
[debug] [2022-11-28T17:11:03.700Z] Time: Mon Nov 28 2022 23:11:03 GMT+0600 (Bangladesh Standard Time)
[debug] [2022-11-28T17:11:03.701Z] ----------------------------------------------------------------------
[debug]
[debug] [2022-11-28T17:11:03.716Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2022-11-28T17:11:03.717Z] > authorizing via signed-in user (git.sujon@gmail.com)
[info]
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########

You're about to initialize a Firebase project in this directory:

C:\Users\Sujon\Desktop\Mission\Module-78 {ass-12}\client

[info]
=== Project Setup
[info]
[info] First, let's associate this project directory with a Firebase project.
[info] You can create multiple project aliases by running firebase use --add,
[info] but for now we'll just set up a default project.
[info]
[debug] [2022-11-28T17:11:14.204Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects pageSize=100
[debug] [2022-11-28T17:11:15.564Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects 200
[debug] [2022-11-28T17:11:15.564Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects [omitted]
14 changes: 10 additions & 4 deletions src/Contexts/AuthProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const AuthProvider = ({children}) => {
const userEmailQueryData = (email) => {
setLoading(true)
// axios
// .post(`http://localhost:5000/users?email=${event?.email}`)
fetch(`http://localhost:5000/users?email=${email}`, {
// .post(`https://server-git-sujon.vercel.app/users?email=${event?.email}`)
fetch(`https://server-git-sujon.vercel.app/users?email=${email}`, {
method: "GET",
// headers: {
// "content-type": "application/json",
Expand All @@ -61,6 +61,7 @@ const AuthProvider = ({children}) => {
.then((res) => res.json())
.then((data) => {
setEmailData(data[0]);

});
}

Expand All @@ -77,13 +78,18 @@ const AuthProvider = ({children}) => {
.then((res) => res.json())
.then((imageData) => {
const photoUrl= imageData?.data?.display_url;
console.log(photoUrl)
setHostedPhotoUrl(photoUrl)
if(photoUrl){
setLoading(true)
setHostedPhotoUrl(photoUrl)
}

})

};




useEffect(()=>{
const unSubscribe= onAuthStateChanged(auth, currentUser => {
setUser(currentUser)
Expand Down
2 changes: 1 addition & 1 deletion src/Hooks/IsAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const IsAdmin = (email) => {

useEffect(() => {
if (email) {
fetch(`http://localhost:5000/users/admin/${email}`)
fetch(`https://server-git-sujon.vercel.app/users/admin/${email}`)
.then((res) => res.json())
.then((data) => {
console.log(data);
Expand Down
2 changes: 1 addition & 1 deletion src/Hooks/UseToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const UseToken = (email) => {
const [token, setToken] = useState("");
useEffect(() => {
if (email) {
fetch(`http://localhost:5000/jwt?email=${email}`)
fetch(`https://server-git-sujon.vercel.app/jwt?email=${email}`)
.then((res) => res.json())
.then((data) => {
if (data.accessToken) {
Expand Down
29 changes: 24 additions & 5 deletions src/Layout/DashboardLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,42 @@ const DashboardLayout = () => {
</div>
</div>

<li>
{
(emailData?.accountType === 'Seller' || emailData?.isAdmin) &&
<>
<li>
<Link to="/dashboard">My Products</Link>
</li>

<li>
<Link to="/dashboard/addProducts">Add Products</Link>
</li>
</>
}

<li>
<Link to="/dashboard/myOrders">My Orders</Link>
</li>
<li>

{
(emailData?.accountType === 'Buyer' || emailData?.isAdmin ) &&
<li>
<Link to="/dashboard/myOrders">My Orders</Link>
</li>

}

{

emailData?.isAdmin &&
<>
<li>
<Link to="/dashboard/allSellers">All Sellers</Link>
</li>
<li>
<Link to="/dashboard/allBuyers">All Buyers</Link>
</li>

</>
}

</ul>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Buyer/MyOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const MyOrders = () => {
queryKey: ["bookings", user?.email],
queryFn: async () => {
const res = await fetch(
`http://localhost:5000/bookings?buyerEmail=${user?.email}`
`https://server-git-sujon.vercel.app/bookings?buyerEmail=${user?.email}`
);
const data = await res.json();
return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CatagoriesShowcase = () => {
const { data: catagories = [], isLoading } = useQuery({
queryKey: ["catagories"],
queryFn: async () => {
const res = await fetch(`http://localhost:5000/catagories`);
const res = await fetch(`https://server-git-sujon.vercel.app/catagories`);
const data = await res.json();
return data;
},
Expand Down
72 changes: 65 additions & 7 deletions src/Pages/Dashboard/AllBuyers/AllBuyers.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,76 @@
import { CheckBadgeIcon } from '@heroicons/react/24/solid';
import { useQuery } from '@tanstack/react-query';
import React from 'react';
import React, { useState } from 'react';
import toast from 'react-hot-toast';
import Spinner from '../../Shared/Spinner/Spinner';

const AllBuyers = () => {

const [toggle, setToggle] = useState(true);
const {data:users = [], isLoading, refetch} = useQuery({
queryKey: ['users'],
queryFn: async()=> {
const res= await fetch(`http://localhost:5000/users`)
const res= await fetch(`https://server-git-sujon.vercel.app/Buyers?accountType=Buyer`)
const data = await res.json()
return data
}
})
console.log(users)
console.log(users);

const varifingHandler = (user) => {
fetch(`https://server-git-sujon.vercel.app/users/${user?._id}`, {
method: "PUT",
headers: {
"content-type": "application/json",
},
body: JSON.stringify({ isVerified: toggle }),

})
.then((res) => res.json())
.then((data) => {
console.log(data);
if (data.modifiedCount > 0) {
{
user?.isVerified?.isVerified
? toast.error(`Verify Undone`)
: toast.success(`User Verified `);
}
setToggle(!toggle);
refetch();

// fetch(`https://server-git-sujon.vercel.app/products?isVerified=isVerified`,{
// method: 'GET',
// headers: {
// "content-type": "application/json",
// },
// // body: JSON.stringify({ isVerified: toggle }),
// })
// .then((res) => res.json())
// .then((data) =>{
// console.log(data)

// })

}
});
}

const deleteUserHndler = (user) => {
fetch(`https://server-git-sujon.vercel.app/users/${user?._id}`, {
method: "DELETE",

})
.then(res=> res.json())
.then(data => {
console.log(data)
refetch()
})
}

if(isLoading){
return <Spinner></Spinner>
}



return (
<div>
Expand Down Expand Up @@ -55,7 +113,7 @@ const AllBuyers = () => {
<p className="text-neutral text-sm font-semibold flex items-center justify-between w-1/2">
{
//
(user?.isVerified ?
(user?.isVerified?.isVerified ?
<>{<>{'Verified'} <CheckBadgeIcon className="h-5 w-5 ml-2 text-blue-500"></CheckBadgeIcon></>}</>
:

Expand All @@ -68,15 +126,15 @@ const AllBuyers = () => {

<td className="flex items-center justify-center ">
<button
// onClick={() => payNowHandler(user)}
onClick={() => varifingHandler(user)}
className="btn btn-neutral btn-md hover:btn-primary text-center text-white font-semibold"
>
Make Verified
</button>
</td>
<td className="text-center">
<button
// onClick={() => payNowHandler(user)}
onClick={() => deleteUserHndler(user)}
className="btn btn-neutral btn-md hover:btn-primary text-white font-semibold"
>
Delete
Expand Down
21 changes: 18 additions & 3 deletions src/Pages/Dashboard/AllSeller/AllSeller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const AllSeller = () => {
const {data:users = [], isLoading, refetch} = useQuery({
queryKey: ['users'],
queryFn: async()=> {
const res= await fetch(`http://localhost:5000/users`)
const res= await fetch(`https://server-git-sujon.vercel.app/sellers?accountType=Seller`)
const data = await res.json()
return data
}
})
console.log(users);

const varifingHandler = (user) => {
fetch(`http://localhost:5000/users/${user?._id}`, {
fetch(`https://server-git-sujon.vercel.app/users/${user?._id}`, {
method: "PUT",
headers: {
"content-type": "application/json",
Expand All @@ -38,18 +38,33 @@ const AllSeller = () => {
}
setToggle(!toggle);
refetch();

// fetch(`https://server-git-sujon.vercel.app/products?isVerified=isVerified`,{
// method: 'GET',
// headers: {
// "content-type": "application/json",
// },
// // body: JSON.stringify({ isVerified: toggle }),
// })
// .then((res) => res.json())
// .then((data) =>{
// console.log(data)

// })

}
});
}

const deleteUserHndler = (user) => {
fetch(`http://localhost:5000/users/${user?._id}`, {
fetch(`https://server-git-sujon.vercel.app/users/${user?._id}`, {
method: "DELETE",

})
.then(res=> res.json())
.then(data => {
console.log(data)
refetch()
})
}

Expand Down
12 changes: 0 additions & 12 deletions src/Pages/Dashboard/Dashboard.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/Pages/Home/Advertised/Advertised.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Advertised = () => {
} = useQuery({
queryKey: ["products"],
queryFn: async () => {
const res = await fetch(`http://localhost:5000/products`);
const res = await fetch(`https://server-git-sujon.vercel.app/products`);
const data = await res.json();
return data;
},
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Products/Products.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Products = () => {
const { data: products = [], isLoading } = useQuery({
queryKey: ["products", category?.catagoriesName],
queryFn: async () => {
const res = await fetch(`http://localhost:5000/products?category=${category.catagoriesName}`);
const res = await fetch(`https://server-git-sujon.vercel.app/products?category=${category.catagoriesName}`);
const data = await res.json();
return data;
},
Expand Down
Loading

0 comments on commit 7fc856f

Please sign in to comment.