Skip to content

Commit

Permalink
Merge pull request #37 from danial117/client_dev_36
Browse files Browse the repository at this point in the history
commited
  • Loading branch information
danial117 authored Sep 10, 2024
2 parents 65e0ad6 + 593b05d commit e6259f5
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 33 deletions.
Binary file removed public/assets/linkedin.png
Binary file not shown.
Binary file removed public/assets/twitter.png
Binary file not shown.
6 changes: 3 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="%PUBLIC_URL%/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
Expand All @@ -13,7 +13,7 @@
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand All @@ -28,7 +28,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Infovit</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file added public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 23 additions & 3 deletions src/scenes/Address.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useSelector,useDispatch } from "react-redux";
import { EditRounded } from "@mui/icons-material";
import { removeItemFromCart } from "../state";
import SpinnerRotating from "../skeleton/spinner";
import { useNavigate } from "react-router-dom";


const states = [
Expand Down Expand Up @@ -98,7 +99,24 @@ const states = [
NH: ['Manchester', 'Nashua', 'Concord', 'Derry', 'Rochester', 'Salem', 'Dover', 'Merrimack', 'Hudson', 'Londonderry'],
NJ: ['Newark', 'Jersey City', 'Paterson', 'Elizabeth', 'Edison', 'Woodbridge', 'Lakewood', 'Toms River', 'Hamilton', 'Trenton'],
NM: ['Albuquerque', 'Las Cruces', 'Rio Rancho', 'Santa Fe', 'Roswell', 'Farmington', 'Clovis', 'Hobbs', 'Alamogordo', 'Carlsbad'],
NY: ['New York City', 'Buffalo', 'Rochester', 'Yonkers', 'Syracuse', 'Albany', 'New Rochelle', 'Mount Vernon', 'Schenectady', 'Utica'],
NY: [
"New York City", "Albany", "Buffalo", "Rochester", "Syracuse", "Yonkers", "Schenectady",
"Mount Vernon", "Troy", "Niagara Falls", "Binghamton", "Utica", "White Plains",
"New Rochelle", "Ithaca", "Poughkeepsie", "Jamestown", "Rome", "Peekskill",
"Lockport", "Kingston", "Batavia", "Plattsburgh", "Glens Falls", "Auburn", "Elmira",

// Smaller towns and villages
"Amherst", "Huntington", "Hempstead", "Clarkstown", "Greenburgh", "Cheektowaga",
"Ramapo", "Irondequoit", "Tonawanda", "North Hempstead", "Greece", "Perinton",
"Babylon", "Union", "Smithtown", "Orangetown", "Hamburg", "Colonie", "Henrietta",

// Even smaller locations and hamlets
"Cortland", "Oneonta", "Ogdensburg", "Massena", "Fulton", "Gloversville", "Oswego",
"Geneva", "Watertown", "Canandaigua", "Beacon", "Tarrytown", "Medina", "Endicott",
"West Seneca", "Lackawanna", "Corning", "Malone", "Canton", "Fredonia",
"Jamesville", // Adding Jamesville
"Cazenovia", "Dansville", "Skaneateles", "Delhi", "Wappingers Falls"
],
NC: ['Charlotte', 'Raleigh', 'Greensboro', 'Durham', 'Winston-Salem', 'Fayetteville', 'Cary', 'Wilmington', 'High Point', 'Asheville'],
ND: ['Fargo', 'Bismarck', 'Grand Forks', 'Minot', 'West Fargo', 'Mandan', 'Dickinson', 'Jamestown', 'Williston', 'Wahpeton'],
OH: ['Columbus', 'Cleveland', 'Cincinnati', 'Toledo', 'Akron', 'Dayton', 'Parma', 'Canton', 'Youngstown', 'Lorain'],
Expand Down Expand Up @@ -151,7 +169,8 @@ const Address=()=>{
const [showDropdown, setShowDropdown] = useState(false);
const [cities, setCities] = useState([]);
const [edit,setEdit]=useState(false);
const [loading,setLoading]=useState(false)
const [loading,setLoading]=useState(false);
const navigate=useNavigate()

useEffect(()=>{
try{
Expand Down Expand Up @@ -327,7 +346,8 @@ const Address=()=>{
api.get('/order/tax').then((response)=>{
if(response.status === 200 || response.status=== 404 ){

window.location.href='/order'
navigate('/order',{replace:true})
window.location.reload()
}
}) }else{
window.location.href='/createAccount'
Expand Down
20 changes: 10 additions & 10 deletions src/scenes/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ const Footer=()=>{


<div className="flex flex-col gap-y-2">
<p className="font-bold text-white text-lg font-Lexend">Quick links</p>
<p className="text-white font-Poppins text-xs">HomePage</p>
<p className="text-white font-Poppins text-xs">Pro</p>
<p className="text-white font-Poppins text-xs">Contacts</p>
<p className="text-white font-Poppins text-xs">Info</p>
<p className="font-bold text-white text-lg font-Lexend">Quick links</p>
<p onClick={()=>{window.location.href='/'}} className="text-white cursor-pointer font-Poppins text-xs">HomePage</p>
<p onClick={()=>{window.location.href='/createAccount'}} className="text-white cursor-pointer font-Poppins text-xs">Account</p>
<p onClick={()=>{window.location.href='/contact'}} className="text-white cursor-pointer font-Poppins text-xs">Contacts</p>
<p onClick={()=>{window.location.href='/about'}} className="text-white cursor-pointer font-Poppins text-xs">Info</p>

</div>


<div className="flex flex-col gap-y-2">
<p className="font-bold text-white text-lg font-Lexend">About us</p>
<p className="text-white font-Poppins text-xs">Order</p>
<p className="text-white font-Poppins text-xs">Purchase</p>
<p className="text-white font-Poppins text-xs">Privacy Policy</p>
<p className="text-white font-Poppins text-xs">Terms of Sales</p>
<p onClick={()=>{window.location.href='/about'}} className="font-bold cursor-pointer text-white text-lg font-Lexend">About us</p>
<p onClick={()=>{window.location.href='/order'}} className="text-white cursor-pointer font-Poppins text-xs">Order</p>
<p onClick={()=>{window.location.href='/userOrders'}} className="text-white cursor-pointer font-Poppins text-xs">Purchase</p>
<p onClick={()=>{window.location.href='/'}} className="text-white cursor-pointer font-Poppins text-xs">Privacy Policy</p>
<p onClick={()=>{window.location.href='/'}} className="text-white cursor-pointer font-Poppins text-xs">Terms of Sales</p>

</div>

Expand Down
39 changes: 36 additions & 3 deletions src/scenes/NavBar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { KeyboardArrowDownRounded,ShoppingCartRounded,MenuRounded,CloseRounded,AccountCircle } from "@mui/icons-material";
import { KeyboardArrowDownRounded,ShoppingCartRounded,MenuRounded,CloseRounded,AccountCircle, DisplaySettings } from "@mui/icons-material";
import { useEffect, useState,useContext } from "react";
import Cart from "../widget/Cart";
import { useMediaQuery } from "@mui/material";
Expand Down Expand Up @@ -28,6 +28,8 @@ const NavBar=()=>{
const navigate=useNavigate()
const isMobileCategories = useMediaQuery('(min-width:1024px)');
const { cart, toggleCart } = useContext(CartContext);
const cartItems=useSelector((state)=>state.cartItems);
const [totalCartItems,setTotalCartItems]=useState(false)
const dispatch=useDispatch()
const [categories,setCategories]=useState(false)
const location = useLocation();
Expand All @@ -40,6 +42,16 @@ const NavBar=()=>{
const [anchorEl, setAnchorEl] = useState(null);


useEffect(()=>{

if(cartItems.length !==0 ){
setTotalCartItems(cartItems.length)
}else{
setTotalCartItems(false)
}


},[cartItems,dispatch])



Expand Down Expand Up @@ -88,7 +100,19 @@ const NavBar=()=>{
}

{isMobile && <div className="basis-[20%] md:max-lg:basis-[30%] md:max-lg:justify-end justify-end md:max-lg:gap-x-6 w-full gap-x-8 flex flex-row py-2 ml-auto mr-[4px]">
<ShoppingCartRounded onClick={toggleCart} style={{cursor:'pointer',fontSize:30,margin:'auto 0'}}/>

<div onClick={toggleCart} className="relative cursor-pointer my-auto">
<div className='absolute -top-[2px] right-0'>
{totalCartItems && <p className="text-top bg-black py-[1px] px-[6px] rounded-full font-bold mb-4 text-red-500 text-xs font-Lexend">{totalCartItems}</p> }

</div>


<ShoppingCartRounded style={{cursor:'pointer',fontSize:30,margin:'auto 0'}}/>

</div>


{!accessToken && <button onClick={()=>{window.location.href='/createAccount'}} className="px-4 md:max-lg:text-[12px] md:max-lg:px-2 text-emerald-600 border-2 border-emerald-300 rounded-md text-sm font-Poppins">
Sign Up
</button>}
Expand Down Expand Up @@ -132,7 +156,16 @@ const NavBar=()=>{
<div className="my-auto">
<div className="flex mr-2 flex-row gap-x-4">

<ShoppingCartRounded onClick={toggleCart} style={{cursor:'pointer'}}/>
<div onClick={toggleCart} className="relative cursor-pointer my-auto">
<div className='absolute -top-[2px] right-0'>
{totalCartItems && <p className="text-top bg-black py-[1px] px-[6px] rounded-full font-bold mb-4 text-red-500 text-xs font-Lexend">{totalCartItems}</p> }

</div>


<ShoppingCartRounded style={{cursor:'pointer',fontSize:30,margin:'auto 0'}}/>

</div>
{!accessToken &&
<button onClick={()=>{window.location.href='/createAccount'}} className="px-4 md:max-lg:text-[12px] md:max-lg:px-2 text-emerald-600 border-2 border-emerald-300 py-[4px] rounded-md text-sm font-Poppins">
Sign Up
Expand Down
26 changes: 13 additions & 13 deletions src/scenes/SignUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,27 +189,27 @@ const SignUp = () => {
window.location.href = '/';
});
} else {
const response=await fetch(`${process.env.REACT_APP_API_URL}/user/signup`, {
const response=await fetch(`${process.env.REACT_APP_API_URL}/user/signup`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify(formData),
})
.then((response) => response.json())
.then((data) => {
dispatch(setUser({ user: data.userData }));
dispatch(setAccessToken({ accessToken: data.accessToken }));

});


if(response){
if(response.status===201 && response.data) {

if(response.status===201) {

const data=await response.json()

dispatch(setUser({ user: data.userData }));
dispatch(setAccessToken({ accessToken: data.accessToken }));
UserRegisterationEvent()
response.data.items.map((item)=>{
dispatch( addItemToCart({product:item.product,quantity:item.quantity}))
})

const dispatchPromises = [];
cartItems.forEach((product) => {
cartItems.forEach((product) => {

dispatchPromises.push(dispatch(addItemToCartAsync({ product:product,quantity:product.quantity })));
});

Expand Down Expand Up @@ -238,7 +238,7 @@ const SignUp = () => {
}catch (error) {
alert('An error occured during signup')
setLoading(false)
// Handle error if needed

} finally {
setLoading(false);
window.location.href = '/';
Expand Down
2 changes: 1 addition & 1 deletion src/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const initialState = {
export const addItemToCartAsync = createAsyncThunk(
'auth/addItemToCartAsync',
async ({ product, quantity }, { getState,dispatch }) => {

const state = getState();

if (state.accessToken) {
Expand Down

0 comments on commit e6259f5

Please sign in to comment.