add update package & weather details

This commit is contained in:
Romulus21
2024-04-22 23:50:59 +02:00
parent 2f2077497d
commit 49f0abd08c
9 changed files with 1038 additions and 993 deletions

View File

@@ -1,15 +1,20 @@
import React from "react"
import {Link, useLocation} from "react-router-dom"
import useAuthUser from "../hooks/AuthUser"
import useDimension from "../hooks/DimensionHook"
const Header = () => {
const {authUser} = useAuthUser()
const location = useLocation()
const {targetRef, dimensions} = useDimension()
return <header className="flex justify-between bg-blue-700 px-5 py-3 text-xl text-white">
return <header ref={targetRef}
className="flex justify-between bg-blue-700 px-5 py-3 text-xl text-white">
<div>
<Link to="/">Bermite</Link>
<Link to="/" className={`font-bold`}>
{dimensions.width < 400 ? 'B' : 'Bermite'}
</Link>
</div>
{authUser?.locations && authUser.locations.length > 0 && <nav className="flex gap-2">
@@ -19,7 +24,9 @@ const Header = () => {
{authUser
? <span className="flex gap-2">
<Link to="/profile" className={location.pathname === '/profile' ? 'font-bold' : ''}>{authUser.name}</Link>
<Link to="/profile" className={`${location.pathname === '/profile' ? 'font-bold' : ''} font-bold`}>
{dimensions.width < 400 ? authUser.name[0] : authUser.name}
</Link>
</span>
: <span className="flex gap-2">
<Link to="/connexion">Connexion</Link>

View File

@@ -23,7 +23,7 @@ const AddRainfall: FC<AddRainfallProps> = ({reload}) => {
}
}
return <Card className="w-full min-w-[300px] self-start overflow-hidden md:w-auto">
return <Card className="w-full self-start overflow-hidden md:w-auto">
<h2 className="-mx-2 -mt-1 bg-blue-500 px-2 py-1 text-center text-lg font-bold text-white">
Ajout d&apos;une mesure
</h2>
@@ -38,7 +38,7 @@ const AddRainfall: FC<AddRainfallProps> = ({reload}) => {
</Field>
{!loading ? <Field type="number"
name="value"
value={data.value}
value={data.value ?? ''}
onChange={event => setData({...data, value: Number(event.target.value)})}>
Mesure
</Field> : <div className="h-[74px]" />}

View File

@@ -7,7 +7,7 @@ import {monthlyRainfall} from "../../types"
const YearRainfall: FC<YearRainfallProps> = ({loadedAt}) => {
const {errorCatch, errorLabel, setError, axiosGet} = useAxiosTools()
const [data, setData] = useState<monthlyRainfall[]>([])
const [data, setData] = useState<monthlyRainfall[][]>([])
useEffect(() => {
fetchData()
@@ -27,10 +27,10 @@ const YearRainfall: FC<YearRainfallProps> = ({loadedAt}) => {
}
return <div>
<Card className="w-full min-w-[300px] self-start overflow-hidden md:w-auto">
<Card className="w-full self-start overflow-hidden md:w-auto">
<h1 className="-mx-2 -mt-1 bg-blue-500 px-2 py-1 text-center text-lg font-bold text-white">Précipitations des derniers mois</h1>
{errorLabel()}
<table className="w-full text-center">
<table className="w-full overflow-y-scroll text-center">
<thead>
<tr>
<th>Mois</th>