Skip to content

Commit

Permalink
environmental variables applied
Browse files Browse the repository at this point in the history
  • Loading branch information
nazmussakibofficial committed Nov 8, 2022
1 parent 5162351 commit 9f663a4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ function App() {
},
{
path: '/services',
element: <Services></Services>,
loader: () => fetch('http://localhost:5000/services')
element: <Services></Services>
},
{
path: '/services/:id',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pages/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Login = () => {
.then(result => {
const user = result.user
form.reset();
navigate(from, { replace: true })
navigate(from, { replace: true });
})
.catch(e => console.error(e))

Expand Down
35 changes: 26 additions & 9 deletions src/components/Pages/Services.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { useLoaderData } from 'react-router-dom';
import ServiceCard from '../Shared/ServiceCard';

const Services = () => {
const services = useLoaderData();
const [services, setServices] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
fetch('http://localhost:5000/services')
.then(res => res.json())
.then(data => {
setServices(data)
setLoading(false)
})
}, [])
return (
<div className='container mx-auto py-16 px-4'>
<h1 className='text-4xl font-bold text-primary text-center mb-6 p-4'>Our Services</h1>
<div className='grid grid-cols-1 md:grid-cols-3 gap-4'>
{
services.map(service => <ServiceCard key={service._id} service={service}></ServiceCard>)
}
</div>
<div>
{!loading ?
<div className='container mx-auto py-16 px-4'>
<h1 className='text-4xl font-bold text-primary text-center mb-6 p-4'>Our Services</h1>
<div className='grid grid-cols-1 md:grid-cols-3 gap-4'>
{
services.map(service => <ServiceCard key={service._id} service={service}></ServiceCard>)
}
</div>
</div>
:
<div className='flex justify-center my-6'>
<button className="btn loading">loading</button>
</div>
}
</div>
);
};
Expand Down
5 changes: 3 additions & 2 deletions src/components/Pages/UserReviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ const UserReviews = () => {
return (

<div className='min-h-screen'>
{

{comments.length !== 0 ?
comments.map(comment => <CommentOptions key={comment._id} comments={comment} handleDelete={handleDelete} handleUpdate={handleUpdate}></CommentOptions>)
:
<h2 className='text-3xl text-center mt-6'>No reviews were added</h2>
}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Shared/PrivateRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const PrivateRoute = ({ children }) => {
if (user) {
return children;
}
return <Navigate state={{ from: location }} replace></Navigate>
return <Navigate to='/login' state={{ from: location }} replace></Navigate>
};

export default PrivateRoute;
12 changes: 6 additions & 6 deletions src/firebase/firebase.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { initializeApp } from "firebase/app";

// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyB6wYSxsdSnHbzCTpPIz3I01IbKb8Cd04k",
authDomain: "gallery-of-memories.firebaseapp.com",
projectId: "gallery-of-memories",
storageBucket: "gallery-of-memories.appspot.com",
messagingSenderId: "117668417811",
appId: "1:117668417811:web:0ccc9e9bda14cb67610ae6"
apiKey: process.env.REACT_APP_apiKey,
authDomain: process.env.REACT_APP_authDomain,
projectId: process.env.REACT_APP_projectId,
storageBucket: process.env.REACT_APP_storageBucket,
messagingSenderId: process.env.REACT_APP_messagingSenderId,
appId: process.env.REACT_APP_appId
};

// Initialize Firebase
Expand Down

0 comments on commit 9f663a4

Please sign in to comment.