Skip to content

Commit c3720da

Browse files
author
ninjadev999
committed
Merge pull request #116 from goldenstar999/backend
updated video interview on admin part
2 parents ea57435 + af42b08 commit c3720da

File tree

9 files changed

+56
-30
lines changed

9 files changed

+56
-30
lines changed

frontend/src/components/shiptalent/videos/videoPlayer.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import styles from 'styles';
99

1010
class VideoPlayer extends Component {
1111
render() {
12-
const { title, url, classes } = this.props;
13-
console.log('===== VideoPlayer: title: ', title);
12+
const { title, url, width, height, classes } = this.props;
1413
return (
1514
<Grid container spacing={16} justify="center" alignItems="center">
1615
{title && (
@@ -24,10 +23,9 @@ class VideoPlayer extends Component {
2423
<ReactPlayer
2524
url={url}
2625
className={url ? classes.clientVideoPlayer : classes.clientEmptyVideoPlayer}
27-
width={'480px'}
28-
height={'270px'}
26+
width={width ? width : '480px'}
27+
height={height ? height : '270px'}
2928
controls={true}
30-
light
3129
/>
3230
</Grid>
3331
</Grid>

frontend/src/containers/admin/EditProfiles/Videos/EditGreetingVideos/EditGreetingVideos.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Spacer from 'components/general/spacer';
77
import AdminForm from 'components/shiptalent/forms/adminForm';
88
import OverviewVideo from '../OverviewVideo';
99
import IntervewVideoItem from '../InterviewVideos/InterviewVideoItem';
10+
import { getLiveVideosByPositionName, getCurrentTalentPositionName } from 'utils/appUtils';
1011
import { adminStyles } from 'styles';
1112

1213

@@ -78,7 +79,7 @@ class EditGreetingVideos extends React.Component {
7879
<Grid item lg={2} md={1} xs={12}/>
7980
<Grid item xs={12}><Spacer size={15} /></Grid>
8081
<Grid item xs={12}>
81-
<IntervewVideoItem videos={profile && profile.talent_videos} />
82+
<IntervewVideoItem videos={profile && getLiveVideosByPositionName(profile.talent_videos, getCurrentTalentPositionName(profile))} />
8283
</Grid>
8384
<Grid item xs={12}><Spacer size={30} /></Grid>
8485
</Grid>
@@ -93,8 +94,8 @@ class EditGreetingVideos extends React.Component {
9394
talent={profile}
9495
showName
9596
formSubTitle="Video Greetings"
96-
nextLink={{pathname: "/admin/edit-profiles/edit-profile", state: {profileId: profile ? profile.id : null}}}
97-
nextButtonTitle="Back to Profile"
97+
nextLink={{pathname: "/admin/edit-profiles/profile-videos"}}
98+
nextButtonTitle="Back to VIDEOS"
9899
>
99100
{this.renderContent()}
100101
</AdminForm>

frontend/src/containers/admin/EditProfiles/Videos/GreetingVideoItem.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import { adminStyles } from 'styles';
1010
class GreetingVideoItem extends Component {
1111

1212
render() {
13-
const { videos, classes } = this.props;
14-
let total = 4;
15-
let currentVideos = videos ? videos.length : 0;
16-
let approved = (total && videos) ? videos.filter(video => video.approved).length : 0;
13+
const { greetingVideos, interviewVideos, classes } = this.props;
14+
let total = 9;
15+
let currentVideos = greetingVideos ? greetingVideos.length : 0;
16+
let currentInterviewVideos = interviewVideos ? interviewVideos.length : 0;
17+
currentVideos += currentInterviewVideos;
18+
let approved = (greetingVideos ? greetingVideos.filter(video => video.approved).length: 0) + currentInterviewVideos;
1719
let pending = currentVideos - approved;
1820

1921
return (

frontend/src/containers/admin/EditProfiles/Videos/InterviewVideos/InterviewVideoItem.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Typography from '@material-ui/core/Typography';
66
import Grid from '@material-ui/core/Grid';
77
import Button from '@material-ui/core/Button';
88
import ApprovedStatus from '../../ApprovedStatus';
9-
import { getLiveVideoNumbers } from 'utils/appUtils';
109
import { adminStyles } from 'styles';
1110

1211

@@ -25,7 +24,8 @@ class InterviewVideoItem extends Component {
2524

2625
render() {
2726
const { videos } = this.props;
28-
const videoCount = videos ? getLiveVideoNumbers(videos) : 0;
27+
const videoCount = videos ? videos.length : 0;
28+
2929
return (
3030
<Grid container spacing={16} direction="column" justify="center" alignItems="center">
3131
<Grid item xs={12}>

frontend/src/containers/admin/EditProfiles/Videos/InterviewVideos/LiveInterviewVideo.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import Panel from 'components/general/panel';
77
import VideoPlayer from 'components/shiptalent/videos/videoPlayer';
88
import AdminForm from 'components/shiptalent/forms/adminForm';
99
import QuestionSelection from './QuestionSelection';
10-
import { getLiveVideos } from 'utils/appUtils';
1110
import defaultValues from 'constants/defaultValues';
1211
import * as talentActions from 'actions/talentActions';
12+
import { getLiveVideosByPositionName, getCurrentTalentPositionName } from 'utils/appUtils';
1313
import { adminStyles } from 'styles';
1414
import TechnicianQuestionSelection from './TechnicianQuestionSelection';
1515

@@ -23,7 +23,9 @@ class LiveInterviewVideo extends Component {
2323

2424
getInfoFromProps = (props) => {
2525
const { profile } = props;
26-
let videos = (profile && profile.talent_videos) ? getLiveVideos(profile.talent_videos) : [];
26+
let videos = (profile && profile.talent_videos)
27+
? getLiveVideosByPositionName(profile.talent_videos, getCurrentTalentPositionName(profile))
28+
: [];
2729
return { videos };
2830
};
2931

@@ -43,33 +45,35 @@ class LiveInterviewVideo extends Component {
4345
const { selectedQuestionId, videos } = this.state;
4446
const { profile, classes } = this.props;
4547
const video = videos ? videos[selectedQuestionId] : 0;
46-
const positionType = (profile && profile.talent_position_types && profile.talent_position_types[0])
47-
? profile.talent_position_types[0] : null;
48+
const positionName = getCurrentTalentPositionName(profile);
4849
const subPositionType = (profile && profile.talent_position_sub_types && profile.talent_position_sub_types[0])
4950
? profile.talent_position_sub_types[0].position_sub_type : null;
5051
return (
5152
<Panel>
5253
<Grid container spacing={24}>
5354
<Grid item md={1} xs />
5455
<Grid item md={10} xs={12}>
55-
{ (positionType === defaultValues.DEFAULT_TECHNICIAN_POSITION_TYPE)
56-
? <QuestionSelection positionType={positionType} selectedQuestionId={`${selectedQuestionId}`} onChange={this.handleChange} />
57-
: <TechnicianQuestionSelection subPositionType={subPositionType} selectedQuestionId={`${selectedQuestionId}`} onChange={this.handleChange} />
56+
{ (positionName === defaultValues.DEFAULT_TECHNICIAN_POSITION_TYPE)
57+
? <TechnicianQuestionSelection subPositionType={subPositionType} selectedQuestionId={`${selectedQuestionId}`} onChange={this.handleChange} />
58+
: <QuestionSelection positionName={positionName} selectedQuestionId={`${selectedQuestionId}`} onChange={this.handleChange} />
5859
}
5960
</Grid>
6061
<Grid item md={1} xs />
6162

62-
<Grid item xs={12} >
63-
<Grid container spacing={8} alignItems="center">
63+
<Grid item md={1} xs />
64+
<Grid item xs={10} >
65+
<Grid container spacing={8} justify="center" alignItems="flex-start">
6466
<Grid item sm={6} xs={12}>
6567
{ video && video.question }
6668
</Grid>
6769
<Grid item sm={6} xs={12} className={classes.centerText}>
68-
<VideoPlayer url={video ? video.url : ''} />
70+
<VideoPlayer url={video ? video.url : ''} width={'100%'} height={'100%'}/>
6971
</Grid>
7072
<Grid item xs />
7173
</Grid>
7274
</Grid>
75+
<Grid item md={1} xs />
76+
7377
</Grid>
7478
</Panel>
7579
);

frontend/src/containers/admin/EditProfiles/Videos/InterviewVideos/QuestionSelection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ class QuestionSelection extends Component {
2727
};
2828

2929
render() {
30-
const { positionType } = this.props;
30+
const { positionName } = this.props;
3131
const { selectedQuestionId } = this.state;
3232
return (
3333
<Grid container spacing={16} justify="center" alignItems="center">
3434
<Grid item xs={12}></Grid>
3535
<Grid item xs={12}>
3636
<FormControl component="fieldset">
37-
<FormLabel component="legend">{`${positionType ? positionType.position_type : ''} Questions:`}</FormLabel>
37+
<FormLabel component="legend">{`${positionName && positionName} Questions:`}</FormLabel>
3838
<RadioGroup
3939
aria-label="selectedQuestionId"
4040
name="selectedQuestionId"

frontend/src/containers/admin/EditProfiles/Videos/ProfileVideos.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class ProfileVideos extends React.Component {
1414

1515
getInfoFromProps = (props) => {
1616
const { location } = props;
17-
// let profile = (location && location.state && location.state.profile) ? location.state.profile : null;
1817
let profileId = (location && location.state && location.state.profileId) ? location.state.profileId : null;
1918
return { profileId };
2019
};

frontend/src/containers/admin/EditProfiles/Videos/ProfileVideosTable.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ import Grid from '@material-ui/core/Grid';
44
import Spacer from 'components/general/spacer';
55
import GreetingVideoItem from './GreetingVideoItem';
66
import PositionVideoItem from './PositionVideoItem';
7-
import { filterSubSkillVideosByPosition, getSubSkillVideosByPositionType } from 'utils/appUtils';
7+
import { getSubSkillVideosByPositionType, getLiveVideosByPositionName, getCurrentTalentPositionName } from 'utils/appUtils';
88
import { adminStyles } from 'styles';
99

1010

1111
class ProfileVideosTable extends Component {
1212
render() {
1313
const { profile, greetingsVideos, interviewVideos, subSkillVideos, allPositionTypes, allSkills, classes } = this.props;
14-
14+
1515
return (
1616
<Grid container spacing={32} justify="center" alignItems="center">
1717
<Grid item lg={4} md={6} xs={12}>
18-
<GreetingVideoItem videos={greetingsVideos} interviewVideos={interviewVideos}/>
18+
<GreetingVideoItem
19+
greetingVideos={greetingsVideos}
20+
interviewVideos={getLiveVideosByPositionName(interviewVideos, getCurrentTalentPositionName(profile))}
21+
/>
1922
</Grid>
2023
{profile && allPositionTypes && allPositionTypes.map(positionType => {
2124
if (positionType.video_audition_button_title) {

frontend/src/utils/appUtils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ export function getLiveVideos(talent_videos) {
167167
return res;
168168
}
169169

170+
export function getLiveVideosByPositionName(talent_videos, positionName) {
171+
let res = [];
172+
if (talent_videos && talent_videos.length > 0) {
173+
for (let i = 0; i < talent_videos.length; i ++) {
174+
let video = talent_videos[i];
175+
if (video.position_type === positionName) res.push(video);
176+
}
177+
}
178+
return res;
179+
}
180+
170181
export function checkPreviousShipMedical(medicals) {
171182
let checkingMedicals = [
172183
'Pregnancy',
@@ -221,6 +232,14 @@ export function getLanguageIndex(name) {
221232
return defaultValues.LANGUAGES.indexOf(name);
222233
}
223234

235+
export function getCurrentTalentPositionName(talent) {
236+
return talent.talent_position_types[0] ? talent.talent_position_types[0].position_type : null;
237+
}
238+
239+
export function getCurrentTalentPositionSubType(talent) {
240+
return talent.talent_position_sub_types[0] ? talent.talent_position_sub_types[0].position_sub_type : null
241+
}
242+
224243
export function findRelatedSkillByPositionName(skills, positionName) {
225244
return skills.find(function(skill) {
226245
return skill.related_position_type === positionName;

0 commit comments

Comments
 (0)