Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rtProject into development
  • Loading branch information
nmdra committed Oct 14, 2024
2 parents fccadab + 133800c commit 55bc8ce
Showing 10 changed files with 86 additions and 94 deletions.
70 changes: 0 additions & 70 deletions backend/controllers/Help/ccmController.js

This file was deleted.

13 changes: 13 additions & 0 deletions backend/controllers/shopController.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,19 @@ import asyncHandler from '../middlewares/asyncHandler.js'
import Shop from '../models/shopModel.js'

// Fetch all shops
export const getAllShops = asyncHandler(async (req, res) => {
try {
const shops = await Shop.find() // Fetch all shops
if (!shops || shops.length === 0) {
return res.status(404).json({ message: 'No shops found' }) // Handle case where no shops are found
}
res.json(shops) // Send the shops data as response
} catch (error) {
res.status(500).json({
message: 'Failed to fetch all shops: ' + error.message,
}) // Send error message in response
}
})
// route GET /api/shops
const getShops = asyncHandler(async (req, res) => {
try {
4 changes: 4 additions & 0 deletions backend/routes/shop_productRoute.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import {
createShop,
updateShop,
deleteShop,
getAllShops,
} from '../controllers/shopController.js'

import { protect } from '../middlewares/farmerauthMiddleware.js' // Ensure the path is correct
@@ -18,6 +19,9 @@ import {

const router = express.Router()

//Fetch All Shops
router.get('/all-shops', getAllShops)

// Route to handle GET and POST requests for shops
router
.route('/')
2 changes: 0 additions & 2 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -36,7 +36,6 @@ import {
//Help Routes
import routes from './routes/Help/index.js'
import authRoutes from './routes/Help/authCCM.route.js'
import ccmRoutes from './routes/Help/ccmRoutes.js'

// Production-only delivery task scheduling
if (process.env.SERVER_ENV === 'production') {
@@ -106,7 +105,6 @@ app.use('/api/news', newsRoutes) // News routes
//Help Routes
app.use('/api/help', routes)
app.use('/api/help/auth', authRoutes)
app.use('/api/ccm', ccmRoutes)

// Middleware to handle errors and send appropriate responses
app.use(notFound) // Handle 404 Not Found
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
"mapbox-gl": "^3.7.0",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-calendly": "^4.3.1",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
8 changes: 5 additions & 3 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -118,7 +118,8 @@ import Dashboard from './Pages/Help/CCManager/Dashboard'

import SupportTicketDashboardPage from './Pages/Help/CCManager/SupportTicket'
import FeedbackDashboard from './Pages/Help/CCManager/FeedbackDashboard'
import CCMProfile from './Pages/Help/CCManager/CCMProfile'
import Calendly from './Components/Help/Calendly'
// import CCMProfile from './Pages/Help/CCManager/CCMProfile'

// Define all routes in a single Router
const router = createBrowserRouter(
@@ -321,10 +322,11 @@ const router = createBrowserRouter(
<Route path="/help/login" element={<LogIn />} />
<Route path="/help/verify" element={<OtpEntry />} />
<Route path="/help/dashboard" element={<Dashboard />} />
<Route
<Route path="/help/calendly" element={<Calendly />} />
{/* <Route
path="/help/dashboard/profile"
element={<CCMProfile />}
/>
/> */}
<Route
path="/help/dashboard/feedbacks"
element={<FeedbackDashboard />}
11 changes: 11 additions & 0 deletions frontend/src/Components/Help/Calendly.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { InlineWidget } from 'react-calendly'

const Calendly = () => {
return (
<div className="py-[10rem]">
<InlineWidget url="https://calendly.com/aweesha-thavishanka/freelance-consulting" />
</div>
)
}

export default Calendly
2 changes: 1 addition & 1 deletion frontend/src/Components/Help/HelpHeroSection.jsx
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ const HelpHeroSection = () => {
</svg>
</Link>
<Link
to="https://cal.com/aweesha-thavishanka/30min"
to="/help/calendly"
className="inline-flex items-center justify-center px-5 py-3 text-base font-medium text-center text-black border border-gray-300 rounded-lg hover:bg-gray-100 focus:ring-4 focus:ring-gray-100 dark:text-white dark:border-gray-700 dark:hover:bg-gray-700 dark:focus:ring-gray-800"
>
<svg
53 changes: 43 additions & 10 deletions frontend/src/Components/Home/ShopList.jsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,66 @@
import { shopList } from '../../lib/constants/data'
import { useEffect, useState } from 'react'
import axios from 'axios'
import { useNavigate } from 'react-router-dom'

const ShopList = () => {
const [shops, setShops] = useState([]) // State to hold shop data
const [loading, setLoading] = useState(true) // Loading state
const [error, setError] = useState(null) // Error state

const navigate = useNavigate()

// Fetch shops from API when the component mounts
useEffect(() => {
const fetchShops = async () => {
try {
// Use the VITE_API_URL environment variable from .env file
const { data } = await axios.get(
`${import.meta.env.VITE_API_URL}/shops/all-shops`
)
setShops(data) // Set shop data in state
setLoading(false) // Turn off loading
} catch (error) {
console.error('Error fetching shops:', error)
setError('Failed to fetch shops') // Set error message
setLoading(false) // Turn off loading
}
}

fetchShops() // Call the fetch function
}, []) // Empty dependency array to only run on mount

if (loading) {
return <p>Loading shops...</p> // Show loading state
}

if (error) {
return <p>{error}</p> // Show error state
}

return (
<div className="mx-auto max-w-7xl py-[5rem]">
<h1 className="pb-10 text-4xl">Shop List</h1>
<div className="grid grid-cols-1 gap-6 md:grid-cols-4">
{shopList.map((item, index) => (
{shops.map((shop, index) => (
<div
key={index}
className=" border-2 p-2 border-[#b8f724] rounded-lg"
className="border-2 p-2 border-[#b8f724] rounded-lg"
>
<div>
<img
src={item.cover_img}
alt={item.shop_name}
src={shop.cover_img}
alt={shop.name}
className="object-cover w-[300px] h-[200px] rounded-md"
/>
</div>
<div className="flex flex-col py-3 gap-y-2">
<div className="">
<h1 className="text-xl ">{item.shop_name}</h1>
<h1 className="text-xl ">{shop.name}</h1>
</div>
<div className="flex items-center gap-3 ">
<h1>{item.ratings}</h1>

<h1>LKR.{item.delivery_fee}</h1>
<h1>{item.location}</h1>
<h1>{shop.ratings}</h1>
<h1>LKR.{shop.delivery_fee}</h1>
<h1>{shop.location}</h1>
</div>
</div>
</div>
16 changes: 8 additions & 8 deletions frontend/src/Pages/Help/CCManager/CCMProfile.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// import CustomerCareManagerProfile from '../../../Components/Help/dashboard/CustomerCareManagerProfile'

function CCMProfile() {
return (
<div>
{/* <CustomerCareManagerProfile /> */}
</div>
)
}
// function CCMProfile() {
// return (
// <div>
// <CustomerCareManagerProfile />
// </div>
// )
// }

export default CCMProfile
// export default CCMProfile

0 comments on commit 55bc8ce

Please sign in to comment.