@tactics/toddle-styleguide 5.4.3 → 5.4.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "5.4.3",
3
+ "version": "5.4.4",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -1,15 +1,15 @@
1
1
  import React, {useContext, useEffect, useState} from 'react';
2
2
  import {View} from 'react-native';
3
3
  import {TimeSlotRecord} from '../../../models/time-slot-record';
4
- import {TimeSlotSequence} from '../../../models/time-slot-sequence';
5
4
  import {TimetableEditWrapper} from './components/timetable-edit-wrapper';
6
5
  import {TimetableEditState} from '../../../types/timetable-edit.enum';
7
6
  import {ThemeCtx} from '../../../context/theme.context';
8
7
  import {Stylesheet} from './timetable-editor.styles';
8
+ import {TimeSlotEmployeeSequence} from '../../../models/time-slot-employee-sequence';
9
9
 
10
10
  interface TimetableEditorStaffProps {
11
- sequence: TimeSlotSequence;
12
- onChange: (seq: TimeSlotSequence) => void;
11
+ sequence: TimeSlotEmployeeSequence;
12
+ onChange: (seq: TimeSlotEmployeeSequence) => void;
13
13
  }
14
14
 
15
15
  export const TimetableEditorStaff = ({
@@ -22,17 +22,41 @@ export const TimetableEditorStaff = ({
22
22
  const [activeEditState, setActiveEditState] = useState(
23
23
  TimetableEditState.NONE
24
24
  );
25
- const [first, setFrist] = useState<TimeSlotRecord>(sequence.first);
25
+ const [first, setFirst] = useState<TimeSlotRecord>(sequence.first);
26
26
  const [second, setSecond] = useState<TimeSlotRecord>(sequence.second);
27
+ const [third, setThird] = useState<TimeSlotRecord>(sequence.third);
28
+ const [fourth, setFourth] = useState<TimeSlotRecord>(sequence.fourth);
29
+ const [fifth, setFifth] = useState<TimeSlotRecord>(sequence.fifth);
30
+ const [sixth, setSixth] = useState<TimeSlotRecord>(sequence.sixth);
31
+ const [seventh, setSeventh] = useState<TimeSlotRecord>(sequence.seventh);
32
+ const [eighth, setEighth] = useState<TimeSlotRecord>(sequence.eighth);
33
+ const [nineth, setNinth] = useState<TimeSlotRecord>(sequence.ninth);
34
+ const [tenth, setTenth] = useState<TimeSlotRecord>(sequence.tenth);
35
+
27
36
 
28
37
  useEffect(() => {
29
- const newSeq = TimeSlotSequence.fromEmpty();
38
+ const newSeq = TimeSlotEmployeeSequence.fromEmpty();
30
39
  newSeq.first.start = first.start;
31
40
  newSeq.first.end = first.end;
32
41
  newSeq.second.start = second.start;
33
42
  newSeq.second.end = second.end;
34
- newSeq.third.start = TimeSlotRecord.fromEmpty().start;
35
- newSeq.third.end = TimeSlotRecord.fromEmpty().end;
43
+ newSeq.third.start = third.start;
44
+ newSeq.third.end = third.end;
45
+
46
+ newSeq.fourth.start = fourth.start;
47
+ newSeq.fourth.end = fourth.end;
48
+ newSeq.fifth.start = fifth.start;
49
+ newSeq.fifth.end = fifth.end;
50
+ newSeq.sixth.start = sixth.start;
51
+ newSeq.sixth.end = sixth.end;
52
+ newSeq.seventh.start = seventh.start;
53
+ newSeq.seventh.end = seventh.end;
54
+ newSeq.eighth.start = eighth.start;
55
+ newSeq.eighth.end = eighth.end;
56
+ newSeq.ninth.start = nineth.start;
57
+ newSeq.ninth.end = nineth.end;
58
+ newSeq.tenth.start = tenth.start;
59
+ newSeq.tenth.end = tenth.end;
36
60
 
37
61
  onChange(newSeq);
38
62
  }, [first, second]);
@@ -43,7 +67,7 @@ export const TimetableEditorStaff = ({
43
67
  index={1}
44
68
  record={first}
45
69
  onUpdate={(seq) => {
46
- setFrist(TimeSlotRecord.fromRecord(seq));
70
+ setFirst(TimeSlotRecord.fromRecord(seq));
47
71
  }}
48
72
  editState={
49
73
  activeIndex === 1 ? activeEditState : TimetableEditState.NONE
@@ -67,6 +91,118 @@ export const TimetableEditorStaff = ({
67
91
  setActiveEditState(val);
68
92
  }}
69
93
  />
94
+ <TimetableEditWrapper
95
+ index={3}
96
+ record={third}
97
+ onUpdate={(seq) => {
98
+ setThird(TimeSlotRecord.fromRecord(seq));
99
+ }}
100
+ editState={
101
+ activeIndex === 3 ? activeEditState : TimetableEditState.NONE
102
+ }
103
+ onPressTag={(val, index) => {
104
+ setActiveIndex(index);
105
+ setActiveEditState(val);
106
+ }}
107
+ />
108
+ <TimetableEditWrapper
109
+ index={4}
110
+ record={fourth}
111
+ onUpdate={(seq) => {
112
+ setFourth(TimeSlotRecord.fromRecord(seq));
113
+ }}
114
+ editState={
115
+ activeIndex === 4 ? activeEditState : TimetableEditState.NONE
116
+ }
117
+ onPressTag={(val, index) => {
118
+ setActiveIndex(index);
119
+ setActiveEditState(val);
120
+ }}
121
+ />
122
+ <TimetableEditWrapper
123
+ index={5}
124
+ record={fifth}
125
+ onUpdate={(seq) => {
126
+ setFifth(TimeSlotRecord.fromRecord(seq));
127
+ }}
128
+ editState={
129
+ activeIndex === 5 ? activeEditState : TimetableEditState.NONE
130
+ }
131
+ onPressTag={(val, index) => {
132
+ setActiveIndex(index);
133
+ setActiveEditState(val);
134
+ }}
135
+ />
136
+ <TimetableEditWrapper
137
+ index={6}
138
+ record={sixth}
139
+ onUpdate={(seq) => {
140
+ setSixth(TimeSlotRecord.fromRecord(seq));
141
+ }}
142
+ editState={
143
+ activeIndex === 6 ? activeEditState : TimetableEditState.NONE
144
+ }
145
+ onPressTag={(val, index) => {
146
+ setActiveIndex(index);
147
+ setActiveEditState(val);
148
+ }}
149
+ />
150
+ <TimetableEditWrapper
151
+ index={7}
152
+ record={seventh}
153
+ onUpdate={(seq) => {
154
+ setSeventh(TimeSlotRecord.fromRecord(seq));
155
+ }}
156
+ editState={
157
+ activeIndex === 7 ? activeEditState : TimetableEditState.NONE
158
+ }
159
+ onPressTag={(val, index) => {
160
+ setActiveIndex(index);
161
+ setActiveEditState(val);
162
+ }}
163
+ />
164
+ <TimetableEditWrapper
165
+ index={8}
166
+ record={eighth}
167
+ onUpdate={(seq) => {
168
+ setEighth(TimeSlotRecord.fromRecord(seq));
169
+ }}
170
+ editState={
171
+ activeIndex === 8 ? activeEditState : TimetableEditState.NONE
172
+ }
173
+ onPressTag={(val, index) => {
174
+ setActiveIndex(index);
175
+ setActiveEditState(val);
176
+ }}
177
+ />
178
+ <TimetableEditWrapper
179
+ index={9}
180
+ record={nineth}
181
+ onUpdate={(seq) => {
182
+ setNinth(TimeSlotRecord.fromRecord(seq));
183
+ }}
184
+ editState={
185
+ activeIndex === 9 ? activeEditState : TimetableEditState.NONE
186
+ }
187
+ onPressTag={(val, index) => {
188
+ setActiveIndex(index);
189
+ setActiveEditState(val);
190
+ }}
191
+ />
192
+ <TimetableEditWrapper
193
+ index={10}
194
+ record={tenth}
195
+ onUpdate={(seq) => {
196
+ setTenth(TimeSlotRecord.fromRecord(seq));
197
+ }}
198
+ editState={
199
+ activeIndex === 10 ? activeEditState : TimetableEditState.NONE
200
+ }
201
+ onPressTag={(val, index) => {
202
+ setActiveIndex(index);
203
+ setActiveEditState(val);
204
+ }}
205
+ />
70
206
  </View>
71
207
  );
72
208
  };
@@ -0,0 +1,165 @@
1
+ import {TimeSlotRecord, TimeSlotRecordJSON} from './time-slot-record';
2
+
3
+ export class TimeSlotEmployeeSequence {
4
+ private constructor(
5
+ public readonly first: TimeSlotRecord,
6
+ public readonly second: TimeSlotRecord,
7
+ public readonly third: TimeSlotRecord,
8
+ public readonly fourth: TimeSlotRecord,
9
+ public readonly fifth: TimeSlotRecord,
10
+ public readonly sixth: TimeSlotRecord,
11
+ public readonly seventh: TimeSlotRecord,
12
+ public readonly eighth: TimeSlotRecord,
13
+ public readonly ninth: TimeSlotRecord,
14
+ public readonly tenth: TimeSlotRecord,
15
+ ) {}
16
+
17
+ static fromAttendanceRecordArray(arr: TimeSlotRecord[]): TimeSlotEmployeeSequence {
18
+ return new TimeSlotEmployeeSequence(
19
+ arr[0] ? arr[0] : TimeSlotRecord.fromEmpty(),
20
+ arr[1] ? arr[1] : TimeSlotRecord.fromEmpty(),
21
+ arr[2] ? arr[2] : TimeSlotRecord.fromEmpty(),
22
+ arr[3] ? arr[2] : TimeSlotRecord.fromEmpty(),
23
+ arr[4] ? arr[4] : TimeSlotRecord.fromEmpty(),
24
+ arr[5] ? arr[5] : TimeSlotRecord.fromEmpty(),
25
+ arr[6] ? arr[6] : TimeSlotRecord.fromEmpty(),
26
+ arr[7] ? arr[7] : TimeSlotRecord.fromEmpty(),
27
+ arr[8] ? arr[8] : TimeSlotRecord.fromEmpty(),
28
+ arr[9] ? arr[9] : TimeSlotRecord.fromEmpty(),
29
+ );
30
+ }
31
+
32
+ static fromTimeSlotRecordJSONArray(
33
+ arr: TimeSlotRecordJSON[]
34
+ ): TimeSlotEmployeeSequence {
35
+ return new TimeSlotEmployeeSequence(
36
+ TimeSlotRecord.fromJson(
37
+ arr[0] ? arr[0] : TimeSlotRecord.fromEmpty().toJson()
38
+ ),
39
+ TimeSlotRecord.fromJson(
40
+ arr[1] ? arr[1] : TimeSlotRecord.fromEmpty().toJson()
41
+ ),
42
+ TimeSlotRecord.fromJson(
43
+ arr[2] ? arr[2] : TimeSlotRecord.fromEmpty().toJson()
44
+ ),
45
+ TimeSlotRecord.fromJson(
46
+ arr[3] ? arr[3] : TimeSlotRecord.fromEmpty().toJson()
47
+ ),
48
+ TimeSlotRecord.fromJson(
49
+ arr[4] ? arr[4] : TimeSlotRecord.fromEmpty().toJson()
50
+ ),
51
+ TimeSlotRecord.fromJson(
52
+ arr[5] ? arr[5] : TimeSlotRecord.fromEmpty().toJson()
53
+ ),
54
+ TimeSlotRecord.fromJson(
55
+ arr[6] ? arr[6] : TimeSlotRecord.fromEmpty().toJson()
56
+ ),
57
+ TimeSlotRecord.fromJson(
58
+ arr[7] ? arr[7] : TimeSlotRecord.fromEmpty().toJson()
59
+ ),
60
+ TimeSlotRecord.fromJson(
61
+ arr[8] ? arr[8] : TimeSlotRecord.fromEmpty().toJson()
62
+ ),
63
+ TimeSlotRecord.fromJson(
64
+ arr[9] ? arr[9] : TimeSlotRecord.fromEmpty().toJson()
65
+ )
66
+ );
67
+ }
68
+
69
+ static fromEmpty(): TimeSlotEmployeeSequence {
70
+ return new TimeSlotEmployeeSequence(
71
+ TimeSlotRecord.fromEmpty(),
72
+ TimeSlotRecord.fromEmpty(),
73
+ TimeSlotRecord.fromEmpty(),
74
+ TimeSlotRecord.fromEmpty(),
75
+ TimeSlotRecord.fromEmpty(),
76
+ TimeSlotRecord.fromEmpty(),
77
+ TimeSlotRecord.fromEmpty(),
78
+ TimeSlotRecord.fromEmpty(),
79
+ TimeSlotRecord.fromEmpty(),
80
+ TimeSlotRecord.fromEmpty(),
81
+ );
82
+ }
83
+
84
+ asArray(): TimeSlotRecord[] {
85
+ return [this.first, this.second, this.third, this.fourth, this.fifth, this.sixth, this.seventh, this.eighth, this.ninth , this.tenth];
86
+ }
87
+
88
+ toJson(): TimeSlotRecord[] {
89
+ return this.asArray();
90
+ }
91
+
92
+ addToNextSlot(checkInOutTime: string) {
93
+ if (this.first.start === '') {
94
+ this.first.start = checkInOutTime;
95
+ } else if (this.first.end === undefined || this.first.end === '') {
96
+ this.first.end = checkInOutTime;
97
+ } else if (this.second.start === '') {
98
+ this.second.start = checkInOutTime;
99
+ } else if (this.second.end === undefined || this.second.end === '') {
100
+ this.second.end = checkInOutTime;
101
+ } else if (this.third.start === '') {
102
+ this.third.start = checkInOutTime;
103
+ } else if (this.third.end === undefined || this.third.end === '') {
104
+ this.third.end = checkInOutTime;
105
+ } else if (this.fourth.start === '') {
106
+ this.fourth.start = checkInOutTime;
107
+ } else if (this.fourth.end === undefined || this.fourth.end === '') {
108
+ this.fourth.end = checkInOutTime;
109
+ } else if (this.fifth.start === '') {
110
+ this.fifth.start = checkInOutTime;
111
+ } else if (this.fifth.end === undefined || this.fifth.end === '') {
112
+ this.fifth.end = checkInOutTime;
113
+ } else if (this.sixth.start === '') {
114
+ this.sixth.start = checkInOutTime;
115
+ } else if (this.sixth.end === undefined || this.sixth.end === '') {
116
+ this.sixth.end = checkInOutTime;
117
+ } else if (this.seventh.start === '') {
118
+ this.seventh.start = checkInOutTime;
119
+ } else if (this.seventh.end === undefined || this.seventh.end === '') {
120
+ this.seventh.end = checkInOutTime;
121
+ } else if (this.eighth.start === '') {
122
+ this.eighth.start = checkInOutTime;
123
+ } else if (this.eighth.end === undefined || this.eighth.end === '') {
124
+ this.eighth.end = checkInOutTime;
125
+ } else if (this.ninth.start === '') {
126
+ this.ninth.start = checkInOutTime;
127
+ } else if (this.ninth.end === undefined || this.ninth.end === '') {
128
+ this.ninth.end = checkInOutTime;
129
+ } else if (this.tenth.start === '') {
130
+ this.tenth.start = checkInOutTime;
131
+ } else if (this.tenth.end === undefined || this.tenth.end === '') {
132
+ this.tenth.end = checkInOutTime;
133
+ }
134
+ }
135
+
136
+ isComplete(): boolean {
137
+ return (
138
+ this.first.isComplete() &&
139
+ this.second.isComplete() &&
140
+ this.third.isComplete() &&
141
+ this.fourth.isComplete() &&
142
+ this.fifth.isComplete() &&
143
+ this.sixth.isComplete() &&
144
+ this.seventh.isComplete() &&
145
+ this.eighth.isComplete() &&
146
+ this.ninth.isComplete() &&
147
+ this.tenth.isComplete()
148
+ );
149
+ }
150
+
151
+ isEmpty(): boolean {
152
+ return (
153
+ this.first.isEmpty() &&
154
+ this.second.isEmpty() &&
155
+ this.third.isEmpty() &&
156
+ this.fourth.isEmpty() &&
157
+ this.fifth.isEmpty() &&
158
+ this.sixth.isEmpty() &&
159
+ this.seventh.isEmpty() &&
160
+ this.eighth.isEmpty() &&
161
+ this.ninth.isEmpty() &&
162
+ this.tenth.isEmpty()
163
+ );
164
+ }
165
+ }