Skip to content

Commit

Permalink
optimized and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshitPachori committed Jun 8, 2024
1 parent be9b7cd commit f75cfbe
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import CustomLoader from "@/components/CustomLoader";
import { useRouter } from "next/navigation";
import toast from "react-hot-toast";
import { convertMillisecondsToMinutesAndHours } from "@/utils/millisecondsToMinutes";
import { RideState } from "@/utils/slices/rideSlice";
const pages = () => {
const ride = useAppSelector((state) => state.driver);
const auth = useAppSelector((state) => state.auth);
Expand Down Expand Up @@ -42,13 +43,13 @@ const pages = () => {
{ride.completedRides.length === 0 ? (
<h1>No Completed rides</h1>
) : (
ride.completedRides.map((item) => (
ride.completedRides.map((item: RideState) => (
<div
className="relative flex flex-col lg:flex-row justify-between my-5 p-2 rounded-md shadow-lg border"
key={item?.id}
key={item?.rideId}
>
<div className="flex flex-col lg:flex-row items-center justify-between lg:gap-8 ">
<p>{item?.id}</p>
<p>{item?.rideId}</p>
<Image
src="https://cdn.pixabay.com/photo/2017/06/15/04/13/car-2404064_1280.png"
alt=""
Expand All @@ -70,7 +71,7 @@ const pages = () => {
</p>
<div>
<p className="text-center text-sm m-2">
Booked By : {item?.user.fullName}
Booked By : {item?.user?.fullName}
</p>
<div className="items-center text-center my-2">
<p className="text-xs sm:text-sm text-slate-600">
Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/app/ride/[id]/payment/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Layout from "@/components/Layout/Layout";
import PaymentPage from "@/components/Payment/PaymentPage";
import React from "react";

const page = ({ params }) => {
const page = ({ params }: any) => {
return <Layout children={<PaymentPage rideId={params.id} />} />;
};

Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/app/ride/[id]/payment/success/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Layout from "@/components/Layout/Layout";
import Success from "@/components/Payment/Success";
import React from "react";

const page = ({ params }) => {
const page = ({ params }: any) => {
return <Layout children={<Success rideId={params.id} />} />;
};

Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/app/rideDetail/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GuardComponent from "@/components/Auth/GuardComponent";
import Layout from "@/components/Layout/Layout";
import RideDetail from "@/components/RideDetail/RideDetail";

function page({ params }) {
function page({ params }: any) {
return (
<GuardComponent>
<Layout children={<RideDetail id={params.id} />} />
Expand Down
34 changes: 18 additions & 16 deletions ride_fast_frontend/components/BookRide/BookRide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function BookRide() {
{activeField === "pickupArea" &&
formik.values?.pickupArea?.length > 0 && (
<div className="absolute top-10 left-0 bg-white z-10 rounded-md p-2 border max-h-[50vh] w-full overflow-y-scroll shadow-md hide-scroll">
{suggestions.map((suggestion, index) => (
{suggestions.map((suggestion: any, index) => (
<div
key={index}
onClick={() => handleSelectSuggestion(suggestion)}
Expand Down Expand Up @@ -184,22 +184,24 @@ function BookRide() {
{activeField === "destinationArea" &&
formik.values?.destinationArea?.length > 0 && (
<div className="absolute top-10 left-0 bg-white z-10 rounded-md p-2 border max-h-[50vh] w-full overflow-y-scroll shadow-md hide-scroll">
{suggestions.map((suggestion, index) => (
<div
key={index}
onClick={() => handleSelectSuggestion(suggestion)}
className="flex items-center py-2 z-10 bg-white cursor-pointer"
>
<div className="pr-5">
<LocationOn />
{suggestions.map(
(suggestion: { display_name: any }, index) => (
<div
key={index}
onClick={() => handleSelectSuggestion(suggestion)}
className="flex items-center py-2 z-10 bg-white cursor-pointer"
>
<div className="pr-5">
<LocationOn />
</div>
<div>
<p className="font-semibold">
{suggestion?.display_name?.split()[0]}
</p>
</div>
</div>
<div>
<p className="font-semibold">
{suggestion?.display_name.split()[0]}
</p>
</div>
</div>
))}
)
)}
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/components/BookRide/SearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface SearchResultProps {
setActiveField: string;
latitude_key: string;
longitude_key: string;
item: object;
item: any;
}

function SearchResult({
Expand Down
4 changes: 1 addition & 3 deletions ride_fast_frontend/components/BookRide/SearchResultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import React from "react";
import LocationIcon from "@mui/icons-material/LocationOn";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
interface SearchCardProps {
item: {
display_name: string;
};
item: any;
areaKey: string;
setActiveField: string;
latitude_key: string;
Expand Down
6 changes: 3 additions & 3 deletions ride_fast_frontend/components/Company/CompanyDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const CompanyDashboard = () => {
</div>
)}
{userData.length !== 0 &&
userData.map((user) => (
userData.map((user: any) => (
<div
className="shadow-lg px-10 py-5 my-5 border border-slate-300 rounded-md flex items-center justify-between bg-slate-100"
key={user.id}
Expand All @@ -136,7 +136,7 @@ const CompanyDashboard = () => {
{driverData.length === 0 ? (
<h1>No Driver there</h1>
) : (
driverData.map((driver) => (
driverData.map((driver: any) => (
<div
className="shadow-lg px-10 py-5 my-5 border border-slate-300 rounded-md flex flex-col lg:flex-row gap-8 justify-center items-center lg:justify-between bg-slate-100"
key={driver.id}
Expand Down Expand Up @@ -229,7 +229,7 @@ const CompanyDashboard = () => {
{rideData.length === 0 ? (
<h1>No Rides are there</h1>
) : (
rideData.map((ride) => (
rideData.map((ride: any) => (
<div
className="shadow-lg px-10 py-5 my-5 border border-slate-300 rounded-md flex flex-col lg:flex-row gap-8 justify-center items-center lg:justify-between bg-slate-100"
key={ride.id}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Image from "next/image";
import React from "react";

const AllocatedRideCard = ({ ride, type }: { type: string; ride: {} }) => {
const AllocatedRideCard = ({ ride, type }: { type: string; ride:any }) => {
return (
<div className=" px-5 py-5 ">
<h1 className="mb-5 font-semibold text-xl text-center">Ride Details</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const AllocatedRides = () => {
{ride.allocatedRides.length === 0 ? (
<h1>No Allocated Rides</h1>
) : (
ride.allocatedRides.map((item, idx) => (
ride.allocatedRides.map((item:any, idx) => (
<div
className="flex flex-col lg:flex-row justify-between my-5 p-2 rounded-md shadow-lg border"
key={idx + item.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const CurrentRides = () => {
{driver.currentRides.length === 0 ? (
<h1>No Current Rides</h1>
) : (
driver.currentRides.map((item) => (
driver.currentRides.map((item:any) => (
<div
className="flex flex-col lg:flex-row justify-between"
key={item?.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const StartedRide = () => {
{driver.startedRides.length === 0 ? (
<h1>No Started Rides</h1>
) : (
driver.startedRides.map((item) => (
driver.startedRides.map((item:any) => (
<div
className="flex flex-col lg:flex-row justify-between"
key={item?.id}
Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/components/Payment/PaymentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const PaymentPage = ({ rideId }: { rideId: number }) => {
const token = useAppSelector((state) => state.auth.token);
const dispatch = useAppDispatch();
const router = useRouter();
const [myRide, setMyRide] = useState({});
const [myRide, setMyRide] = useState<any>({});
useEffect(() => {
const dispatchgetride = async () => {
if (token) {
Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/components/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Profile() {
<p className="">{auth?.user?.mobile}</p>
</div>
<div className="rounded-sm border mt-5">
{ride.map((item) => (
{ride.map((item:any) => (
<RideCar ride={item} key={item?.id} />
))}
<div className="flex flex-col items-center">
Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/components/Ride/RideCar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from "react";
import { Verified } from "@mui/icons-material";
import { Avatar } from "@mui/material";

function RideCar({ ride }: { ride: {} }) {
function RideCar({ ride }: { ride: any }) {
const router = useRouter();
return (
<div
Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/components/Ride/Rides.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function Rides() {
No Completed Rides...
</h1>
) : (
completedRide.map((item, idx) => (
completedRide.map((item:any, idx) => (
<div
key={idx}
className="flex justify-between items-center shadow-md rounded-s-sm p-3 cursor-pointer"
Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/components/RideDetail/RideDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function RideDetail({ id }: { id: number }) {
const ride = useAppSelector((state) => state.ride);
const token = auth.token;
useEffect(() => {
let intervalId;
let intervalId: NodeJS.Timeout;
if (token) {
// dispatch(userProfile(token));
const dipatchgetRide = async () => {
Expand Down
2 changes: 1 addition & 1 deletion ride_fast_frontend/utils/millisecondsToMinutes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function convertMillisecondsToMinutesAndHours(seconds) {
export function convertMillisecondsToMinutesAndHours(seconds: any) {
// if (milliseconds < 1000) return milliseconds + " milli sec";
// let seconds = Math.floor(milliseconds / 1000);
// let minutes = Math.floor(seconds / 60);
Expand Down
7 changes: 6 additions & 1 deletion ride_fast_frontend/utils/slices/rideSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ interface Driver {
longitude: number;
role: string;
password: string;
vehicle: {
company: string;
model: string;
licensePlate:string
};
}
interface RideState {
export interface RideState {
rideId: number;
isLoading: boolean;
error: SerializedError | string | null;
Expand Down

0 comments on commit f75cfbe

Please sign in to comment.