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

last play.. #79

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added client/src/assets/chatback.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions client/src/components/Farmer/FDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@



function Box({ data, showSecondaryBox }) {

Check failure on line 11 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'data' is missing in props validation

Check failure on line 11 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'showSecondaryBox' is missing in props validation
return (
<div className={styles['box-primary']}>
<div className={styles['primary-details']}>
<p>{data.profile?.displayName || 'N/A'} {data.profile?.lname || ''}</p>

Check failure on line 15 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'data.profile' is missing in props validation

Check failure on line 15 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'data.profile.displayName' is missing in props validation

Check failure on line 15 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'data.profile' is missing in props validation

Check failure on line 15 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'data.profile.lname' is missing in props validation
<p>Phone: {data.profile?.phone || 'N/A'}</p>

Check failure on line 16 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'data.profile' is missing in props validation

Check failure on line 16 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'data.profile.phone' is missing in props validation
<p className={styles.emu}>Email : {data.profile?.email || 'N/A'}</p>

Check failure on line 17 in client/src/components/Farmer/FDashboard.jsx

View workflow job for this annotation

GitHub Actions / Lint Client Code

'data.profile' is missing in props validation
<p>State: {data.address?.state || 'N/A'}</p>
</div>
<div className={styles['primary-btn']}>
Expand Down Expand Up @@ -176,6 +176,13 @@

function FDashboard() {
const [searchQuery,setSearchQuery] = useState('');
const {currentUser} = useAuth();
const navigate = useNavigate();
useEffect(() => {
if(currentUser === null){
navigate('/abc');
}
},[currentUser,navigate]);

return (
<div className={styles.dashbody}>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Farmer/FDashboard.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ body {
}
.primary-details {
width: 70%;
font-size: 22px;
font-size: 20px;
/* padding: 30px;
line-height: 25px; */
display: flex;
Expand Down
65 changes: 64 additions & 1 deletion client/src/components/Farmer/FarmNav.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useContext } from 'react';
import { useState, useEffect, useContext,useRef } from 'react';
import styles from './FarmSell.module.css'; // Assuming you're using CSS Modules
import { toast, ToastContainer } from 'react-toastify';
import { auth } from '../../../firebase';
Expand All @@ -7,6 +7,11 @@ import { useNavigate, useLocation } from 'react-router-dom'; // Import useLocati
import { doc, getDoc } from 'firebase/firestore';
import { db } from '../../../firebase';
import { AuthContext } from '../context/auth_context';
import { useTranslation } from 'react-i18next';
import { IoIosArrowDropdown, IoIosArrowDropup } from 'react-icons/io';
import { MdOutlineTranslate } from 'react-icons/md';



function ProfileIcon() {
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
Expand Down Expand Up @@ -49,6 +54,7 @@ function ProfileIcon() {
}
};


return (
<div className={styles.profileicon}>
<div onClick={toggleDropdown} className={styles.profilebutton}>
Expand Down Expand Up @@ -90,13 +96,70 @@ function Navbar() {
navigate(path);
};

const { i18n } = useTranslation();
const { t } = useTranslation();
const [dropdownOpen, setDropdownOpen] = useState(false);
const [language, setLanguage] = useState('Eng');
const dropdownRef = useRef(null);

useEffect(() => {
function handleClickOutside(event) {
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
setDropdownOpen(false);
}
}
// const cachedLanguage = localStorage.getItem('language') || i18n.language;
// setLanguage(cachedLanguage === 'en' ? 'Eng' : cachedLanguage === 'kn' ? 'ಕನ್ನಡ' : 'हिंदी');
// i18n.changeLanguage(cachedLanguage); // Apply cached language if it exists
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
// }, [dropdownRef,i18n]);
}, [dropdownRef]);


return (
<header className={styles.headfs}>
<div className={styles.navp}>
<div className={styles.h1nav}>
<h1>Krishi</h1>
<h1 id={styles.h1e}>Seva</h1>
</div>
<div ref={dropdownRef} className="relative">
<div
onClick={() => setDropdownOpen(!dropdownOpen)}
className="cursor-pointer flex items-center justify-center gap-2 hover:bg-slate-300 p-2 rounded"
>
<MdOutlineTranslate />
{language}
{dropdownOpen ? <IoIosArrowDropdown /> : <IoIosArrowDropup />}
</div>
{dropdownOpen && (
<div className="absolute left-0 mt-2 w-24 bg-white border rounded shadow-md">
<ul className="py-1">
<li
className="px-4 py-2 hover:bg-slate-100 cursor-pointer"
// onClick={() => changeLanguage('en')}
>
English
</li>
<li
className="px-4 py-2 hover:bg-slate-100 cursor-pointer"
// onClick={() => changeLanguage('kn')}
>
ಕನ್ನಡ
</li>
<li
className="px-4 py-2 hover:bg-slate-100 cursor-pointer"
// onClick={() => changeLanguage('hi')}
>
हिंदी
</li>
</ul>
</div>
)}
</div>
<ProfileIcon />
</div>
<div className={styles.navs}>
Expand Down
49 changes: 26 additions & 23 deletions client/src/components/Farmer/FarmSell.jsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,43 @@
import styles from './FarmSell.module.css';
import cropData from './cropsData.json';
import { useState } from 'react';
import { useState,useEffect } from 'react';
import { collection, addDoc, doc,setDoc} from 'firebase/firestore';
import { db } from '../../../firebase';
import { useAuth } from '../context/auth_context';
import { ToastContainer, toast } from 'react-toastify';
import { useNavigate } from 'react-router-dom';
import Navbar from './FarmNav';

function Box({ crop }) {
function Box({ crop, onCropSelect }) {
return (
<div className={styles['box-crop']}>
<div className={styles['box-crop']} onClick={() => onCropSelect(crop)}>
<img src={crop.imageUrl} alt={crop.name} />
<div className={styles['radio-button']}>
<label>
<input type="radio" name="crop" value={crop.name} />
<input
type="radio"
name="crop"
value={crop.name}
className={styles.rad}
checked={false} // Remove the checked attribute to avoid radio button interference
onChange={() => onCropSelect(crop)} // Update crop selection on radio button change
/>
{' ' + crop.name}
</label>
</div>
</div>
);
}

function Details({ crops, setSelectedCrop, handleInputChange }) {
return (
<div className={styles['details-box']}>
<div className={styles['image-box']}>
{crops.map((crop, index) => (
<div
<Box
key={index}
className={styles['box-crop']}
onClick={() => setSelectedCrop(crop)}
>
<img src={crop.imageUrl} alt={crop.name} />
<div className={styles['radio-button']}>
<label>
<input
type="radio"
name="crop"
value={crop.name}
onChange={() => setSelectedCrop(crop)}
/>
{' ' + crop.name}
</label>
</div>
</div>
crop={crop}
onCropSelect={setSelectedCrop}
/>
))}
</div>
<div className={styles.formbox}>
Expand Down Expand Up @@ -203,6 +197,15 @@ function Search({ searchQuery, setSearchQuery, handleSearch }) {
}

function FarmSell() {

const {currentUser} = useAuth();
const navigate = useNavigate();
useEffect(() => {
if(currentUser === null){
navigate('/abc');
}
},[currentUser,navigate]);

const [searchQuery, setSearchQuery] = useState('');
const [filteredCrops, setFilteredCrops] = useState(cropData.crops);
const [selectedCrop, setSelectedCrop] = useState(null);
Expand All @@ -217,7 +220,7 @@ function FarmSell() {
pincode: '',
});

const { currentUser } = useAuth(); // Get the current user from AuthContext
// const { currentUser } = useAuth();

const handleSearch = () => {
const filtered = cropData.crops.filter((crop) =>
Expand Down
10 changes: 8 additions & 2 deletions client/src/components/Farmer/FarmSell.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ body {
align-items: center;
justify-content: space-between; */
display: grid;
grid-template-columns: 3.5fr 0.4fr;
grid-template-columns: 3.5fr 0.4fr 0.4fr;
align-items: center;
border: 0.5px solid rgb(159, 159, 159);
}
Expand Down Expand Up @@ -237,6 +237,10 @@ body {
border-radius: 0.3rem;
box-shadow: 2px 2px 2px rgba(8, 0, 0, 0.4);
}
.box-crop:hover{
box-shadow: 4px 4px 4px rgba(61, 161, 31, 0.4);

}
.box-crop img {
width: 100%;
height: 80%;
Expand Down Expand Up @@ -405,4 +409,6 @@ border-color: yellowgreen;
color: #00B207;
}
/* `````````````````````````````````````` */

.rad{
display: none;
}
8 changes: 6 additions & 2 deletions client/src/components/Negotiate/chat.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@
.chat{
display: flex;
flex-direction: column;
background-color: rgb(228, 226, 226);
background-color: #fefefe;
border: 1px solid rgba(128, 128, 128, 0.267);
}
.clientpfp{
height:7.4vh;
width: 76vw;
text-align: center;
padding: 8px;
background-color: whitesmoke;
background-color: #fefefe;
border: 1px solid rgba(128, 128, 128, 0.267);
font-size: 25px;
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -106,6 +108,7 @@
overflow-y: scroll;
height: 80vh; /* Adjust based on layout */
padding: 10px;
background-image: url('https://i.pinimg.com/564x/8c/98/99/8c98994518b575bfd8c949e91d20548b.jpg');
}
.send{
display: flex;
Expand All @@ -127,6 +130,7 @@
overflow-y: auto;
border-radius: 10px;
resize: none;
border: 0.25px solid rgba(128, 128, 128, 0.267);
}
.send>button {
/* border-radius:10px; */
Expand Down
9 changes: 9 additions & 0 deletions client/src/components/ProfileSetup/Profilesetup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ import styles from './profilesetup.module.css'; // Import the CSS module
import { db } from '../../../firebase';
import { setDoc,doc } from 'firebase/firestore';
import { AuthContext } from '../context/auth_context';
import { useNavigate } from 'react-router-dom';

import Navbar from '../Farmer/FarmNav';

export default function Profilesetup() {
const { currentUser } = useContext(AuthContext); // Get currentUser from AuthContext
const port = import.meta.env.VITE_PORT;
// const {currentUser} = useAuth();
const navigate = useNavigate();
useEffect(() => {
if(currentUser === null){
navigate('/abc');
}
},[currentUser,navigate]);


const [imagePreview1, setImagePreview1] = useState(null);
const [imagePreview2, setImagePreview2] = useState(null);
Expand Down
Loading