Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/admin/login #14

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
36304da
chore:added dependencies
Jan 17, 2024
1c4d6b4
modified: app.tsx and main.tsx
Jan 17, 2024
8ddcbde
added: driver type data (#1)
Someone-rahul Jan 17, 2024
455fe0d
Master (#2)
Someone-rahul Jan 17, 2024
7edf98c
Master (#3)
Someone-rahul Jan 19, 2024
f131f31
feat:user registration with custom json for testing
Someone-rahul Jan 19, 2024
4a6edd4
fixed:registration and added a login feature
Jan 19, 2024
2c249d3
Feat/admin/passenger (#6)
Someone-rahul Jan 23, 2024
b4d873a
feat: added client side pages and components
SagarAdhikari19 Jan 17, 2024
0ce3a8b
admin-dashboard-updated
SagarAdhikari19 Jan 19, 2024
ef671b6
jsondb_updated
SagarAdhikari19 Jan 19, 2024
4180ce0
table created
SagarAdhikari19 Jan 22, 2024
2809820
added some changes in admin side UI
Jan 23, 2024
e57defa
feat:added a repository context to access all repos objects
Jan 24, 2024
0530bbd
Merge branch 'main' of github.com:truenary/pl7-web-app
Jan 25, 2024
92007ec
feat:managed driver info
Jan 25, 2024
c51eeb8
some changes added
Jan 29, 2024
7bb85a9
added a map feature from sagar
Jan 29, 2024
1df1e1c
refactor: removed passenger info
Feb 2, 2024
18d9bc1
Merge branch 'main' of github.com:truenary/pl7-web-app
Feb 2, 2024
baf43dd
fixed:bug in dashboard_map
Feb 2, 2024
2af06a1
fixed:bugs at passenger info
Feb 2, 2024
75491cc
refactor:added a generic api and repositories
Feb 9, 2024
6b9a9ca
refactor: deleted other repo and apis
Feb 9, 2024
5fff332
refactor: completed
Feb 9, 2024
37bdaca
fixed: comments
Feb 12, 2024
a06bba3
chore: added pagination logic
Feb 14, 2024
ff8b12e
feat: pagination added in driver and passenger table
Feb 14, 2024
fcdea22
feat: added ride history
SagarAdhikari19 Feb 14, 2024
37cf564
feat : Blog feature added
SagarAdhikari19 Feb 15, 2024
6e2148e
feat :commentfixed : lodash implemented
SagarAdhikari19 Feb 15, 2024
175ef01
Fixed : comment
SagarAdhikari19 Feb 16, 2024
a2c5361
Merge branch 'main' of github.com:truenary/pl7-web-app
Feb 16, 2024
79cf3df
Merge branch 'main' of github.com:truenary/pl7-web-app
SagarAdhikari19 Feb 16, 2024
e8953b2
fix:merge confilts fixed
SagarAdhikari19 Feb 16, 2024
6b8f325
updated api
Feb 20, 2024
436258f
Merge branch 'main' of https://github.com/sagaradhi19/autoapp_testing
SagarAdhikari19 Feb 20, 2024
6b23fc1
fixed :design
SagarAdhikari19 Feb 20, 2024
00bdfc5
Enhanced About Us section: new design, refined content
SagarAdhikari19 Feb 19, 2024
d3a407d
fixed :footer
SagarAdhikari19 Feb 19, 2024
7986a16
passenger list fetch
SagarAdhikari19 Feb 20, 2024
2f6f5a9
fixed : error with passengertable
SagarAdhikari19 Feb 20, 2024
a99694f
fixed : login
SagarAdhikari19 Feb 22, 2024
2b31829
fixed : login-task Completed
SagarAdhikari19 Feb 22, 2024
97849ec
fixed : comments
SagarAdhikari19 Feb 26, 2024
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
30 changes: 29 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"react-redux": "^9.1.0",
"react-router-dom": "^6.21.2",
"recharts": "^2.11.0",
"use-places-autocomplete": "^4.0.1"
"use-places-autocomplete": "^4.0.1",
"zustand": "^4.5.1"
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^5.17.20",
Expand Down
57 changes: 32 additions & 25 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
import AppLayout from "./client/pages/AppLayout";
import Home from "./client/pages/Home";
import Contact from "./client/pages/Contact";
import Register from "./client/pages/Register";
// import Register from "./client/pages/Register";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these commented imports.

import Blog from "./client/pages/Blog";
import About from "./client/pages/About";
import Download from "./client/pages/Download";
Expand All @@ -22,6 +22,10 @@ import { RepositoryProvider } from "./provider/RepositoryProvider";
import DriverInfo from "./admin/pages/DriverInfoPage";
import RidesHistory from "./admin/components/RidesHistory/RidesHistory";
import { RideInfo } from "./admin/components/Rides/RideInfo";
import FormWithNumber from "./client/components/register/FormWithNumber";
import OtpForm from "./client/components/register/OtpForm";
import UserRegisterform from "./client/components/register/UserRegisterForm";
// import BlogAdmin from "./admin/components/Blog/BlogAdmin";

function App() {
return (
Expand All @@ -32,7 +36,9 @@ function App() {
<Route path="/*" element={<AppLayout />}>
<Route index element={<Home />} />
<Route path="contact" element={<Contact />} />
<Route path="register" element={<Register />} />
<Route path="registerPhone" element={<FormWithNumber />} />
<Route path="checkOtp" element={<OtpForm />} />
<Route path="register" element={<UserRegisterform />} />
<Route path="blog" element={<Blog />} />
<Route path="about" element={<About />} />
<Route path="login" element={<Login />} />
Expand All @@ -42,7 +48,7 @@ function App() {
<Route index element={<Dashboard />} />
<Route path="onlinedriver" element={<Onlinedriver />} />
<Route path="drivers" element={<Driver />} />
<Route path="drivers/:id" element={<DriverInfo />} />
<Route path="driverInfo" element={<DriverInfo />} />
<Route path="passengers" element={<Passengers />} />
<Route path="ratings" element={<Rating />} />
<Route path="rides" element={<Ride />} />
Expand All @@ -51,28 +57,29 @@ function App() {
<Route path="logout" element={<Logout />} />
</Route>

<Route path="*" element={<PageNotFound />} />
</Routes>
</Router>
<Toaster
position="top-center"
gutter={12}
toastOptions={{
success: {
duration: 4000,
},
error: {
duration: 5000,
},
style: {
fontSize: "16px",
padding: "16px 24px",
maxWidth: "500px",
backgroundColor: "blue-100",
},
}}
containerStyle={{ margin: "8px" }}
/>
<Route path="*" element={<PageNotFound />} />
</Routes>
</Router>
<Toaster
position="top-center"
gutter={12}
toastOptions={{
success: {
duration: 4000,
},
error: {
duration: 5000,
},
style: {
fontSize: "16px",
padding: "16px 24px",
maxWidth: "500px",
backgroundColor: "blue-100",
},
}}
containerStyle={{ margin: "8px" }}
/>

</RepositoryProvider>
</>
);
Expand Down
10 changes: 10 additions & 0 deletions src/Storemanagement/Store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import{ create} from 'zustand';
interface PaginationState {
currentPage: number;
setCurrentPage: (page: number) => void;
}

export const usePaginationStore = create<PaginationState>((set) => ({
currentPage: 1,
setCurrentPage: (page) => set({ currentPage: page }),
}));
29 changes: 29 additions & 0 deletions src/admin/action/FetchOnlineDriverData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useEffect, useState } from 'react';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these throwing errors? "useEffect" and "useState" are hooks and can't be used here. Just return the response data received.

import { OnlineDriver } from '@/types/data';
import _ from 'lodash';
import { Repository } from '@/repositories/Repository';

export function useOnlineDrivers(repo: Repository): OnlineDriver[] | null {
const [onlineDrivers, setOnlineDrivers] = useState<OnlineDriver[] | null>(null);

useEffect(() => {
const fetchData = async () => {
try {
const data = await repo.getAllOnlineDriver();
if (_.isArray(data)) {
setOnlineDrivers(data);
} else {
console.error('Data is not in the expected format:', data);
setOnlineDrivers(null);
}
} catch (error) {
console.error('Error fetching data:', error);
setOnlineDrivers(null);
}
};

fetchData();
}, [repo]);

return onlineDrivers;
}
105 changes: 105 additions & 0 deletions src/admin/components/Blog/BlogAdmin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { useRepository } from '@/hooks/CustomHook';
import { BlogPostFormData } from '@/types/data';
import React from 'react';
import { SubmitHandler, useForm } from 'react-hook-form';
import toast from 'react-hot-toast';
import BlogSection from './BlogSection';

const BlogAdmin: React.FC = () => {
const { register, handleSubmit, formState: { errors } } = useForm<BlogPostFormData>();
const repository = useRepository();

const onSubmit: SubmitHandler<BlogPostFormData> = async (data ) => {
const formData = new FormData();
formData.append('title', data.title);
formData.append('content', data.content);
if (data.photo) {
formData.append('blogImage', data.photo[0]);
}
if (data.video) {
formData.append('blogVideo', data.video[0]);
}

try {
const response = await repository.repo.createBlogPost(formData);
if (response) {
toast.success('Blog post submitted successfully!');
console.log(data)
} else {
toast.error('Failed to submit blog post!');
console.log(data)
}
} catch (error) {
console.error('Error submitting blog post:', error);
console.log(data)
toast.error('An error occurred while submitting blog post!');
}
};
return (
<>
<div className="container mx-auto p-4 ">
<h1 className="text-3xl font-bold mb-4">Blog Section</h1>
<form onSubmit={handleSubmit(onSubmit)}>
<div className="mb-4">
<label htmlFor="title" className="block text-sm font-medium text-gray-700 mb-1">
Title
</label>
<input
type="text"
id="title"
{...register('title', { required: true })}
className="w-full mx-2 my-2 border-gray-300 rounded-md shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 h-14"
/>
{errors.title && <span className="text-red-500">Title is required</span>}
</div>
<div className="mb-4">
<label htmlFor="content" className="block text-sm font-medium text-gray-700 mb-1">
Content
</label>
<textarea
id="content"
{...register('content', { required: true })}
className="w-full border-gray-300 rounded-md shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-500 focus:ring-opacity-50"
rows={8}
></textarea>
{errors.content && <span className="text-red-500">Content is required</span>}
</div>
<div className="mb-4">
<label htmlFor="photo" className="block text-sm font-medium text-gray-700 mb-1">
Photo
</label>
<input
type="file"
id="blogImage"
{...register('photo')}
className="w-full border-gray-300 rounded-md shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-500 focus:ring-opacity-50"
/>
</div>
<div className="mb-4">
<label htmlFor="video" className="block text-sm font-medium text-gray-700 mb-1">
Video
</label>
<input
type="file"
id="blogVideo"
{...register('video')}
className="w-full border-gray-300 rounded-md shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-500 focus:ring-opacity-50"
accept="video/*"
/>
</div>
<div className="flex justify-center">
<button
type="submit"
className="inline-block bg-indigo-500 text-white py-2 px-6 rounded-md hover:bg-indigo-600 focus:outline-none focus:ring focus:ring-indigo-200"
>
Publish
</button>
</div>
</form>
</div>
<BlogSection />
</>
);
};

export default BlogAdmin;
101 changes: 101 additions & 0 deletions src/admin/components/Blog/BlogSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React from 'react'

function BlogSection() {
return (
<>


<div className='grid grid-cols-3 gap-4 my-32'>
<div className="container mx-auto p-4 ">
<h1 className="text-3xl font-bold mb-4">Blog Section</h1>
<div className="max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
<a href="#">
<img className="rounded-t-lg" src="/docs/images/blog/image-1.jpg" alt="" />
</a>
<div className="p-5">
<a href="#">
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Noteworthy technology acquisitions 2021</h5>
</a>
<p className="mb-3 font-normal text-gray-700 dark:text-gray-400">Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.</p>
<a href="#" className="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
Read more
<svg className="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M1 5h12m0 0L9 1m4 4L9 9"/>
</svg>
</a>
</div>
</div>

</div>

<div className="container mx-auto p-4">
<h1 className="text-3xl font-bold mb-4">Blog Section</h1>
<div className="max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
<a href="#">
<img className="rounded-t-lg" src="/docs/images/blog/image-1.jpg" alt="" />
</a>
<div className="p-5">
<a href="#">
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Noteworthy technology acquisitions 2021</h5>
</a>
<p className="mb-3 font-normal text-gray-700 dark:text-gray-400">Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.</p>
<a href="#" className="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
Read more
<svg className="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M1 5h12m0 0L9 1m4 4L9 9"/>
</svg>
</a>
</div>
</div>

</div>

<div className="container mx-auto p-4">
<h1 className="text-3xl font-bold mb-4">Blog Section</h1>
<div className="max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
<a href="#">
<img className="rounded-t-lg" src="/docs/images/blog/image-1.jpg" alt="" />
</a>
<div className="p-5">
<a href="#">
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Noteworthy technology acquisitions 2021</h5>
</a>
<p className="mb-3 font-normal text-gray-700 dark:text-gray-400">Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.</p>
<a href="#" className="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
Read more
<svg className="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M1 5h12m0 0L9 1m4 4L9 9"/>
</svg>
</a>
</div>
</div>

</div>
<div className="container mx-auto p-4">
<h1 className="text-3xl font-bold mb-4">Blog Section</h1>
<div className="max-w-sm bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
<a href="#">
<img className="rounded-t-lg" src="/docs/images/blog/image-1.jpg" alt="" />
</a>
<div className="p-5">
<a href="#">
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Noteworthy technology acquisitions 2021</h5>
</a>
<p className="mb-3 font-normal text-gray-700 dark:text-gray-400">Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.</p>
<a href="#" className="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
Read more
<svg className="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M1 5h12m0 0L9 1m4 4L9 9"/>
</svg>
</a>
</div>
</div>

</div>

</div>
</>
)
}

export default BlogSection
Loading