Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "Snami&Potok",
"version": "1.5.3",
"version": "1.6.5",
"description": "Расширение позволяет отправлять сотрудников из платформы для рекрутмента Potok напрямую в сервис адаптации Снами",
"permissions": [
"tabs",
"activeTab",
"declarativeContent",
"storage",
"https://app.potok.io/*",
"https://snami.work/*",
Expand All @@ -15,6 +14,11 @@
"scripts": ["src/scripts/config.js", "src/scripts/api.js", "src/scripts/background.js"],
"persistent": false
},
"browser_specific_settings": {
"gecko": {
"id": "addon@snami.work"
}
},
"browser_action": {
"default_popup": "src/popup.html",
"default_icon": {
Expand Down
39 changes: 3 additions & 36 deletions src/scripts/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,8 @@ class Api {
})
.then(async response => {
const { ok, status } = response;
// console.log(
// `${method}: ${this.baseUrl}${url}${uriSuffix ? `/${uriSuffix}` : ''}\n`,
// ` response:`,
// response,
// );

if (ok) {
const data = await response.json();
// console.log(
// `${method}: ${this.baseUrl}${url}${uriSuffix ? `/${uriSuffix}` : ''}\n`,
// body,
// ` resultData:`,
// data,
// ` status:`,
// status,
// );
if (retry && onRetryResolve) {
onRetryResolve({ ok, data, headers: response.headers, status });
} else {
Expand All @@ -76,27 +62,8 @@ class Api {
} catch (error) {
problem = error;
}
// console.log(
// `${method}: ${this.baseUrl}${url}${uriSuffix ? `/${uriSuffix}` : ''}\n`,
// body,
// ` problem:`,
// problem,
// ` status:`,
// status
// );
let snamiError = problem && problem.error && problem.error.message;
try {
if (
problem &&
problem.error &&
problem.error.data &&
Array.isArray(problem.error.data)
) {
snamiError = `${snamiError} ${problem.error.data
.map(({ key, value }) => (key && value ? `${key}: ${value}` : ''))
.join(', ')}`;
}
} catch {}

const potokErrors =
problem && problem.errors && Object.values(problem.errors).join(', ');
if (retry && onRetryResolve) {
Expand Down Expand Up @@ -217,14 +184,14 @@ const requestPotokLogin = (email, password) => {
apiPotok.post('auth/sign_in.json', { email, password }).then(response => {
const { ok, headers, problem } = response;
if (ok && headers && headers.get('access-token')) {
const aurhHeaders = {
const authHeaders = {
'access-token': headers.get('access-token'),
client: headers.get('client'),
uid: headers.get('uid'),
'token-type': headers.get('token-type'),
expiry: headers.get('expiry'),
};
resolve({ ...response, data: aurhHeaders });
resolve({ ...response, data: authHeaders });
} else {
resolve({
...response,
Expand Down
35 changes: 27 additions & 8 deletions src/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ class App {
};

_initApp = () => {
storageSync.get(
['snamiHeaders', 'potokHeaders', 'snamiServerType'],
({ snamiHeaders = null, potokHeaders = null, snamiServerType = 0 }) => {
storageSync.get(['snamiHeaders', 'potokHeaders', 'snamiServerType'],
(response = {}) => {
const {snamiHeaders = null, potokHeaders = null, snamiServerType = 0} = response;
this.snamiHeaders = snamiHeaders;
this.snamiServerType = snamiServerType;
this.potokHeaders = potokHeaders;
Expand Down Expand Up @@ -496,7 +496,7 @@ class App {
hrId: +this.applicant.hrId,
mentorId: +this.applicant.mentorId,
tutorId: +this.applicant.tutorId,
salary: +this.applicant.salary,
salary: +this.applicant.salary.replace(/\s/g, ''),
phone,
birthday: this.birthdsayDatepicker.getDate('yyyy-mm-dd') || '',
startedDate: this.startedDatepicker.getDate('yyyy-mm-dd') || '',
Expand All @@ -518,7 +518,7 @@ class App {
hrId: +this.applicant.hrId,
mentorId: +this.applicant.mentorId,
tutorId: +this.applicant.tutorId,
salary: +this.applicant.salary,
salary: +this.applicant.salary.replace(/\s/g, ''),
phone,
birthday: this.birthdsayDatepicker.getDate('yyyy-mm-dd') || '',
startedDate: this.startedDatepicker.getDate('yyyy-mm-dd') || '',
Expand Down Expand Up @@ -550,7 +550,11 @@ class App {
};

_onClickElement = event => {
const { target: { id: targetId, parentElement: { id: parentId } = {} } = {} } = event;
// const { target: { id: targetId, parentElement: { id: parentId } = {} } = {} } = event;
const { target = {} } = event;
const targetId = target.id;
const { parentElement = {} } = target;
const parentId = parentElement.id;
if (targetId === id_logoutSnami || parentId === id_logoutSnami) {
this._logOutSnami().then(() => {
storageLocal.set({ authLogin: '', authPassword: '' }, () => {
Expand Down Expand Up @@ -646,17 +650,31 @@ class App {
if (!this.applicant.hrId) {
target.value = '';
}
this._validateFormItem(
this.applicant.hrId,
form_selectHrId,
'Обязательное поле',
this._validatorNoEmpty
);
} else {
this.applicant.hrId = '';
this._hideFormItemError(form_selectHrId);
}
break;
case form_selectMentorId:
if (type === 'blur') {
if (!this.applicant.mentorId) {
target.value = '';
}
this._validateFormItem(
this.applicant.mentorId,
form_selectMentorId,
'Обязательное поле',
this._validatorNoEmpty
);
} else {
this.applicant.mentorId = '';
this._hideFormItemError(form_selectMentorId);
}
break;
case form_selectTutorId:
Expand Down Expand Up @@ -867,6 +885,7 @@ class App {
break;
case form_inputSex:
this.applicant.sex = !!value;
this._hideFormItemError(form_inputSex);
break;
case form_authLogin:
storageLocal.set({ authLogin: value }, () => {});
Expand Down Expand Up @@ -957,8 +976,8 @@ class App {

_getApplicantContent = () => {
return new Promise((resolve, reject) => {
chrome.tabs.getSelected(null, tab => {
const { url } = tab;
chrome.tabs.query({active: true, windowId: chrome.windows.WINDOW_ID_CURRENT}, tab => {
const { url } = tab[0];
let jobId = '';
let applicantId = '';
// https://app.potok.io/applicants/6755512/
Expand Down
2 changes: 0 additions & 2 deletions src/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ const FRONT_URL_SNAMI = {

const storageSync = chrome.storage.sync;
const storageLocal = chrome.storage.local;
// storageSync.clear();
// storageLocal.clear();
10 changes: 4 additions & 6 deletions src/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,10 @@ const template_candidateForm = ({
<div class="form-item">
<label class="form-label required" htmlFor="phone">Пол</label>
<div class="form-radios">
<label><input name="${form_inputSex}" type="radio" value="0" ${
sex === true ? 'checked' : ''
}><span class="checkmark"></span> Мужской</label>
<label><input name="${form_inputSex}" type="radio" value="1" ${
sex === false ? 'checked' : ''
}><span class="checkmark"></span> Женский</label>
<label><input name="${form_inputSex}" type="radio" value="0" ${sex === true ? 'checked' : ''}>
<span class="checkmark"></span> Мужской</label>
<label><input name="${form_inputSex}" type="radio" value="1" ${sex === false ? 'checked' : ''}>
<span class="checkmark"></span> Женский</label>
</div>
<div id="${form_inputSex}_error"></div>
</div>
Expand Down
Loading