diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..c92de29 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,20 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on merge +'on': + push: + branches: + - marketplace +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: pnpm i && pnpm build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_AGRPRJ }}' + channelId: live + projectId: agrprj diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..0efad39 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,17 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on PR +'on': pull_request +jobs: + build_and_preview: + if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: pnpm i && pnpm build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_AGRPRJ }}' + projectId: agrprj diff --git a/Applications/client/src/pages/dashboard.tsx b/Applications/client/src/pages/dashboard.tsx deleted file mode 100644 index 8fdbf49..0000000 --- a/Applications/client/src/pages/dashboard.tsx +++ /dev/null @@ -1,9 +0,0 @@ -const DashboardPage = () => { - return ( -
- Dashboard -
- ) -} - -export default DashboardPage diff --git a/Applications/client/.eslintrc.cjs b/Applications/consumer/.eslintrc.cjs similarity index 100% rename from Applications/client/.eslintrc.cjs rename to Applications/consumer/.eslintrc.cjs diff --git a/Applications/consumer/.gitignore b/Applications/consumer/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/Applications/consumer/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/Applications/consumer/index.html b/Applications/consumer/index.html new file mode 100644 index 0000000..92a996a --- /dev/null +++ b/Applications/consumer/index.html @@ -0,0 +1,13 @@ + + + + + + + Green market | One stop shop for all things agri + + +
+ + + diff --git a/Applications/consumer/package.json b/Applications/consumer/package.json new file mode 100644 index 0000000..ff5360c --- /dev/null +++ b/Applications/consumer/package.json @@ -0,0 +1,29 @@ +{ + "name": "consumer", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite --port 5300 --host 0.0.0.0 --open", + "build": "tsc && vite build", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "@green-sync/ui": "workspace:^", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@types/react": "^18.0.28", + "@types/react-dom": "^18.0.11", + "@typescript-eslint/eslint-plugin": "^5.57.1", + "@typescript-eslint/parser": "^5.57.1", + "@vitejs/plugin-react": "^4.0.0-beta.0", + "eslint": "^8.38.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.3.4", + "typescript": "^5.0.2", + "vite": "^4.3.0" + } +} diff --git a/Applications/client/public/vite.svg b/Applications/consumer/public/vite.svg similarity index 100% rename from Applications/client/public/vite.svg rename to Applications/consumer/public/vite.svg diff --git a/Applications/consumer/src/App.tsx b/Applications/consumer/src/App.tsx new file mode 100644 index 0000000..cd329b1 --- /dev/null +++ b/Applications/consumer/src/App.tsx @@ -0,0 +1,9 @@ +import {Card} from "@green-sync/ui" +export const App = () => { + const cta = () => { + + } + return <> + + +} \ No newline at end of file diff --git a/Applications/consumer/src/components/index.ts b/Applications/consumer/src/components/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/Applications/consumer/src/index.css b/Applications/consumer/src/index.css new file mode 100644 index 0000000..2c3fac6 --- /dev/null +++ b/Applications/consumer/src/index.css @@ -0,0 +1,69 @@ +:root { + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/Applications/consumer/src/main.tsx b/Applications/consumer/src/main.tsx new file mode 100644 index 0000000..ee446d9 --- /dev/null +++ b/Applications/consumer/src/main.tsx @@ -0,0 +1,10 @@ +import React from 'react' +import ReactDOM from 'react-dom/client' +import {App} from './App.tsx' +import './index.css' + +ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + + , +) diff --git a/Applications/consumer/src/pages/Home.tsx b/Applications/consumer/src/pages/Home.tsx new file mode 100644 index 0000000..0c99ec9 --- /dev/null +++ b/Applications/consumer/src/pages/Home.tsx @@ -0,0 +1,3 @@ +export const HomePage = () => { + return <>Home Page +} \ No newline at end of file diff --git a/Applications/consumer/src/pages/index.ts b/Applications/consumer/src/pages/index.ts new file mode 100644 index 0000000..f623eef --- /dev/null +++ b/Applications/consumer/src/pages/index.ts @@ -0,0 +1 @@ +export * from "./Home" \ No newline at end of file diff --git a/Applications/client/src/vite-env.d.ts b/Applications/consumer/src/vite-env.d.ts similarity index 100% rename from Applications/client/src/vite-env.d.ts rename to Applications/consumer/src/vite-env.d.ts diff --git a/Applications/client/tsconfig.json b/Applications/consumer/tsconfig.json similarity index 100% rename from Applications/client/tsconfig.json rename to Applications/consumer/tsconfig.json diff --git a/Applications/client/tsconfig.node.json b/Applications/consumer/tsconfig.node.json similarity index 100% rename from Applications/client/tsconfig.node.json rename to Applications/consumer/tsconfig.node.json diff --git a/Applications/client/vite.config.ts b/Applications/consumer/vite.config.ts similarity index 100% rename from Applications/client/vite.config.ts rename to Applications/consumer/vite.config.ts diff --git a/Applications/client/.env.example b/Applications/farmer/.env.example similarity index 100% rename from Applications/client/.env.example rename to Applications/farmer/.env.example diff --git a/Applications/farmer/.eslintrc.cjs b/Applications/farmer/.eslintrc.cjs new file mode 100644 index 0000000..4020bcb --- /dev/null +++ b/Applications/farmer/.eslintrc.cjs @@ -0,0 +1,14 @@ +module.exports = { + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + ], + parser: '@typescript-eslint/parser', + parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': 'warn', + }, +} diff --git a/Applications/farmer/.firebaserc b/Applications/farmer/.firebaserc new file mode 100644 index 0000000..e8d95fd --- /dev/null +++ b/Applications/farmer/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "agrprj" + } +} diff --git a/Applications/client/.gitignore b/Applications/farmer/.gitignore similarity index 100% rename from Applications/client/.gitignore rename to Applications/farmer/.gitignore diff --git a/Applications/farmer/firebase.json b/Applications/farmer/firebase.json new file mode 100644 index 0000000..e1fdf63 --- /dev/null +++ b/Applications/farmer/firebase.json @@ -0,0 +1,17 @@ +{ + "hosting": { + "site": "dev-agritech", + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} diff --git a/Applications/client/index.html b/Applications/farmer/index.html similarity index 91% rename from Applications/client/index.html rename to Applications/farmer/index.html index 369fce0..cd5042f 100644 --- a/Applications/client/index.html +++ b/Applications/farmer/index.html @@ -8,7 +8,7 @@ - + Vite + React + TS diff --git a/Applications/client/package.json b/Applications/farmer/package.json similarity index 81% rename from Applications/client/package.json rename to Applications/farmer/package.json index 85c8694..34cde7e 100644 --- a/Applications/client/package.json +++ b/Applications/farmer/package.json @@ -7,11 +7,15 @@ "start": "vite --host 0.0.0.0 --port 43000", "build": "tsc && vite build", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "host":"firebase deploy --only hosting:dev-agritech", + "host:prod":"firebase deploy --only hosting:prod-agritech" }, "dependencies": { "@apollo/client": "^3.7.12", + "@headlessui/react": "^1.7.14", "@heroicons/react": "^2.0.17", + "@reach/disclosure": "^0.18.0", "firebase": "^9.20.0", "graphql": "^16.6.0", "react": "^18.2.0", diff --git a/Applications/client/postcss.config.js b/Applications/farmer/postcss.config.js similarity index 100% rename from Applications/client/postcss.config.js rename to Applications/farmer/postcss.config.js diff --git a/Applications/farmer/public/vite.svg b/Applications/farmer/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/Applications/farmer/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Applications/client/src/App.tsx b/Applications/farmer/src/App.tsx similarity index 51% rename from Applications/client/src/App.tsx rename to Applications/farmer/src/App.tsx index 028cff4..0bc94da 100644 --- a/Applications/client/src/App.tsx +++ b/Applications/farmer/src/App.tsx @@ -1,21 +1,21 @@ import { Routes, Route} from "react-router-dom" import ErrorPage from "./pages/errorPage" -import LoginPage from "./pages/loginPage" import DashboardPage from "./pages/dashboard" -import { SignUp } from "./pages/signUpPage" import {env} from "./utils" +import LoginForms from "./components/forms/LoginForms" +import { RouteGuard } from "./components/authentication/auth.guard" function App() { console.log(env) return ( <> - }/> - } /> - }/> + + + + }/> + } /> }/> ) -} - -export default App diff --git a/Applications/farmer/src/components/authentication/auth.guard.tsx b/Applications/farmer/src/components/authentication/auth.guard.tsx new file mode 100644 index 0000000..55eaa23 --- /dev/null +++ b/Applications/farmer/src/components/authentication/auth.guard.tsx @@ -0,0 +1,25 @@ +import { User, onAuthStateChanged } from "firebase/auth" +import { createContext, useEffect, useState } from "react" +import { auth } from "../../utils" +import { useNavigate } from "react-router-dom" + +// export a context +export const GreenContext = createContext(null) + +export const RouteGuard = ({children}: any) => { + const [user, setUser] = useState() + const nav = useNavigate() + useEffect(()=>{ + const sub = onAuthStateChanged(auth, (user)=>{ + if(!user) { + nav("/signin") + } + setUser(user as User) + // additional logic + }) + return sub + }, [user,nav,setUser]) + return + {children} + +} diff --git a/Applications/farmer/src/components/authentication/index.ts b/Applications/farmer/src/components/authentication/index.ts new file mode 100644 index 0000000..45184d9 --- /dev/null +++ b/Applications/farmer/src/components/authentication/index.ts @@ -0,0 +1 @@ +export * from './' \ No newline at end of file diff --git a/Applications/farmer/src/components/authentication/loginComponent.tsx b/Applications/farmer/src/components/authentication/loginComponent.tsx new file mode 100644 index 0000000..c2db39c --- /dev/null +++ b/Applications/farmer/src/components/authentication/loginComponent.tsx @@ -0,0 +1,15 @@ +import React, { useState } from 'react' +import { SignUp } from '../../pages'; +import SignIn from '../../pages/loginPage'; + +const LoginComponent = () => { + const [showComponent, setShowComponent] = useState(true); + + return ( +
+ {showComponent ? setShowComponent(!showComponent)} /> : setShowComponent(!showComponent)}/>} +
+ ) +} + +export default LoginComponent diff --git a/Applications/farmer/src/components/dashboard/calendar/calendar.tsx b/Applications/farmer/src/components/dashboard/calendar/calendar.tsx new file mode 100644 index 0000000..a35a17e --- /dev/null +++ b/Applications/farmer/src/components/dashboard/calendar/calendar.tsx @@ -0,0 +1,112 @@ +import React, {useState} from 'react' + + +export const CalendarComponent = () => { + // Get the current date + const currentDate = new Date(); + + // Initialize state for the selected date + const [selectedDate, setSelectedDate] = useState(currentDate); + + // Calculate the number of days in the selected month + const numDaysInMonth = new Date( + selectedDate.getFullYear(), + selectedDate.getMonth() + 1, + 0 + ).getDate(); + + // Calculate the first day of the month + const firstDayOfMonth = new Date( + selectedDate.getFullYear(), + selectedDate.getMonth(), + 1 + ).getDay(); + + // Initialize an array to hold the days of the month + const daysOfMonth = []; + + // Loop through the days of the month and add them to the array + for (let i = 1; i <= numDaysInMonth; i++) { + daysOfMonth.push(i); + } + + // Create an array to hold the calendar rows + const calendarRows = []; + + // Create an array to hold the current week + let currentWeek = []; + + // Add blank cells for the days before the first day of the month + for (let i = 0; i < firstDayOfMonth; i++) { + currentWeek.push(null); + } + + // Add the days of the month to the current week + for (let i = 0; i < daysOfMonth.length; i++) { + currentWeek.push(daysOfMonth[i]); + + // If the current week is complete, add it to the calendar rows and start a new week + if (currentWeek.length === 7) { + calendarRows.push(currentWeek); + currentWeek = []; + } + } + + // Add blank cells for the remaining days in the last week + while (currentWeek.length < 7) { + currentWeek.push(null); + } + + // Add the final week to the calendar rows + calendarRows.push(currentWeek); + + // Handle the previous month button click + const handlePrevMonth = () => { + setSelectedDate(new Date(selectedDate.getFullYear(), selectedDate.getMonth() - 1, 1)); + }; + + // Handle the next month button click + const handleNextMonth = () => { + setSelectedDate(new Date(selectedDate.getFullYear(), selectedDate.getMonth() + 1, 1)); + }; + + // Render the calendar + return ( +
+
+ +

+ {selectedDate.toLocaleString("default", { month: "long", year: "numeric" })} +

+ +
+ + + + + + + + + + + + + + {calendarRows.map((week, index) => ( + + {week.map((day, index) => ( + + ))} + + ))} + +
SunMonTueWedThuFriSat
{day}
+
+ ); +}; + diff --git a/Applications/farmer/src/components/dashboard/farm/crops.tsx b/Applications/farmer/src/components/dashboard/farm/crops.tsx new file mode 100644 index 0000000..e69de29 diff --git a/Applications/farmer/src/components/dashboard/farm/liveStock.tsx b/Applications/farmer/src/components/dashboard/farm/liveStock.tsx new file mode 100644 index 0000000..3a1df8e --- /dev/null +++ b/Applications/farmer/src/components/dashboard/farm/liveStock.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const liveStock = () => { + return ( +
+ +
+ ) +} + +export default liveStock diff --git a/Applications/farmer/src/components/dashboard/index.ts b/Applications/farmer/src/components/dashboard/index.ts new file mode 100644 index 0000000..13b06ef --- /dev/null +++ b/Applications/farmer/src/components/dashboard/index.ts @@ -0,0 +1 @@ +export * from "./" \ No newline at end of file diff --git a/Applications/client/src/components/profile.tsx b/Applications/farmer/src/components/dashboard/profile.tsx similarity index 100% rename from Applications/client/src/components/profile.tsx rename to Applications/farmer/src/components/dashboard/profile.tsx diff --git a/Applications/farmer/src/components/dashboard/recentActivities.tsx b/Applications/farmer/src/components/dashboard/recentActivities.tsx new file mode 100644 index 0000000..29f027e --- /dev/null +++ b/Applications/farmer/src/components/dashboard/recentActivities.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const RecentActivities = () => { + return ( +
+ +
+ ) +} + +export default RecentActivities \ No newline at end of file diff --git a/Applications/farmer/src/components/dashboard/searchBar.tsx b/Applications/farmer/src/components/dashboard/searchBar.tsx new file mode 100644 index 0000000..377ef5c --- /dev/null +++ b/Applications/farmer/src/components/dashboard/searchBar.tsx @@ -0,0 +1,34 @@ +import { useState } from 'react'; + +type SearchBarProps = { + onSearch: (query: string) => void; +}; + +const SearchBar: React.FC = ({ onSearch }) => { + const [query, setQuery] = useState(''); + + const handleSearch = (event: React.FormEvent) => { + event.preventDefault(); + onSearch(query); + }; + + return ( +
+ setQuery(event.target.value)} + className="px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" + /> + +
+ ); +}; + +export default SearchBar; diff --git a/Applications/farmer/src/components/dashboard/sideBar.tsx b/Applications/farmer/src/components/dashboard/sideBar.tsx new file mode 100644 index 0000000..8d57bf9 --- /dev/null +++ b/Applications/farmer/src/components/dashboard/sideBar.tsx @@ -0,0 +1,52 @@ +import { CalendarIcon, ClockIcon, CpuChipIcon, GlobeAltIcon, HomeIcon, ShoppingBagIcon, SunIcon, UserCircleIcon } from "@heroicons/react/20/solid"; + +function SidebarComponent() { + const menuItems = [ + { label: 'Home', icon: , href: '#' }, + { label: 'Profile', icon: , href: '#' }, + { label: 'Weather', icon: , href: '#' }, + { label: 'Calendar', icon: , href: '#' }, + { label: 'Farm', icon: , href: '#' }, + { label: 'IoT', icon: , href: '#' }, + { label: 'Recent', icon: , href: '#' }, + { label: 'Marketplace', icon: , href: '#' }, + ]; + + return ( +
+
+ Workflow + GreenSync +
+ +
+ +
+
+ ); +} + +export default SidebarComponent; diff --git a/Applications/farmer/src/components/dashboard/weather.tsx b/Applications/farmer/src/components/dashboard/weather.tsx new file mode 100644 index 0000000..aba33dd --- /dev/null +++ b/Applications/farmer/src/components/dashboard/weather.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const weather = () => { + return ( +
+ +
+ ) +} + +export default weather diff --git a/Applications/farmer/src/components/forms/LoginForms.tsx b/Applications/farmer/src/components/forms/LoginForms.tsx new file mode 100644 index 0000000..50bc0b2 --- /dev/null +++ b/Applications/farmer/src/components/forms/LoginForms.tsx @@ -0,0 +1,273 @@ + +import { useState } from "react"; +import { CreateUserAccount, SocialLogin, LoginnWithEmailAndPassword,UserDetails } from "../../firebase"; +import { useNavigate } from "react-router-dom"; + +export default function LoginForms() { + const nav = useNavigate() + + const [signInType, setSignInType] = useState("Login") + const [userData, setUserData] = useState({} as UserDetails); + + const handleEmail = (e: any) => { + userData["email"] = e.target.value; + setUserData({...userData}); + }; + + const handlePassword = (e: any) => { + userData["password"] = e.target.value; + setUserData({...userData}); + }; + + const handleLastName = (e: any) => { + userData["lastName"] = e.target.value; + setUserData({...userData}); + }; + + const handleFirstName = (e: any) => { + userData["firstName"] = e.target.value; + setUserData({...userData}); + }; + + const handleFarmerType = (e: any) => { + userData["farmType"] = e.target.value; + setUserData({...userData}); + }; + const authenticate = async (e: any) => { + e.preventDefault() + const [option,provider] = e.target.id.split(',') + const userData = e.target.value; + if(option ==="social"){ + const isloggedIn= await SocialLogin(provider) + return isloggedIn ? nav("/"): null + } else { + const isloggedIn= await LoginnWithEmailAndPassword(userData) + return isloggedIn ? nav("/"): null + } + + } + + return ( + <> +
+
+
+

+ Sign {signInType === "Login" ? " In" : " Up"} to your account +

+ +
+
+{/* =======================================================LOGIN==================================================================== */} +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ + + +
setSignInType("Register")}> + New here? Create Account +
+
+
+{/* =============================================================REGISTER================================================================================= */} +
CreateUserAccount(userData)} + > +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+ + +
+ +
setSignInType("Login")}> + Have an Account? Sign In +
+
+
+ {/* ===========================================SOCIALS============================================================================================================================================= */} +
+
+ + + +
+
+
+
+
+ +
+
+ + ) } diff --git a/Applications/farmer/src/components/profile.tsx b/Applications/farmer/src/components/profile.tsx new file mode 100644 index 0000000..d01275b --- /dev/null +++ b/Applications/farmer/src/components/profile.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const profile = () => { + return ( +
+ +
+ ) +} + +export default profile diff --git a/Applications/client/src/components/sideBar.tsx b/Applications/farmer/src/components/sideBar.tsx similarity index 100% rename from Applications/client/src/components/sideBar.tsx rename to Applications/farmer/src/components/sideBar.tsx diff --git a/Applications/client/src/firebase/firebase.ts b/Applications/farmer/src/firebase/firebase.ts similarity index 64% rename from Applications/client/src/firebase/firebase.ts rename to Applications/farmer/src/firebase/firebase.ts index 1312d9f..a51308a 100644 --- a/Applications/client/src/firebase/firebase.ts +++ b/Applications/farmer/src/firebase/firebase.ts @@ -1,35 +1,43 @@ +/* eslint-disable react-hooks/rules-of-hooks */ import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, FacebookAuthProvider, createUserWithEmailAndPassword, + updateProfile } from "firebase/auth"; import { SocialProviders, UserDetails } from "./firebaseInterfaces"; import {auth} from "../utils"; -import firebase from 'firebase/app'; -// const auth = getAuth(); +// const history = useHistory(); -const LoginnWithEmailAndPassword = async (data: UserDetails, auth: any) => { +const LoginnWithEmailAndPassword = async (data: UserDetails) => { // {email, password, fullname} try { const { email, password } = data; await signInWithEmailAndPassword(auth, email, password); - return true; + return true } catch (error) { + console.log(error); return error; } }; // union type -const SocialLogin = async (provider: SocialProviders,auth:any) => { +const SocialLogin = async (provider: SocialProviders) => { // TODO: implement this method const providers = { google: new GoogleAuthProvider(), facebook: new FacebookAuthProvider(), } - await signInWithPopup(auth, providers[provider as SocialProviders]); + try { + await signInWithPopup(auth, providers[provider as SocialProviders]); + return true; + } catch(error) { + return false + } + }; const CreateUserAccount = async (data: UserDetails) => { @@ -38,21 +46,19 @@ const CreateUserAccount = async (data: UserDetails) => { await createUserWithEmailAndPassword(auth, email, password) .then((userCredential) => { const user = userCredential.user; - // const uid = user.uid; - - // // Add more data to the user in the Realtime Database - // const databaseRef = firebase.database().ref(``); - // const userData = { email, firstName, lastName, farmType }; - // databaseRef.set(userData); - - // console.log('User signed up:', user); + updateProfile(user, { + displayName: firstName, + // lastName: lastName, + // farmingType: farmType + }) }) .catch((error) => { console.error('Error signing up:', error); }); return true } catch (error) { - return error; + alert("Error signing up") + return false; } } diff --git a/Applications/client/src/firebase/firebaseInterfaces.ts b/Applications/farmer/src/firebase/firebaseInterfaces.ts similarity index 100% rename from Applications/client/src/firebase/firebaseInterfaces.ts rename to Applications/farmer/src/firebase/firebaseInterfaces.ts diff --git a/Applications/client/src/firebase/index.ts b/Applications/farmer/src/firebase/index.ts similarity index 100% rename from Applications/client/src/firebase/index.ts rename to Applications/farmer/src/firebase/index.ts diff --git a/Applications/client/src/index.css b/Applications/farmer/src/index.css similarity index 64% rename from Applications/client/src/index.css rename to Applications/farmer/src/index.css index bd6213e..b5c61c9 100644 --- a/Applications/client/src/index.css +++ b/Applications/farmer/src/index.css @@ -1,3 +1,3 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; diff --git a/Applications/client/src/main.tsx b/Applications/farmer/src/main.tsx similarity index 100% rename from Applications/client/src/main.tsx rename to Applications/farmer/src/main.tsx diff --git a/Applications/farmer/src/pages/dashboard.tsx b/Applications/farmer/src/pages/dashboard.tsx new file mode 100644 index 0000000..d0cd5e1 --- /dev/null +++ b/Applications/farmer/src/pages/dashboard.tsx @@ -0,0 +1,37 @@ +import React, { useState } from 'react'; +import ProfileComponent from '../components/dashboard/profile'; +import RecentActivities from '../components/dashboard/recentActivities'; +import SidebarComponent from '../components/dashboard/sideBar'; +import { CalendarComponent } from '../components/dashboard/calendar/calendar'; +import SearchBar from '../components/dashboard/searchBar'; + +const DashboardComponent: React.FC = () => { + const [searchQuery, setSearchQuery] = useState(''); + + const handleSearch = (query: string) => { + setSearchQuery(query); + }; + + return ( +
+ +
+
+ +
+ +
+
+
+
+ + {/* */} +
+
+
+
+
+ ); +}; + +export default DashboardComponent; diff --git a/Applications/client/src/pages/errorPage.tsx b/Applications/farmer/src/pages/errorPage.tsx similarity index 100% rename from Applications/client/src/pages/errorPage.tsx rename to Applications/farmer/src/pages/errorPage.tsx diff --git a/Applications/farmer/src/pages/index.ts b/Applications/farmer/src/pages/index.ts new file mode 100644 index 0000000..ab07ace --- /dev/null +++ b/Applications/farmer/src/pages/index.ts @@ -0,0 +1,4 @@ +export * from './loginPage'; +export * from './signUpPage'; +export * from './dashboard'; +export * from './errorPage'; \ No newline at end of file diff --git a/Applications/client/src/pages/loginPage.tsx b/Applications/farmer/src/pages/loginPage.tsx similarity index 97% rename from Applications/client/src/pages/loginPage.tsx rename to Applications/farmer/src/pages/loginPage.tsx index b355d78..e2918eb 100644 --- a/Applications/client/src/pages/loginPage.tsx +++ b/Applications/farmer/src/pages/loginPage.tsx @@ -4,7 +4,7 @@ import {SocialLogin, UserDetails} from "../firebase" import {LoginnWithEmailAndPassword} from "../firebase" import {auth} from "../utils"; -export default function SignIn() { +export default function SignIn(toggleComponent: any) { const [userData, setUserData] = useState({} as UserDetails); const handleEmail = (e: any) => { @@ -28,7 +28,7 @@ export default function SignIn() {
-
LoginnWithEmailAndPassword(userData, auth)} >
@@ -95,9 +95,9 @@ export default function SignIn() { Sign in
-
+ */}
- New here? Create Account + New here? Create Account