Skip to content

Commit 77f3a27

Browse files
Update URL contact support
1 parent 908cf3c commit 77f3a27

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

email_login/src/components/PanelWrapper.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import PopupHOC from './PopupHOC';
99
import ForgotPasswordPopup from './ForgotPasswordPopup';
1010
import DialogPopup, { DialogTypes } from './DialogPopup';
1111
import { ButtonState } from './Button';
12+
import { toCapitalize } from './../utils/StringUtils';
1213
import {
1314
createTemporalAccount,
1415
deleteTemporalAccount,
@@ -21,6 +22,7 @@ import {
2122
closeLoginWindow,
2223
getAccountByParams,
2324
getComputerName,
25+
getOsAndArch,
2426
linkAuth,
2527
linkBegin,
2628
linkStatus,
@@ -33,6 +35,7 @@ import { DEVICE_TYPE, appDomain } from '../utils/const';
3335
import DeviceNotApproved from './DeviceNotApproved';
3436
import { hashPassword } from '../utils/HashUtils';
3537
import string, { getLang } from './../lang';
38+
import { version } from './../../package.json';
3639
import './panelwrapper.scss';
3740

3841
const { errors, help, signIn, signUp } = string;
@@ -92,6 +95,7 @@ class PanelWrapper extends Component {
9295
super();
9396
this.state = {
9497
buttonSignInState: ButtonState.DISABLED,
98+
contactURL: '',
9599
currentStep: mode.SIGNIN,
96100
lastStep: [mode.SIGNIN],
97101
mode: mode.SIGNIN,
@@ -126,14 +130,19 @@ class PanelWrapper extends Component {
126130
);
127131
}
128132

133+
async componentDidMount() {
134+
const contactURL = await this.defineContactURL();
135+
this.setState({ contactURL });
136+
}
137+
129138
renderFooter = () => (
130139
<footer>
131140
<span>
132141
{help.need_help}
133142
&nbsp;
134143
<a
135144
className="footer-link"
136-
href={`https://criptext.com/${getLang}/contact/`}
145+
href={this.state.contactURL}
137146
// eslint-disable-next-line react/jsx-no-target-blank
138147
target="_blank"
139148
>
@@ -540,6 +549,13 @@ class PanelWrapper extends Component {
540549
: `${usernameOrEmailAddress}@${appDomain}`;
541550
};
542551

552+
defineContactURL = async () => {
553+
const { os, arch, installerType } = await getOsAndArch();
554+
return `https://criptext.com/${getLang}/contact?version=${version}&os=${toCapitalize(
555+
os
556+
)}&installer=${installerType}&arch=${arch}`;
557+
};
558+
543559
goToPasswordLogin = () => {
544560
this.setState(state => ({
545561
buttonSignInState: ButtonState.ENABLED,

email_login/src/utils/StringUtils.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ export const replaceCharacters = (string, positionsToExclude, character) => {
3737
return replacedString;
3838
}
3939
};
40+
41+
export const toCapitalize = (string, eachWord) => {
42+
if (!eachWord) {
43+
return string.replace(/\b\w/g, firstLetter => firstLetter.toUpperCase());
44+
}
45+
return string
46+
.split(' ')
47+
.map(word =>
48+
word.replace(/\b\w/g, firstLetter => firstLetter.toUpperCase())
49+
)
50+
.join(' ');
51+
};

email_login/src/utils/ipc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const closeLoginWindow = () => {
66

77
export const getComputerName = () => callMain('get-computer-name');
88

9+
export const getOsAndArch = () => callMain('get-os-and-arch');
10+
911
export const isWindows = () => callMain('get-isWindows');
1012

1113
export const minimizeLoginWindow = () => {

0 commit comments

Comments
 (0)