Skip to content

Commit 3408e6c

Browse files
author
ninjadev999
committed
fixed live intertiew issue
1 parent f1c1d17 commit 3408e6c

File tree

8 files changed

+333
-277
lines changed

8 files changed

+333
-277
lines changed

backend/question/views.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from rest_framework.filters import BaseFilterBackend
1414
from rest_framework.schemas import ManualSchema
1515
import random
16+
from drf_yasg.utils import swagger_auto_schema
17+
from drf_yasg import openapi
1618

1719

1820
class QuestionPracticeStaticList(APIView):
@@ -88,6 +90,8 @@ def get_schema_fields(self, view):
8890
def filter_queryset(self, request, queryset, view):
8991
return queryset.filter(owner=request.user)
9092

93+
94+
9195
class QuestionRamdomList(APIView):
9296
schema = ManualSchema(fields=[
9397
coreapi.Field(
@@ -103,24 +107,35 @@ class QuestionRamdomList(APIView):
103107
schema=coreschema.String()
104108
),
105109
])
110+
111+
position_type_param = openapi.Parameter(
112+
'position_type',
113+
openapi.IN_QUERY,
114+
description="position type name parameter",
115+
type=openapi.TYPE_STRING
116+
)
117+
106118
# filter_backends = (SimpleFilterBackend,)
107119
"""
108120
Retrieve 5 questions randomly.
109121
"""
122+
@swagger_auto_schema(manual_parameters=[position_type_param],
123+
responses={200: QuestionSerializer(many=True)})
124+
110125
def get(self, request, format=None):
111126
try:
112-
position_type = request.query_params.get('position_type') #request.query_params.get('position_type')
113-
position_sub_type = request.query_params.get('position_sub_type') #request.query_params.get('position_type')
127+
position_type_name = request.query_params.get('position_type') #request.query_params.get('position_type')
128+
position_sub_type_name = request.query_params.get('position_sub_type') #request.query_params.get('position_type')
114129

115-
if not position_type:
130+
if not position_type_name:
116131
questions = Question.objects.all()
117132
else :
118-
position_type = PositionType.objects.get(name__iexact=position_type)
119-
if not position_sub_type:
133+
position_type = PositionType.objects.get(name__iexact=position_type_name)
134+
if not position_sub_type_name:
120135
print('===== filter question: ', position_type.id)
121136
questions = Question.objects.filter(position_type=position_type.id)
122137
else:
123-
questions = Question.objects.filter(position_type=position_type.id).filter(position_sub_type=position_sub_type)
138+
questions = Question.objects.filter(position_type=position_type.id).filter(position_sub_type=position_sub_type_name)
124139
except PositionType.DoesNotExist:
125140
raise Http404
126141

frontend/src/actions/videoActions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import apiConfig from '../constants/api';
33
import defaultValues from 'constants/defaultValues'
44
import * as types from './actionTypes'
55

6-
export const getVideoQuestionsActions = (id, mode) => ({
6+
export const getVideoQuestionsActions = (positionName, mode) => ({
77
[RSAA]: {
8-
endpoint: ((mode === defaultValues.DEFAULT_PRACTICE_POSITION_TYPE) ? `${apiConfig.url}/question/practice/static` : `${apiConfig.url}/question/random/?position_type=${id}`),
8+
endpoint: ((mode === defaultValues.DEFAULT_PRACTICE_POSITION_TYPE) ? `${apiConfig.url}/question/practice/static` : `${apiConfig.url}/question/random/?position_type=${positionName}`),
99
method: 'GET',
1010
headers: { 'Content-Type': 'application/json' },
1111
types: [
Lines changed: 90 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import React from 'react'
2-
import RaisedButton from 'material-ui/RaisedButton';
32
import { Link } from 'react-router-dom';
43
import { connect } from 'react-redux';
54
import { bindActionCreators } from 'redux';
6-
import * as talentActions from '../../../actions/talentActions';
5+
import { withStyles } from '@material-ui/core/styles';
6+
import Grid from '@material-ui/core/Grid';
7+
import Button from '@material-ui/core/Button';
8+
import Typography from '@material-ui/core/Typography';
9+
import * as videoActions from 'actions/videoActions';
10+
import * as talentActions from 'actions/talentActions';
11+
import styles from 'styles';
712

813
const title = {
914
"cruise": "Cruise Staff",
@@ -18,12 +23,8 @@ const title = {
1823
"video-technician": "Video Technician",
1924
"youth-staff": "Youth Staff"
2025
}
21-
const styles={
22-
raisedButton: {
23-
whiteSpace: "normal",
24-
width: "240px",
25-
}
26-
}
26+
27+
2728
class InterviewInstructionLive extends React.Component {
2829
constructor() {
2930
super();
@@ -33,86 +34,115 @@ class InterviewInstructionLive extends React.Component {
3334
}
3435
}
3536

36-
componentDidMount() {
37-
let __this = this;
38-
setTimeout(function() {
39-
__this.props.talentActions.getCurrentTalentInfo();
40-
}, 400);
41-
}
37+
getInfoFromProps(props) {
38+
const { location, talentInfo } = this.props;
39+
let positionType = (location && location.state && location.state.positionType) ? location.state.positionType : null;
40+
let subPositionType = null;
4241

43-
componentWillReceiveProps(nextProps) {
44-
const { talentInfo } = nextProps;
4542
if (talentInfo) {
4643
const { talent_position_types, talent_position_sub_types } = talentInfo;
47-
let positionType = null;
48-
let subPositionType = null;
4944

50-
if (talent_position_types && talent_position_types.length > 0)
51-
positionType = talent_position_types[0].position_type;
45+
if (!positionType && talent_position_types && talent_position_types.length > 0)
46+
positionType = talent_position_types[0];
5247
if (talent_position_sub_types && talent_position_sub_types.length > 0)
53-
subPositionType = talent_position_sub_types[0].position_sub_type;
54-
55-
this.setState({positionType, subPositionType});
48+
subPositionType = talent_position_sub_types[0].position_sub_type;
5649
}
50+
51+
return { positionType, subPositionType };
52+
}
53+
54+
componentWillMount() {
55+
this.setState({...this.getInfoFromProps(this.props)}, () => {
56+
const { positionType } = this.state;
57+
this.props.talentActions.getCurrentTalentInfo();
58+
this.props.videoActions.getVideoQuestionsActions(positionType.position_type, 'live');
59+
});
60+
}
61+
62+
componentWillReceiveProps(nextProps) {
63+
this.setState({...this.getInfoFromProps(this.props)});
5764
}
5865

66+
onClick = () => {
67+
this.props.history.push('/live-interview', {positionType: this.state.positionType});
68+
};
69+
5970
render() {
71+
const { videoQuestions, classes } = this.props;
6072
const { positionType, subPositionType } = this.state;
6173
let positionName = positionType ? positionType.position_type : '';
6274

63-
return (<div className="video-interview">
75+
return (
76+
<div className="video-interview">
6477
<div className="video-interview-header">
6578
<h1>{`My Video Interview (${positionName})`}</h1>
6679
<h3>Live!</h3>
6780
</div>
68-
<div className="video-interview-body">
69-
<p>
70-
OK, here we go!
71-
</p>
72-
<p>
73-
The “live” Video Interview will now begin and is conducted just like the practice questions
74-
with 30 seconds to read the question and prepare your response,
75-
and up to two minutes to answer.
76-
</p>
77-
<p>
78-
Follow the onscreen prompts until all Video Interview questions have been answered.
79-
</p>
80-
<p>
81-
Remember, once you begin the actual interview,
82-
you will be “live” and unable to stop or go back,
83-
just like with an in-person interview.
84-
</p>
85-
<p>
86-
Relax, be yourself and enjoy the process. You’re gonna be great!
87-
</p>
88-
<br/><br/>
89-
{
90-
<Link to={{pathname: "/live-interview/", state: {positionType: positionType}}}>
91-
<RaisedButton
92-
label="Begin My Video Interview"
93-
className="btn-video-buttons btn-vpb"
94-
style={styles.raisedButton}
95-
secondary={true}
96-
/>
97-
</Link>
98-
}
99-
</div>
100-
</div>)
81+
<Grid container spacing={16} justify="center" alignItems="center">
82+
<Grid item lg={2} md={1} xs={12} />
83+
<Grid item lg={8} md={10} xs={12} >
84+
<div className="video-interview-body">
85+
<p>
86+
OK, here we go!
87+
</p>
88+
<p>
89+
The “live” Video Interview will now begin and is conducted just like the practice questions
90+
with 30 seconds to read the question and prepare your response,
91+
and up to two minutes to answer.
92+
</p>
93+
<p>
94+
Follow the onscreen prompts until all Video Interview questions have been answered.
95+
</p>
96+
<p>
97+
Remember, once you begin the actual interview,
98+
you will be “live” and unable to stop or go back,
99+
just like with an in-person interview.
100+
</p>
101+
<p>
102+
Relax, be yourself and enjoy the process. You’re gonna be great!
103+
</p>
104+
<br/>
105+
</div>
106+
</Grid>
107+
<Grid item lg={2} md={1} xs={12} />
108+
109+
<Grid item lg={5} md={4} xs={12} />
110+
<Grid item lg={2} md={4} xs={12} className={classes.centerText}>
111+
<Button variant="contained" size="large" fullWidth
112+
color="secondary" className={classes.generalButtonClass}
113+
disabled={!videoQuestions || videoQuestions.length <= 0}
114+
onClick={this.onClick}
115+
>
116+
<Typography className={classes.talentProfileGuideButtonTitle}>
117+
Begin My Video Interview
118+
</Typography>
119+
</Button>
120+
</Grid>
121+
<Grid item lg={5} md={4} xs={12} />
122+
123+
</Grid>
101124

125+
</div>
126+
);
102127
}
103128
}
104129

105130
function mapStateToProps(state) {
106-
const { auth, talentInfo } = state;
131+
const { auth, talentInfo, videoQuestions, videoSettings, deviceSettings } = state;
107132
return {
108133
auth: auth,
109-
talentInfo: talentInfo.value
134+
talentInfo: talentInfo.value,
135+
videoQuestions: videoQuestions.value,
136+
isLoading: !videoQuestions.isFetched,
137+
videoSettings: videoSettings,
138+
deviceSettings: deviceSettings,
110139
}
111140
}
112141
function mapDispatchToProps(dispatch) {
113142
return {
114143
talentActions: bindActionCreators(talentActions, dispatch),
144+
videoActions: bindActionCreators(videoActions, dispatch),
115145
}
116146
}
117147

118-
export default connect(mapStateToProps, mapDispatchToProps)(InterviewInstructionLive);
148+
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(InterviewInstructionLive));

0 commit comments

Comments
 (0)