Skip to content

Commit

Permalink
Merge pull request #108 from green-ecolution/feature/update-backend-c…
Browse files Browse the repository at this point in the history
…lient-3b372d3

Update Backend API Client
  • Loading branch information
choffmann authored Oct 6, 2024
2 parents bd456d6 + 6b03170 commit bf816d5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion backend-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@green-ecolution/backend-client",
"version": "1.0.5",
"version": "1.0.6",
"description": "Client for the Green Ecolution backend",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/general/cards/TreeCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getWateringStatusDetails } from '@/hooks/useDetailsForWateringStatus';
import { EntitiesTreeClusterWateringStatus, Tree } from '@green-ecolution/backend-client';
import { EntitiesWateringStatus, Tree } from '@green-ecolution/backend-client';
import { Link } from '@tanstack/react-router';
import { MoveRight } from 'lucide-react';
import React from 'react';
Expand All @@ -9,7 +9,7 @@ interface TreeCardProps {

const TreeCard: React.FC<TreeCardProps> = ({ tree }) => {
// TODO: Add real status
const statusDetails = getWateringStatusDetails(EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusGood);
const statusDetails = getWateringStatusDetails(EntitiesWateringStatus.WateringStatusGood);
const wrapperClasses = 'bg-white group border border-dark-50 p-6 rounded-xl shadow-cards flex flex-col gap-y-4 lg:grid lg:grid-cols-[1fr,2fr,1fr,1fr] lg:items-center lg:gap-5 lg:py-5 xl:px-10';

return (
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/general/cards/TreeclusterCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Tree from '@/components/icons/Tree';
import { getWateringStatusDetails } from '@/hooks/useDetailsForWateringStatus';
import { EntitiesTreeClusterWateringStatus } from '@green-ecolution/backend-client';
import { EntitiesWateringStatus } from '@green-ecolution/backend-client';
import { Link } from '@tanstack/react-router';
import { MapPin } from 'lucide-react';
import React from 'react';
Expand All @@ -14,7 +14,7 @@ interface TreeclusterCard {
region: string;
treeCount: number;
sensorCount: number;
status: EntitiesTreeClusterWateringStatus;
status: EntitiesWateringStatus;
}
}

Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/general/filter/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useOutsideClick from '@/hooks/useOutsideClick';
import Option from './Option';
import { useNavigate } from '@tanstack/react-router';
import { useSuspenseQuery } from '@tanstack/react-query';
import { EntitiesTreeClusterWateringStatus, regionApi } from '@/api/backendApi';
import { EntitiesWateringStatus, regionApi } from '@/api/backendApi';
import { useAuthHeader } from '@/hooks/useAuthHeader';
import { getWateringStatusDetails } from '@/hooks/useDetailsForWateringStatus';

Expand Down Expand Up @@ -96,8 +96,7 @@ const Dialog: React.FC<DialogProps> = ({ initStatusTags, initRegionTags, headlin

<fieldset>
<legend className="font-lato font-semibold text-dark-600 mb-2">Zustand der Bewässerung:</legend>
{Object.entries(EntitiesTreeClusterWateringStatus)
.filter(([key]) => key !== 'TreeClusterWateringStatusUnknown')
{Object.entries(EntitiesWateringStatus)
.map(([statusKey, statusValue]) => (
<Option
key={statusKey}
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/tree/TreeWateringStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EntitiesTreeClusterWateringStatus, Tree } from '@green-ecolution/backend-client';
import { EntitiesWateringStatus, Tree } from '@green-ecolution/backend-client';
import React from 'react';
import { TreeDeciduous } from 'lucide-react';
import { getWateringStatusDetails } from '@/hooks/useDetailsForWateringStatus';
Expand All @@ -13,17 +13,17 @@ const TreeWateringStatus: React.FC<TreeWateringStatus> = ({ tree }) => {
// TODO: Switch to real content
const statusProDepth = [
{
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusGood,
status: EntitiesWateringStatus.WateringStatusGood,
sensorCount: 1,
value: "42,46 kΩ",
},
{
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusGood,
status: EntitiesWateringStatus.WateringStatusGood,
sensorCount: 1,
value: "35,46 kΩ",
},
{
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusModerate,
status: EntitiesWateringStatus.WateringStatusModerate,
sensorCount: 1,
value: "28,12 kΩ",
},
Expand Down Expand Up @@ -53,7 +53,7 @@ const TreeWateringStatus: React.FC<TreeWateringStatus> = ({ tree }) => {
<ul className="space-y-5 md:space-y-0 md:grid md:gap-5 md:grid-cols-2 lg:grid-cols-4">
<li>
<EntitiesStatusCard
statusDetails={getWateringStatusDetails(EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusGood)}
statusDetails={getWateringStatusDetails(EntitiesWateringStatus.WateringStatusGood)}
label="Bewässerungszustand (ø)" />
</li>
{statusCards.map((card, key) => (
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/data/treecluser.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EntitiesTreeClusterWateringStatus } from "@green-ecolution/backend-client";
import { EntitiesWateringStatus } from "@green-ecolution/backend-client";

export function treeclusterDemoData() {
return [
Expand All @@ -10,7 +10,7 @@ export function treeclusterDemoData() {
region: "Friesischer Berg",
treeCount: 34,
sensorCount: 4,
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusBad,
status: EntitiesWateringStatus.WateringStatusBad,
description: 'Diese Bewässserungsgruppe bedindet sich an Position XY und beinhlatet XY viele Bäume. Hier ist zudem noch Platz für mehr Inhalt, den ich noch nicht kenne.',
},
{
Expand All @@ -21,7 +21,7 @@ export function treeclusterDemoData() {
region: "Engelsby",
treeCount: 34,
sensorCount: 4,
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusBad,
status: EntitiesWateringStatus.WateringStatusBad,
description: 'Diese Bewässserungsgruppe bedindet sich an Position XY und beinhlatet XY viele Bäume. Hier ist zudem noch Platz für mehr Inhalt, den ich noch nicht kenne.',
},
{
Expand All @@ -32,7 +32,7 @@ export function treeclusterDemoData() {
region: "Fruerlund",
treeCount: 34,
sensorCount: 4,
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusModerate,
status: EntitiesWateringStatus.WateringStatusModerate,
description: 'Diese Bewässserungsgruppe bedindet sich an Position XY und beinhlatet XY viele Bäume. Hier ist zudem noch Platz für mehr Inhalt, den ich noch nicht kenne.',
},
{
Expand All @@ -43,7 +43,7 @@ export function treeclusterDemoData() {
region: "Mürwik",
treeCount: 34,
sensorCount: 4,
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusGood,
status: EntitiesWateringStatus.WateringStatusGood,
description: 'Diese Bewässserungsgruppe bedindet sich an Position XY und beinhlatet XY viele Bäume. Hier ist zudem noch Platz für mehr Inhalt, den ich noch nicht kenne.',
},
{
Expand All @@ -54,7 +54,7 @@ export function treeclusterDemoData() {
region: "Friesischer Berg",
treeCount: 34,
sensorCount: 4,
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusModerate,
status: EntitiesWateringStatus.WateringStatusModerate,
description: '',
},
{
Expand All @@ -65,7 +65,7 @@ export function treeclusterDemoData() {
region: "Neustadt",
treeCount: 34,
sensorCount: 4,
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusGood,
status: EntitiesWateringStatus.WateringStatusGood,
description: '',
},
{
Expand All @@ -76,7 +76,7 @@ export function treeclusterDemoData() {
region: "Friesischer Berg",
treeCount: 34,
sensorCount: 4,
status: EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusBad,
status: EntitiesWateringStatus.WateringStatusModerate,
description: '',
},
];
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/hooks/useDetailsForWateringStatus.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { EntitiesTreeClusterWateringStatus } from "@green-ecolution/backend-client";
import { EntitiesWateringStatus } from "@green-ecolution/backend-client";

const WateringStatusProperties = {
[EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusUnknown]: {
[EntitiesWateringStatus.WateringStatusUnknown]: {
color: 'dark-400',
label: 'Unbekannt',
description: 'Der Bewässerungsstatus ist unbekannt.',
},
[EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusBad]: {
[EntitiesWateringStatus.WateringStatusBad]: {
color: 'red',
label: 'Sehr trocken',
description: 'Die Bäume benötigen dringend Wasser.',
},
[EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusModerate]: {
[EntitiesWateringStatus.WateringStatusModerate]: {
color: 'yellow',
label: 'Leicht trocken',
description: 'Die Bäume sind leicht trocken und benötigen etwas Wasser.',
},
[EntitiesTreeClusterWateringStatus.TreeClusterWateringStatusGood]: {
[EntitiesWateringStatus.WateringStatusGood]: {
color: 'green-light',
label: 'In Ordnung',
description: 'Die Bewässerung ist ausreichend, keine Maßnahmen erforderlich.',
},
} as const;

type WateringStatusDetails = typeof WateringStatusProperties[EntitiesTreeClusterWateringStatus];
type WateringStatusDetails = typeof WateringStatusProperties[EntitiesWateringStatus];

export const getWateringStatusDetails = (status: EntitiesTreeClusterWateringStatus): WateringStatusDetails => {
export const getWateringStatusDetails = (status: EntitiesWateringStatus): WateringStatusDetails => {
return WateringStatusProperties[status];
};

0 comments on commit bf816d5

Please sign in to comment.