@rileybathurst/paddle 0.0.75 → 0.0.77
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 +1 -1
- package/src/PaddleSunsetTourTimes.tsx +32 -0
- package/src/PaddleTime.tsx +30 -4
- package/src/index.tsx +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
type PaddleSunsetTourTimesTypes = {
|
|
4
|
+
allStrapiSunsetTourTime: {
|
|
5
|
+
nodes: {
|
|
6
|
+
id: string;
|
|
7
|
+
startDate: string;
|
|
8
|
+
endDate: string;
|
|
9
|
+
startTime: string;
|
|
10
|
+
endTime: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export const PaddleSunsetTourTimes = ({ allStrapiSunsetTourTime }: PaddleSunsetTourTimesTypes) =>
|
|
15
|
+
<section className="paddle-sunset-tour-times">
|
|
16
|
+
{/* // TODO: stylize start with a storybook */}
|
|
17
|
+
<p>*We adapt the time of our sunset tour to the sun</p>
|
|
18
|
+
{allStrapiSunsetTourTime.nodes.map((time) => {
|
|
19
|
+
const startDate = new Date(time.startDate);
|
|
20
|
+
const endDate = new Date(time.endDate);
|
|
21
|
+
|
|
22
|
+
const startTimeSplit = time.startTime.split(':');
|
|
23
|
+
const endTimeSplit = time.endTime.split(':');
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div key={time.id}>
|
|
27
|
+
<p>{startDate.toLocaleDateString()} - {endDate.toLocaleDateString()}</p>
|
|
28
|
+
<p>{startTimeSplit[0]}:{startTimeSplit[1]} - {endTimeSplit[0]}:{endTimeSplit[1]}</p>
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
})}
|
|
32
|
+
</section>
|
package/src/PaddleTime.tsx
CHANGED
|
@@ -5,10 +5,36 @@ interface TimeTypes {
|
|
|
5
5
|
finish?: string | null;
|
|
6
6
|
duration?: number | null;
|
|
7
7
|
timeframe?: string | null;
|
|
8
|
+
slug?: string | null;
|
|
9
|
+
|
|
10
|
+
allStrapiSunsetTourTime: {
|
|
11
|
+
nodes: {
|
|
12
|
+
startDate: string;
|
|
13
|
+
endDate: string;
|
|
14
|
+
startTime: string;
|
|
15
|
+
endTime: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
8
18
|
}
|
|
9
|
-
export const PaddleTime = ({ start, finish, duration, timeframe }: TimeTypes) => {
|
|
19
|
+
export const PaddleTime = ({ start, finish, duration, timeframe, slug, allStrapiSunsetTourTime }: TimeTypes) => {
|
|
10
20
|
|
|
11
21
|
// TODO: sunset is a whole thing
|
|
22
|
+
const currentDate = new Date();
|
|
23
|
+
let sunsetStartTime = '';
|
|
24
|
+
let sunsetEndTime = '';
|
|
25
|
+
|
|
26
|
+
if (slug === 'sunset') {
|
|
27
|
+
allStrapiSunsetTourTime.nodes.map((time) => {
|
|
28
|
+
const startDate = new Date(time.startDate);
|
|
29
|
+
const endDate = new Date(time.endDate);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if (startDate <= currentDate && currentDate <= endDate) {
|
|
33
|
+
sunsetStartTime = time.startTime;
|
|
34
|
+
sunsetEndTime = time.endTime;
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
}
|
|
12
38
|
|
|
13
39
|
const hairSpace = String.fromCharCode(0x200A);
|
|
14
40
|
|
|
@@ -21,9 +47,9 @@ export const PaddleTime = ({ start, finish, duration, timeframe }: TimeTypes) =>
|
|
|
21
47
|
}
|
|
22
48
|
}
|
|
23
49
|
|
|
24
|
-
if (start && finish) {
|
|
25
50
|
|
|
26
|
-
|
|
51
|
+
if (start && finish) {
|
|
52
|
+
const startHours = sunsetStartTime ? sunsetStartTime.split(':')[0] : start.split(':')[0];
|
|
27
53
|
let startHoursInt: number = Number.parseInt(startHours);
|
|
28
54
|
const startMins = start.split(':')[1];
|
|
29
55
|
const startMinsInt: number = Number.parseInt(startMins);
|
|
@@ -33,7 +59,7 @@ export const PaddleTime = ({ start, finish, duration, timeframe }: TimeTypes) =>
|
|
|
33
59
|
startHoursInt = startHoursInt - 12;
|
|
34
60
|
}
|
|
35
61
|
|
|
36
|
-
const finishHours = finish.split(':')[0];
|
|
62
|
+
const finishHours = sunsetEndTime ? sunsetEndTime.split(':')[0] : finish.split(':')[0];
|
|
37
63
|
let finishHoursInt: number = Number.parseInt(finishHours);
|
|
38
64
|
const finishMins = finish.split(':')[1];
|
|
39
65
|
const finishMinsInt: number = Number.parseInt(finishMins);
|
package/src/index.tsx
CHANGED