Skip to content

Commit

Permalink
fix: types errors and file names
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadshakkeerp committed Jul 17, 2024
1 parent 162cfa9 commit cbb3fd4
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 38 deletions.
Binary file added public/imgs/shopeaseLogo.webp
Binary file not shown.
29 changes: 17 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { FC, Suspense, useEffect, useState } from "react";
import { Footer, Header, PopupCard } from "./paths";
import { Route, Routes } from "react-router-dom";
import { ProductDetailsProps } from "./assets/types";
import { useSelector } from "react-redux";
import { DarkState } from "./redux/store";
import { Account, Cart, ChatBot, Checkout, Home, NestedHoverNavlink, PaymentSuccessful, ProductDatails, ProductGallery, ProductsGroup } from "./optimazation/AppOptimazation";
import { Account, Cart, ChatBot, Checkout, Home, NestedHoverNavlink, PaymentSuccessful, ProductGallery, ProductsGroup, ProductDetails } from "./optimazation/AppOptimazation";
import { ProductProps } from "./types/productTypes";


const App: FC<ProductDetailsProps> = () => {
const App: FC<ProductProps> = () => {
const [showPopUp, setShowPopUp] = useState(false);

const DarkMode = useSelector((state: { dark: DarkState }) => state?.dark)
// after 4 sec of initial loading
useEffect(() => {
Expand All @@ -25,6 +24,18 @@ const App: FC<ProductDetailsProps> = () => {
return () => clearTimeout(timeOut);
}, []);


const productDetails: ProductProps = {
id: 0,
title: "",
img: "",
offerAvailable: false,
price: 0,
quantity: 0,
cart: [],
thumbImg: ""
}

return (
<div className={`${DarkMode?.isEnabled ? "dark:bg-darkModeBg text-darkModeText" : "bg-white"} relative`}>
{showPopUp && <PopupCard setShowPopUp={setShowPopUp} />}
Expand All @@ -35,14 +46,8 @@ const App: FC<ProductDetailsProps> = () => {
<Route
path="/productDetails/:id"
element={
<ProductDatails
id={0}
title={""}
img={""}
offerAvailable={false}
price={0}
quantity={0}
cart={[]}
<ProductDetails
{...productDetails}
/>
}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/assets/HeaderCatogoryData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { headerCategoriesProps } from "./types";
import { headerCategoriesProps } from "../types/layoutTypes";

export const headerCategories:headerCategoriesProps= [
{
Expand Down
2 changes: 1 addition & 1 deletion src/assets/footerUtility.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FooterDataProps } from "./types";
import { FooterDataProps } from "../types/layoutTypes";

export const footerData: FooterDataProps = {
aboutShopEase: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomProductsRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useState, useEffect, useRef, WheelEvent, FC } from "react";
import { useSelector } from "react-redux";
import { RootState } from "../redux/store";
import React from "react";
import { ProductProps } from "../types/globalTypes";
import { ProductProps } from "../types/productTypes";

interface RowProps {
title: string | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { footerData, footerLinks } from "../assets/footerUtility";
import { FooterDataProps } from "../assets/types";
import { FooterDataProps } from "../types/layoutTypes";
import { Link } from "react-router-dom";

export const Footer: React.FC<FooterDataProps> = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
headerMoreBtnData,
searchIcon,
} from "../assets/globalUtlities";
import logo from "/dist/shopeaseLogo.webp";
import logo from "/imgs/shopeaseLogo.webp";
import { BiChevronDown } from "react-icons/bi";
import { AiOutlineHome } from "react-icons/ai";
import { PiDotsThreeVerticalBold } from "react-icons/pi";
Expand Down
4 changes: 2 additions & 2 deletions src/components/HeaderCatogory.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BiChevronDown } from "react-icons/bi";
import { FC, useState } from "react";
import { headerCategories } from "../assets/HeaderCatogoryData";
import { HeaderCategory, SubCategory } from "../assets/types";
import { headerCategories } from "../assets/headerCatogoryData";

Check failure on line 3 in src/components/HeaderCatogory.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Cannot find module '../assets/headerCatogoryData' or its corresponding type declarations.
import { HeaderCategory, SubCategory } from "../types/layoutTypes";
import { Link } from "react-router-dom";
import { RootState } from "../redux/store";
import { useSelector } from "react-redux";
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProductCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from "react-router-dom";
import { ProductProps } from "../types/globalTypes";
import { ProductProps } from "../types/productTypes";

const ProductCard = ({
product,
Expand Down
18 changes: 9 additions & 9 deletions src/components/ProductDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { useState, FC, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux/es/exports";
import { Link, useParams } from "react-router-dom";
import { rowProductsData } from "../assets/globalUtlities";
import { ProductDetailsProps, } from "../assets/types";
// import { ProductDetailsProps, } from "../types/layoutTypes";
import { CartState, RootState } from "../redux/store";
import { ProductProps } from "../types/globalTypes";
import { ProductProps } from "../types/productTypes";
import { MdLocalOffer, MdLocationSearching, MdOutlineDelete } from "react-icons/md";
import { BsHeart } from "react-icons/bs";
import { RiEditBoxLine } from "react-icons/ri";
import { addToCart } from "../redux/actions/cartActions";

const ProductDatails: FC<ProductDetailsProps & ProductProps[]> = () => {
const ProductDetails: FC<ProductProps> = () => {
const { id } = useParams();
const dispatch = useDispatch();
const darkMode = useSelector((state: RootState) => state?.dark)
Expand Down Expand Up @@ -57,12 +57,12 @@ const ProductDatails: FC<ProductDetailsProps & ProductProps[]> = () => {
<BsHeart className="" />
</span>
<div className="fixed w-full md:w-auto bottom-0 md:static md:flex gap-4 justify-center mt-2">
<button className="bg-[#ff9f00] px-6 py-3 tracking-wider font-semibold w-1/2 md:w-auto text-white rounded-lg shadow-md transition duration-300 hover:bg-[#e69100]"
<button type="button" title="click to buy" className="bg-[#ff9f00] px-6 py-3 tracking-wider font-semibold w-1/2 md:w-auto text-white rounded-lg shadow-md transition duration-300 hover:bg-[#e69100]"
onClick={() => dispatch(addToCart(item.id))}
>
Add To Cart
</button>
<button className="bg-[#fb641b] px-6 py-3 tracking-wider font-semibold w-1/2 md:w-auto text-white rounded-lg shadow-md transition duration-300 hover:bg-[#e64a19]">
<button type="button" title="click to buy" className="bg-[#fb641b] px-6 py-3 tracking-wider font-semibold w-1/2 md:w-auto text-white rounded-lg shadow-md transition duration-300 hover:bg-[#e64a19]">
<Link to={`/productDetails/${item.id}/checkout`} >
Buy Now

Expand Down Expand Up @@ -208,7 +208,7 @@ const ProductDatails: FC<ProductDetailsProps & ProductProps[]> = () => {
onChange={(e) => setUserReview(e.target.value)}
className="w-full p-2 border border-gray-300 rounded-md outline-none focus:border-primary"
/>
<button
<button type="submit"
onClick={handleReviewSubmit}
className="mt-2 px-4 py-2 bg-primary text-white rounded-md hover:bg-primary-dark transition-colors duration-300"
>
Expand All @@ -222,8 +222,8 @@ const ProductDatails: FC<ProductDetailsProps & ProductProps[]> = () => {
reviews.map((review, index) => (
<div key={index} className="border-b border-gray-200 p-4 flex justify-between">
<p className="text-sm">{review}</p>
<span><button title="click to edit"><RiEditBoxLine /></button>
<button title="click to delete"><MdOutlineDelete /></button></span>
<span><button type="button" title="click to edit"><RiEditBoxLine /></button>
<button type="button" title="click to delete"><MdOutlineDelete /></button></span>
</div>
))
)}
Expand All @@ -236,4 +236,4 @@ const ProductDatails: FC<ProductDetailsProps & ProductProps[]> = () => {
);
};

export default ProductDatails
export default ProductDetails
2 changes: 1 addition & 1 deletion src/components/ProductGroupsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { headerCategories } from "../assets/HeaderCatogoryData"
import { headerCategories } from "../assets/headerCatogoryData"

Check failure on line 1 in src/components/ProductGroupsTab.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Cannot find module '../assets/headerCatogoryData' or its corresponding type declarations.

export const ProductGroupsTab = () => {
return (
Expand Down
3 changes: 1 addition & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
img={""}
offerAvailable={false}
price={0}
quantity={0}
/>
quantity={0} thumbImg={""} />
</BrowserRouter>
</ApolloProvider>
</Provider>
Expand Down
4 changes: 2 additions & 2 deletions src/optimazation/AppOptimazation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const NestedHoverNavlink = lazy(
() => import("../components/NestedHoverNavlink")
);
const ProductGallery = lazy(() => import("../pages/ProductGallery"));
const ProductDatails = lazy(() => import("../components/ProductDetails"));
const ProductDetails = lazy(() => import("../components/ProductDetails"));
const Checkout = lazy(() => import("../components/Checkout"));
const PaymentSuccessful = lazy(() => import("../components/PaymentSuccesfull"));
const ChatBot = lazy(() => import("../components/chatbot/ChatBot"));
Expand All @@ -20,7 +20,7 @@ export {
ProductsGroup,
NestedHoverNavlink,
ProductGallery,
ProductDatails,
ProductDetails,
Checkout,
PaymentSuccessful,
ChatBot,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Cart.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { RootState } from "../redux/store";
import { RowProductsProps } from "../assets/types";
import { RowProductsProps } from "../types/layoutTypes";
import { removeToCart } from "../redux/actions/cartActions";

type CartProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, } from "react";
import { HeaderCategory } from "../assets/types";
import { HeaderCategory } from "../types/layoutTypes";
import {
Ad,
CustomProductsRows,
Expand Down
2 changes: 1 addition & 1 deletion src/redux/actions/dataAction.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FetchProducts } from "../../types/globalTypes";
import { FetchProducts } from "../../types/productTypes";
// Action Types
export const FETCH_DATA_REQUEST = "FETCH_DATA_REQUEST";
export const FETCH_DATA_SUCCESS = "FETCH_DATA_SUCCESS";
Expand Down
1 change: 1 addition & 0 deletions src/redux/reducers/axiosFetchData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const fetchProductData = createAsyncThunk("product/fetchData", async () =
])

const _products = productsResponse.data.products
console.log(_products)
const categories = categoriesResponse.data

const newCategoryMap: CategoryMap = {};
Expand Down
2 changes: 1 addition & 1 deletion src/redux/reducers/cartReducer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rowProductsData } from "../../assets/globalUtlities";
import { ProductProps } from "../../types/globalTypes";
import { ProductProps } from "../../types/productTypes";
import { CartFunctionType, CartAction } from "../actions/cartActions";

export interface CartState {
Expand Down
3 changes: 3 additions & 0 deletions src/assets/types.ts → src/types/layoutTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ProductProps } from "./productTypes";

type SubItem = {
name: string;
id: string;
Expand Down Expand Up @@ -32,6 +34,7 @@ type ProductDetailsProps = {
price: number;
quantity: number;
offerAvailable: boolean;
cart?:ProductProps[]
};
interface FooterDataItem {
heading: string;
Expand Down
1 change: 1 addition & 0 deletions src/types/globalTypes.ts → src/types/productTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface ProductProps {
thumbImg:string;
img: string | undefined;
price: number;
quantity?:number;
offerAvailable: boolean;
cart?: ProductProps[];
}
Expand Down

0 comments on commit cbb3fd4

Please sign in to comment.