@tactics/toddle-styleguide 2.0.0 → 2.0.2
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/index.tsx
CHANGED
|
@@ -81,6 +81,7 @@ import { ContextLabel } from './src/components/molecules/context-label/context-l
|
|
|
81
81
|
import { Count } from './src/components/atoms/count/count.component';
|
|
82
82
|
import { Amount } from './src/components/molecules/amount/amount.component';
|
|
83
83
|
import { TimetableEditor } from './src/components/organisms/timetable-editor/timetable-editor.component';
|
|
84
|
+
import { TimetableEditorStaff } from './src/components/organisms/timetable-editor/timetable-editor-staff.component';
|
|
84
85
|
import { InlineError } from './src/components/molecules/inline-error/inline-error.component';
|
|
85
86
|
import { InlineNotice } from './src/components/molecules/inline-notice/inline-notice.component';
|
|
86
87
|
import { SelectableListItem } from './src/components/molecules/selectable-list-item/selectable-list-item.component';
|
|
@@ -187,6 +188,7 @@ export {
|
|
|
187
188
|
Count,
|
|
188
189
|
Amount,
|
|
189
190
|
TimetableEditor,
|
|
191
|
+
TimetableEditorStaff,
|
|
190
192
|
TimeSlotRecord,
|
|
191
193
|
TimeSlotSequence,
|
|
192
194
|
InlineError,
|
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useState } from "react"
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { TimeSlotRecord } from "../../../models/time-slot-record";
|
|
4
|
+
import { TimeSlotSequence } from "../../../models/time-slot-sequence";
|
|
5
|
+
import { TimetableEditWrapper } from "./components/timetable-edit-wrapper";
|
|
6
|
+
import { TimetableEditState } from "../../../types/timetable-edit.enum";
|
|
7
|
+
import { ThemeCtx } from "../../../context/theme.context";
|
|
8
|
+
import { Stylesheet } from "./timetable-editor.styles";
|
|
9
|
+
|
|
10
|
+
interface TimetableEditorProps {
|
|
11
|
+
sequence: TimeSlotSequence;
|
|
12
|
+
onChange: (seq: TimeSlotSequence) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const TimetableEditorStaff = ({sequence, onChange}: TimetableEditorProps) => {
|
|
16
|
+
const context = useContext(ThemeCtx);
|
|
17
|
+
const styles = Stylesheet(context);
|
|
18
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
19
|
+
const [activeEditState, setActiveEditState] = useState(TimetableEditState.NONE);
|
|
20
|
+
const [first, setFrist] = useState<TimeSlotRecord>(sequence.first);
|
|
21
|
+
const [second, setSecond] = useState<TimeSlotRecord>(sequence.second);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const newSeq = TimeSlotSequence.fromEmpty();
|
|
25
|
+
newSeq.first.start = first.start;
|
|
26
|
+
newSeq.first.end = first.end;
|
|
27
|
+
newSeq.second.start = second.start;
|
|
28
|
+
newSeq.second.end = second.end;
|
|
29
|
+
newSeq.third.start = TimeSlotRecord.fromEmpty().start
|
|
30
|
+
newSeq.third.end = TimeSlotRecord.fromEmpty().end;
|
|
31
|
+
|
|
32
|
+
onChange(newSeq);
|
|
33
|
+
}, [first, second])
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<View style={styles.rootContainer}>
|
|
37
|
+
<TimetableEditWrapper
|
|
38
|
+
index={1}
|
|
39
|
+
record={first}
|
|
40
|
+
onUpdate={(seq) => {setFrist(TimeSlotRecord.fromRecord(seq))}}
|
|
41
|
+
editState={activeIndex === 1 ? activeEditState : TimetableEditState.NONE}
|
|
42
|
+
onPressTag={(val,index) => { setActiveIndex(index); setActiveEditState(val);}}
|
|
43
|
+
/>
|
|
44
|
+
<TimetableEditWrapper
|
|
45
|
+
index={2}
|
|
46
|
+
record={second}
|
|
47
|
+
onUpdate={(seq) => {setSecond(TimeSlotRecord.fromRecord(seq))}}
|
|
48
|
+
editState={activeIndex === 2 ? activeEditState : TimetableEditState.NONE}
|
|
49
|
+
onPressTag={(val,index) => { setActiveIndex(index); setActiveEditState(val);}}
|
|
50
|
+
/>
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
53
|
+
}
|