Skip to content

Commit 98bd8bd

Browse files
committed
Merge branch 'master' into #4-Edit-full-text-plus-replace-only-trainer
2 parents 81dc910 + 84df1e9 commit 98bd8bd

5 files changed

Lines changed: 65 additions & 48 deletions

File tree

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
import { generateNewRoomName, generateNewTrainerToken } from './room-name-generator.business';
2+
13
describe('Room name generator business spec', () => {
2-
it('', () => {
3-
const dummy = true;
4-
expect(dummy).toEqual(true);
4+
it('Newly generated room name generator should contain a name followed by a number of 4 digits separated by a - ', () => {
5+
const newRoomName = generateNewRoomName();
6+
const regexForMatchRoomName = /[a-z]*-[0-9]{4}/i;
7+
const resultMatchRoomName = regexForMatchRoomName.test(newRoomName);
8+
expect(resultMatchRoomName).toBe(true);
9+
});
10+
it('Newly generated trainer token generator should contain a name followed by a number of 4 digits separated by a - ', () => {
11+
const newTrainerToken = generateNewTrainerToken();
12+
const regexForMatchTrainerToken = /[a-z]*-[0-9]{4}/i;
13+
const resultMatchTrainerToken = regexForMatchTrainerToken.test(newTrainerToken);
14+
expect(resultMatchTrainerToken).toBe(true);
515
});
616
});

‎front/src/pods/student/student.component.tsx‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ export const StudentComponent: React.FC<Props> = props => {
1414
const { mainContainer, sessionName, studentBoard, labelTextarea } = classes;
1515

1616
return (
17-
<div className={mainContainer}>
18-
<Typography className={sessionName} variant="body1">
19-
Session name: {room}
20-
</Typography>
21-
<label className={labelTextarea} htmlFor="session">
22-
Content
23-
</label>
24-
<TextareaAutosize
25-
id="session"
26-
rowsMax={40}
27-
rowsMin={40}
28-
className={studentBoard}
29-
value={log}
30-
/>
31-
</div>
17+
<>
18+
<main className={mainContainer}>
19+
<Typography className={sessionName} variant="body1">
20+
Session name: {room}
21+
</Typography>
22+
<label className={labelTextarea} htmlFor="session">
23+
Content
24+
</label>
25+
<TextareaAutosize
26+
id="session"
27+
rowsMax={40}
28+
rowsMin={40}
29+
className={studentBoard}
30+
value={log}
31+
/>
32+
</main>
33+
</>
3234
);
3335
};

‎front/src/pods/trainer/components/new-text.component.tsx‎

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,28 @@ export const NewTextComponent: React.FC<Props> = props => {
4444

4545
return (
4646
<div className={newTextContainer}>
47-
<label className={labelTextarea} htmlFor="new-text">
48-
New text
49-
</label>
50-
<TextareaAutosize
51-
rowsMax={10}
52-
rowsMin={10}
53-
className={editTextArea}
54-
onChange={e => handleOnChange(e)}
55-
value={trainerText}
56-
/>
57-
<Button
58-
variant="contained"
59-
color="primary"
60-
className={trainerText ? sendBtn : sendBtnDisabled}
61-
onClick={() => trainerText && handleAppendTrainerTextInternal()}
62-
aria-disabled={!trainerText}
63-
disableRipple={!trainerText}
64-
>
65-
Send
66-
</Button>
47+
<form>
48+
<label className={labelTextarea} htmlFor="new-text">
49+
New text
50+
</label>
51+
<TextareaAutosize
52+
rowsMax={10}
53+
rowsMin={10}
54+
className={editTextArea}
55+
onChange={e => handleOnChange(e)}
56+
value={trainerText}
57+
/>
58+
<Button
59+
variant="contained"
60+
color="primary"
61+
className={trainerText ? sendBtn : sendBtnDisabled}
62+
onClick={() => trainerText && handleAppendTrainerTextInternal()}
63+
aria-disabled={!trainerText}
64+
disableRipple={!trainerText}
65+
>
66+
Send
67+
</Button>
68+
</form>
6769
</div>
6870
);
6971
};

‎front/src/pods/trainer/components/session.component.tsx‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,26 @@ interface Props {
99
handleSendFullContentLog: (fullContent: string) => void;
1010
}
1111

12-
const getTextArea= (elementId: string): HTMLInputElement => document.getElementById("session") as HTMLInputElement;
12+
const getTextArea = (elementId: string): HTMLInputElement =>
13+
document.getElementById('session') as HTMLInputElement;
1314

1415
const handleSetSessionContent = (sessionContent: string) => {
15-
const sessionTextArea: HTMLInputElement = getTextArea("session");
16-
sessionTextArea ? sessionTextArea.value=sessionContent : undefined;
17-
}
16+
const sessionTextArea: HTMLInputElement = getTextArea('session');
17+
sessionTextArea ? (sessionTextArea.value = sessionContent) : undefined;
18+
};
1819

1920
const getFullContent = (currenSessionContent: string) => {
20-
const sessionTextArea: HTMLInputElement = getTextArea("session");
21-
return (sessionTextArea && (sessionTextArea.value!=currenSessionContent)) ? sessionTextArea.value : undefined;
22-
}
21+
const sessionTextArea: HTMLInputElement = getTextArea('session');
22+
return sessionTextArea && sessionTextArea.value != currenSessionContent
23+
? sessionTextArea.value
24+
: undefined;
25+
};
2326

2427
export const SessionComponent: React.FC<Props> = props => {
2528
const { log, handleSendFullContentLog } = props;
2629
const { labelTextarea, studentBoard, sendBtn, undoBtn } = classes;
27-
28-
React.useEffect(()=>{
30+
31+
React.useEffect(() => {
2932
handleSetSessionContent(log);
3033
}, [log]);
3134

@@ -39,7 +42,6 @@ export const SessionComponent: React.FC<Props> = props => {
3942
rowsMax={20}
4043
rowsMin={20}
4144
className={studentBoard}
42-
disabled={false}
4345
/>
4446
<Button
4547
variant="contained"

‎front/src/pods/trainer/trainer.component.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const TrainerComponent: React.FC<Props> = props => {
3030
currentTrainerUrl={currentTrainerUrl}
3131
currentStudentUrl={currentStudentUrl}
3232
/>
33+
3334
<NewTextComponent handleAppendTrainerText={handleAppendTrainerText} />
3435
<SessionComponent log={log} handleSendFullContentLog={handleSendFullContentLog}/>
3536
</main>

0 commit comments

Comments
 (0)