@geops/rvf-mobility-web-component 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
"name": "@geops/rvf-mobility-web-component",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
4
|
"description": "Web components for rvf in the domains of mobility and logistics.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.22",
|
|
6
6
|
"homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"dependencies": {
|
|
10
|
+
"graphql": "^16.10.0",
|
|
11
|
+
"graphql-request": "^7.1.2",
|
|
10
12
|
"jspdf": "^2.5.2",
|
|
11
13
|
"lodash.debounce": "^4.0.8",
|
|
12
14
|
"maplibre-gl": "^4.7.1",
|
|
@@ -1,29 +1,236 @@
|
|
|
1
|
+
import { gql, GraphQLClient } from "graphql-request";
|
|
1
2
|
import { Feature } from "ol";
|
|
2
|
-
import { useMemo } from "preact/hooks";
|
|
3
|
+
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
3
4
|
|
|
4
|
-
import
|
|
5
|
+
import RvfLink from "../../../RvfLink";
|
|
5
6
|
import getLinkByDevice from "../../../utils/getLinkByDevice";
|
|
6
7
|
export interface StationDetailsProps {
|
|
7
8
|
feature: Feature;
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
const document = gql`
|
|
12
|
+
query station($id: String!) {
|
|
13
|
+
station(id: $id) {
|
|
14
|
+
name {
|
|
15
|
+
translation {
|
|
16
|
+
language
|
|
17
|
+
value
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
shortName {
|
|
21
|
+
translation {
|
|
22
|
+
language
|
|
23
|
+
value
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
lat
|
|
27
|
+
lon
|
|
28
|
+
region {
|
|
29
|
+
id
|
|
30
|
+
}
|
|
31
|
+
rentalUris {
|
|
32
|
+
android
|
|
33
|
+
ios
|
|
34
|
+
web
|
|
35
|
+
}
|
|
36
|
+
isVirtualStation
|
|
37
|
+
rentalMethods
|
|
38
|
+
parkingHoop
|
|
39
|
+
parkingType
|
|
40
|
+
contactPhone
|
|
41
|
+
address
|
|
42
|
+
rentalMethods
|
|
43
|
+
capacity
|
|
44
|
+
vehicleTypesAvailable {
|
|
45
|
+
count
|
|
46
|
+
vehicleType {
|
|
47
|
+
id
|
|
48
|
+
formFactor
|
|
49
|
+
riderCapacity
|
|
50
|
+
cargoVolumeCapacity
|
|
51
|
+
cargoLoadCapacity
|
|
52
|
+
propulsionType
|
|
53
|
+
ecoLabels {
|
|
54
|
+
countryCode
|
|
55
|
+
ecoSticker
|
|
56
|
+
}
|
|
57
|
+
maxRangeMeters
|
|
58
|
+
name {
|
|
59
|
+
translation {
|
|
60
|
+
language
|
|
61
|
+
value
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
description {
|
|
65
|
+
translation {
|
|
66
|
+
language
|
|
67
|
+
value
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
vehicleAccessories
|
|
71
|
+
gCO2km
|
|
72
|
+
vehicleImage
|
|
73
|
+
make
|
|
74
|
+
model
|
|
75
|
+
color
|
|
76
|
+
wheelCount
|
|
77
|
+
maxPermittedSpeed
|
|
78
|
+
ratedPower
|
|
79
|
+
defaultReserveTime
|
|
80
|
+
returnConstraint
|
|
81
|
+
vehicleAssets {
|
|
82
|
+
iconUrl
|
|
83
|
+
iconUrlDark
|
|
84
|
+
iconLastModified
|
|
85
|
+
}
|
|
86
|
+
defaultReserveTime
|
|
87
|
+
defaultPricingPlan {
|
|
88
|
+
id
|
|
89
|
+
url
|
|
90
|
+
currency
|
|
91
|
+
isTaxable
|
|
92
|
+
description {
|
|
93
|
+
translation {
|
|
94
|
+
language
|
|
95
|
+
value
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
perKmPricing {
|
|
99
|
+
start
|
|
100
|
+
rate
|
|
101
|
+
interval
|
|
102
|
+
end
|
|
103
|
+
}
|
|
104
|
+
perMinPricing {
|
|
105
|
+
start
|
|
106
|
+
rate
|
|
107
|
+
interval
|
|
108
|
+
end
|
|
109
|
+
}
|
|
110
|
+
surgePricing
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
count
|
|
114
|
+
}
|
|
115
|
+
vehicleDocksCapacity {
|
|
116
|
+
vehicleTypes {
|
|
117
|
+
id
|
|
118
|
+
}
|
|
119
|
+
count
|
|
120
|
+
}
|
|
121
|
+
numVehiclesAvailable
|
|
122
|
+
numDocksDisabled
|
|
123
|
+
numVehiclesDisabled
|
|
124
|
+
numDocksAvailable
|
|
125
|
+
isInstalled
|
|
126
|
+
isRenting
|
|
127
|
+
isReturning
|
|
128
|
+
pricingPlans {
|
|
129
|
+
id
|
|
130
|
+
url
|
|
131
|
+
currency
|
|
132
|
+
isTaxable
|
|
133
|
+
description {
|
|
134
|
+
translation {
|
|
135
|
+
language
|
|
136
|
+
value
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
perKmPricing {
|
|
140
|
+
start
|
|
141
|
+
rate
|
|
142
|
+
interval
|
|
143
|
+
end
|
|
144
|
+
}
|
|
145
|
+
perMinPricing {
|
|
146
|
+
start
|
|
147
|
+
rate
|
|
148
|
+
interval
|
|
149
|
+
end
|
|
150
|
+
}
|
|
151
|
+
surgePricing
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
const client = new GraphQLClient("https://api.mobidata-bw.de/sharing/graphql", {
|
|
157
|
+
method: "GET",
|
|
158
|
+
});
|
|
159
|
+
|
|
10
160
|
function StationDetails({ feature }: StationDetailsProps) {
|
|
161
|
+
const [data, setData] = useState(null);
|
|
11
162
|
const link = useMemo(() => {
|
|
12
163
|
return getLinkByDevice(feature);
|
|
13
164
|
}, [feature]);
|
|
14
165
|
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
const stationId = feature.get("station_id");
|
|
168
|
+
if (stationId) {
|
|
169
|
+
const fetchData = async () => {
|
|
170
|
+
const { station }: { station: unknown } = await client.request(
|
|
171
|
+
document,
|
|
172
|
+
{
|
|
173
|
+
__operation: "station",
|
|
174
|
+
id: feature.get("station_id"),
|
|
175
|
+
},
|
|
176
|
+
);
|
|
177
|
+
setData(station);
|
|
178
|
+
// console.log(station);
|
|
179
|
+
};
|
|
180
|
+
fetchData();
|
|
181
|
+
}
|
|
182
|
+
}, [feature]);
|
|
183
|
+
|
|
184
|
+
const hasVehicles = feature.get("num_vehicles_available") > 0;
|
|
185
|
+
|
|
15
186
|
return (
|
|
16
|
-
<div className="flex flex-col gap-2">
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
187
|
+
// <div className="flex flex-col gap-2">
|
|
188
|
+
// {feature.get("num_vehicles_available")} Fahrzeuge
|
|
189
|
+
// {link && (
|
|
190
|
+
// <a
|
|
191
|
+
// className={"my-10 flex items-center justify-center"}
|
|
192
|
+
// href={link}
|
|
193
|
+
// rel="noreferrer"
|
|
194
|
+
// target="_blank"
|
|
195
|
+
// >
|
|
196
|
+
// <RvfButton>Jetzt buchen</RvfButton>
|
|
197
|
+
// </a>
|
|
198
|
+
// )}
|
|
199
|
+
// </div>
|
|
200
|
+
<div className="flex flex-1 flex-col gap-2">
|
|
201
|
+
<div className="flex flex-1 flex-col gap-2 ">
|
|
202
|
+
<div>{feature.get("num_vehicles_available") || 0} Fahrzeuge</div>
|
|
203
|
+
{hasVehicles && data?.vehicleTypesAvailable?.length && (
|
|
204
|
+
<div className="flex flex-1 flex-col">
|
|
205
|
+
<div className="text-grey">Fahrzeug mieten</div>
|
|
206
|
+
<ul className="list-disc pl-4">
|
|
207
|
+
{data?.vehicleTypesAvailable?.map(
|
|
208
|
+
({ count, vehicleType: { id, name, vehicleImage } }) => {
|
|
209
|
+
return (
|
|
210
|
+
<li key={id}>
|
|
211
|
+
<div className={"flex items-center gap-2"}>
|
|
212
|
+
<span>{`${count} x ${name.translation[0].value}`}</span>
|
|
213
|
+
|
|
214
|
+
{vehicleImage && (
|
|
215
|
+
<img
|
|
216
|
+
alt="vehicle"
|
|
217
|
+
className={"w-12"}
|
|
218
|
+
src={vehicleImage}
|
|
219
|
+
/>
|
|
220
|
+
)}
|
|
221
|
+
</div>
|
|
222
|
+
</li>
|
|
223
|
+
);
|
|
224
|
+
},
|
|
225
|
+
)}
|
|
226
|
+
</ul>
|
|
227
|
+
</div>
|
|
228
|
+
)}
|
|
229
|
+
</div>
|
|
230
|
+
{data?.vehicleTypesAvailable?.length > 0 && link && (
|
|
231
|
+
<div>
|
|
232
|
+
<RvfLink href={link}>Jetzt Buchen</RvfLink>
|
|
233
|
+
</div>
|
|
27
234
|
)}
|
|
28
235
|
</div>
|
|
29
236
|
);
|