Skip to content

Commit

Permalink
adeded validation in mobile input, added active style
Browse files Browse the repository at this point in the history
  • Loading branch information
shefali12-ab committed May 11, 2024
1 parent 27ce355 commit 3f35e6d
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ChartsMaps from "./pages/ChartsMaps";

import EditContactForm from "./components/EditContactForm";
import ContactForm from "./components/ContactForm";
import Sidebar from "./components/Sidebar";
import SideBar from "./components/SideBar";


function App() {
Expand All @@ -20,7 +20,7 @@ function App() {
{pathname == "/chart" ? "Charts And Maps" : "Contact Management App"}
</nav>
<div className="flex w-full ">
<Sidebar />
<SideBar />

<Routes>
<Route path="/" element={<Contacts />} />
Expand Down
26 changes: 14 additions & 12 deletions src/components/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import { useNavigate } from "react-router-dom";
import { addUser } from "../redux/UserReducer";

const ContactForm = () => {
const [firstname, setfirstname] = useState("");
const [lastname, setlastname] = useState("");
const [mobile, setmobile] = useState("");
const [status, setstatus] = useState("active");
const [firstName, setfirstName] = useState("");
const [lastName, setlastName] = useState("");
const [mobile, setMobile] = useState("");
const [status, setStatus] = useState("active");
const users = useSelector((state: any) => state.users);
const dispatch = useDispatch();
const navigate = useNavigate();
const handleSubmit = (e: { preventDefault: () => void }) => {
//console.log("clicked")
e.preventDefault();
dispatch(
addUser({ id: users.length, firstname, lastname, mobile, status })
addUser({ id: users.length, firstName, lastName, mobile, status })
);
navigate("/");
};
Expand All @@ -33,31 +33,33 @@ const ContactForm = () => {
type="text"
className="border-2 p-1 border-blue-500"
name="first_name"
value={firstname}
onChange={(e) => setfirstname(e.target.value)}
value={firstName}
onChange={(e) => setfirstName(e.target.value)}
/>
<input
placeholder="LastName"
type="text"
className="border-2 p-1 border-blue-500"
name="last_name"
value={lastname}
onChange={(e) => setlastname(e.target.value)}
value={lastName}
onChange={(e) => setlastName(e.target.value)}
/>
<input
placeholder="MobileNumber"
type="number"
type="tel"
maxLength={10}
className="border-2 p-1 border-blue-500"
name="mob"
value={mobile}
onChange={(e) => setmobile(e.target.value)}
onChange={(e) => setMobile(e.target.value)}

/>
<label>Status</label>
<select
className="w-full border border-gray-400 p-2 rounded-md"
name="status"
value={status}
onChange={(e) => setstatus(e.target.value)}
onChange={(e) => setStatus(e.target.value)}
>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
Expand Down
5 changes: 3 additions & 2 deletions src/components/EditContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ const EditContactForm = () => {
<input placeholder="LastName" type="text" className="border-2 p-1" value={ulastname} onChange={e=> setlastname(e.target.value)}/>
<input
placeholder="MobileNumber"
type="number"

type="tel"
maxLength={10}
className="border-2 p-1" value={umobile}
onChange={e=> setmobile(e.target.value)}

/>
<label>Status</label>

Expand Down
4 changes: 2 additions & 2 deletions src/components/Popup.tsx → src/components/PopUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface PopupProps {
close: Function;
el: User;
}
const Popup = ({ close, el }: PopupProps) => {
const PopUp = ({ close, el }: PopupProps) => {
return (
<div className="fixed top-0 text-black left-0 w-full h-full bg-opacity-20 bg-black flex items-center justify-center">
<div className="bg-white drop-shadow-md rounded-md p-4 w-mid">
Expand Down Expand Up @@ -41,4 +41,4 @@ const Popup = ({ close, el }: PopupProps) => {
);
};

export default Popup;
export default PopUp;
10 changes: 5 additions & 5 deletions src/components/Sidebar.tsx → src/components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { Link } from "react-router-dom";
import { FaChartLine } from "react-icons/fa";
import { MdContacts } from "react-icons/md";

const Sidebar = () => {
const SideBar = () => {
return (
<div className=" flex flex-col gap-6 w-60 h-screen border-r-2 p-3 ">
<h1 className="text-xl ">Dashboard</h1>

<div className="flex items-center gap-4">
<div className="flex items-center gap-4 hover:bg-blue-200 p-2 rounded">
<MdContacts className="text-2xl" />

<Link to="/" className="text-sm">
<Link to="/" className="text-sm " >
Contacts
</Link>
</div>

<div className="flex items-center gap-4">
<div className="flex items-center gap-4 hover:bg-blue-200 p-2 rounded">
<FaChartLine className="text-2xl" />

<Link to="/chart" className="text-sm">
Expand All @@ -27,4 +27,4 @@ const Sidebar = () => {
);
};

export default Sidebar;
export default SideBar;
4 changes: 2 additions & 2 deletions src/components/WorldMap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Marker, Popup } from "react-leaflet"
import L from 'leaflet';
import markerIcon from '../assets/marker_icon.png';
import L from "leaflet";
import markerIcon from "../assets/marker_icon.png";
const WorldMap=(countries:any)=>{

const {countriesData}=countries
Expand Down
18 changes: 9 additions & 9 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import React from "react"
import ReactDOM from "react-dom/client"
import App from "./App.tsx"
import "./index.css"

import { Provider } from 'react-redux'
import { QueryClient, QueryClientProvider } from 'react-query';
import { configureStore } from '@reduxjs/toolkit'
import { Provider } from "react-redux"
import { QueryClient, QueryClientProvider } from "react-query"
import { configureStore } from "@reduxjs/toolkit"

import UserReducer from './redux/UserReducer.ts'
import { BrowserRouter as Router} from 'react-router-dom'
import UserReducer from "./redux/UserReducer.ts"
import { BrowserRouter as Router} from "react-router-dom"

const store = configureStore({
reducer :{
Expand Down
10 changes: 5 additions & 5 deletions src/pages/ChartsMaps.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';
import { useQuery } from 'react-query';
import { useEffect } from "react";
import { useQuery } from "react-query";
import { Line } from "react-chartjs-2";
import 'leaflet/dist/leaflet.css';
import "leaflet/dist/leaflet.css";

import { MapContainer, TileLayer } from "react-leaflet";
import { CategoryScale, Chart as ChartJS, Legend, LineElement, LinearScale, PointElement, Title, Tooltip } from 'chart.js';
Expand Down Expand Up @@ -30,8 +30,8 @@ const ChartsMaps = () => {
fetchChartData();
fetchCountryData();
}, []);
console.log(chartData)
console.log(countriesData)
// console.log(chartData)
// console.log(countriesData)



Expand Down
4 changes: 2 additions & 2 deletions src/pages/Contacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { deleteUser } from "../redux/UserReducer";
import contact from "../assets/searchimg1.jpg";
import contactpfp from "../assets/icon-profile.png";

import Popup from "../components/Popup";
import PopUp from "../components/PopUp";


interface Contact {
Expand Down Expand Up @@ -77,7 +77,7 @@ const Contacts = () => {
/>
<div>
{isOpen && (
<Popup close={() => togglePopup( data )} el={singleContact } />
<PopUp close={() => togglePopup( data )} el={singleContact } />
)}

</div>
Expand Down

0 comments on commit 3f35e6d

Please sign in to comment.