mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 06:42:14 +00:00
Hooked up the Pricing page to the footer
This commit is contained in:
1 parent
3bbb34ba07
commit
7e85c0ec81
5 files changed
+329
-47
No files matched your search
@@ -18,6 +18,7 @@ const FAKEYOU_TRANSLATIONS: any = {
|
||||
textToSpeech: 'Text to Speech',
|
||||
upload: 'Upload',
|
||||
video: 'Video',
|
||||
pricing: 'Pricing'
|
||||
},
|
||||
topNav: {
|
||||
aboutUs: 'About Us',
|
||||
|
||||
@@ -4,7 +4,7 @@ class FrontendUrlConfig {
|
||||
|
||||
// Main
|
||||
|
||||
static indexPage() : string {
|
||||
static indexPage(): string {
|
||||
return '/';
|
||||
}
|
||||
|
||||
@@ -16,109 +16,113 @@ class FrontendUrlConfig {
|
||||
|
||||
// Standalone pages
|
||||
|
||||
static aboutUsPage() : string {
|
||||
static aboutUsPage(): string {
|
||||
return '/about';
|
||||
}
|
||||
|
||||
static termsPage() : string {
|
||||
|
||||
static pricingPage(): string {
|
||||
return '/pricing';
|
||||
}
|
||||
|
||||
static termsPage(): string {
|
||||
return '/terms';
|
||||
}
|
||||
|
||||
static patronsPage() : string {
|
||||
|
||||
static patronsPage(): string {
|
||||
return '/patrons';
|
||||
}
|
||||
|
||||
static cloneRequestPage() : string {
|
||||
static cloneRequestPage(): string {
|
||||
return '/clone';
|
||||
}
|
||||
|
||||
// Other domains
|
||||
|
||||
static developerDocs() : string {
|
||||
static developerDocs(): string {
|
||||
return 'https://docs.fakeyou.com/';
|
||||
}
|
||||
|
||||
// TTS model links
|
||||
|
||||
static ttsModelPage(modelToken: string) : string {
|
||||
static ttsModelPage(modelToken: string): string {
|
||||
return `/tts/${modelToken}`;
|
||||
}
|
||||
|
||||
static ttsModelEditPage(modelToken: string) : string {
|
||||
static ttsModelEditPage(modelToken: string): string {
|
||||
return `/tts/${modelToken}/edit`;
|
||||
}
|
||||
|
||||
static ttsModelEditCategoriesPage(modelToken: string) : string {
|
||||
static ttsModelEditCategoriesPage(modelToken: string): string {
|
||||
return `/tts/${modelToken}/categories`;
|
||||
}
|
||||
|
||||
static ttsModelDeletePage(modelToken: string) : string {
|
||||
static ttsModelDeletePage(modelToken: string): string {
|
||||
return `/tts/${modelToken}/delete`;
|
||||
}
|
||||
|
||||
static ttsResultPage(resultToken: string) : string {
|
||||
static ttsResultPage(resultToken: string): string {
|
||||
return `/tts/result/${resultToken}`;
|
||||
}
|
||||
|
||||
static ttsResultEditPage(resultToken: string) : string {
|
||||
static ttsResultEditPage(resultToken: string): string {
|
||||
return `/tts/result/${resultToken}/edit`;
|
||||
}
|
||||
|
||||
static ttsResultDeletePage(resultToken: string) : string {
|
||||
static ttsResultDeletePage(resultToken: string): string {
|
||||
return `/tts/result/${resultToken}/delete`;
|
||||
}
|
||||
|
||||
// W2L template links
|
||||
|
||||
static w2lListPage() : string {
|
||||
static w2lListPage(): string {
|
||||
return '/video';
|
||||
}
|
||||
|
||||
static w2lTemplatePage(templateToken: string) : string {
|
||||
static w2lTemplatePage(templateToken: string): string {
|
||||
return `/w2l/${templateToken}`;
|
||||
}
|
||||
|
||||
static w2lTemplateEditPage(templateToken: string) : string {
|
||||
static w2lTemplateEditPage(templateToken: string): string {
|
||||
return `/w2l/${templateToken}/edit`;
|
||||
}
|
||||
|
||||
static w2lTemplateApprovalPage(templateToken: string) : string {
|
||||
static w2lTemplateApprovalPage(templateToken: string): string {
|
||||
return `/w2l/${templateToken}/approval`;
|
||||
}
|
||||
|
||||
static w2lTemplateDeletePage(templateToken: string) : string {
|
||||
static w2lTemplateDeletePage(templateToken: string): string {
|
||||
return `/w2l/${templateToken}/delete`;
|
||||
}
|
||||
|
||||
static w2lResultPage(resultToken: string) : string {
|
||||
static w2lResultPage(resultToken: string): string {
|
||||
return `/w2l/result/${resultToken}`;
|
||||
}
|
||||
|
||||
static w2lResultEditPage(resultToken: string) : string {
|
||||
static w2lResultEditPage(resultToken: string): string {
|
||||
return `/w2l/result/${resultToken}/edit`;
|
||||
}
|
||||
|
||||
static w2lResultDeletePage(resultToken: string) : string {
|
||||
static w2lResultDeletePage(resultToken: string): string {
|
||||
return `/w2l/result/${resultToken}/delete`;
|
||||
}
|
||||
|
||||
// User links
|
||||
|
||||
static userProfilePage(userDisplayName: string) : string {
|
||||
static userProfilePage(userDisplayName: string): string {
|
||||
return `/profile/${userDisplayName}`;
|
||||
}
|
||||
|
||||
static userProfileEditPage(userDisplayName: string) : string {
|
||||
static userProfileEditPage(userDisplayName: string): string {
|
||||
return `/profile/${userDisplayName}/edit`;
|
||||
}
|
||||
|
||||
static userProfileBanPage(userDisplayName: string) : string {
|
||||
static userProfileBanPage(userDisplayName: string): string {
|
||||
return `/profile/${userDisplayName}/ban`;
|
||||
}
|
||||
|
||||
// Contribute
|
||||
|
||||
static contributePage() : string {
|
||||
static contributePage(): string {
|
||||
return '/contribute';
|
||||
}
|
||||
|
||||
@@ -128,19 +132,19 @@ class FrontendUrlConfig {
|
||||
|
||||
// Moderation links
|
||||
|
||||
static moderationMain() : string {
|
||||
static moderationMain(): string {
|
||||
return '/moderation';
|
||||
}
|
||||
|
||||
static moderationTtsCategoryList() : string {
|
||||
static moderationTtsCategoryList(): string {
|
||||
return '/moderation/tts_category/list';
|
||||
}
|
||||
|
||||
static moderationTtsCategoryEdit(categoryToken: string) : string {
|
||||
static moderationTtsCategoryEdit(categoryToken: string): string {
|
||||
return `/moderation/tts_category/edit/${categoryToken}`;
|
||||
}
|
||||
|
||||
static moderationCategoryDeletePage(categoryToken: string) : string {
|
||||
static moderationCategoryDeletePage(categoryToken: string): string {
|
||||
return `/moderation/category/delete/${categoryToken}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,9 +132,9 @@ function NewFooterNavFc(props: Props) {
|
||||
<Link to="/">Text to Speech</Link>
|
||||
</div>
|
||||
|
|
||||
<div>
|
||||
<Link to="/video">Video</Link>
|
||||
</div>
|
||||
<Link to="/pricing">{t('coreUi.footerNav.pricing')}</Link>
|
||||
|
|
||||
<Link to="/video">{t('coreUi.footerNav.video')}</Link>
|
||||
|
|
||||
<div>
|
||||
<Link to="/contribute">Upload</Link>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ProfileEditFc } from './profile/profile_edit/ProfileEditFc';
|
||||
import { ProfileFc } from './profile/profile_view/ProfileFc';
|
||||
import { SessionWrapper } from '@storyteller/components/src/session/SessionWrapper';
|
||||
import { SignupPage } from './signup/SignupPage';
|
||||
import { PricingPage } from './pricing/Pricing';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
import { TermsPage } from './about/terms_page/TermsPage';
|
||||
import { TtsInferenceJob, W2lInferenceJob } from '../../App';
|
||||
@@ -94,9 +95,9 @@ interface Props {
|
||||
allTtsCategories: TtsCategoryType[],
|
||||
setAllTtsCategories: (allTtsCategories: TtsCategoryType[]) => void,
|
||||
|
||||
allTtsCategoriesByTokenMap: Map<string,TtsCategoryType>,
|
||||
allTtsModelsByTokenMap: Map<string,TtsModelListItem>,
|
||||
ttsModelsByCategoryToken: Map<string,Set<TtsModelListItem>>,
|
||||
allTtsCategoriesByTokenMap: Map<string, TtsCategoryType>,
|
||||
allTtsModelsByTokenMap: Map<string, TtsModelListItem>,
|
||||
ttsModelsByCategoryToken: Map<string, Set<TtsModelListItem>>,
|
||||
|
||||
dropdownCategories: TtsCategoryType[][],
|
||||
setDropdownCategories: (dropdownCategories: TtsCategoryType[][]) => void,
|
||||
@@ -131,7 +132,7 @@ class NewVocodesContainer extends React.Component<Props, State> {
|
||||
logoutHandler={this.logout}
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
querySessionCallback={this.props.querySessionAction}
|
||||
/>
|
||||
/>
|
||||
|
||||
<ScrollToTop />
|
||||
|
||||
@@ -157,9 +158,9 @@ class NewVocodesContainer extends React.Component<Props, State> {
|
||||
|
||||
|
||||
<Route path="/profile/:username/edit">
|
||||
<ProfileEditFc
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
/>
|
||||
<ProfileEditFc
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
/>
|
||||
</Route>
|
||||
|
||||
<Route path="/profile/:username/ban">
|
||||
@@ -169,14 +170,21 @@ class NewVocodesContainer extends React.Component<Props, State> {
|
||||
</Route>
|
||||
|
||||
<Route path="/profile/:username">
|
||||
<ProfileFc
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
/>
|
||||
<ProfileFc
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
/>
|
||||
</Route>
|
||||
|
||||
<Route path="/signup">
|
||||
<SignupPage
|
||||
querySessionCallback={()=>{}}
|
||||
querySessionCallback={() => { }}
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
/>
|
||||
</Route>
|
||||
|
||||
<Route path="/pricing">
|
||||
<PricingPage
|
||||
querySessionCallback={() => { }}
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
/>
|
||||
</Route>
|
||||
@@ -357,7 +365,7 @@ class NewVocodesContainer extends React.Component<Props, State> {
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
/>
|
||||
</Route>
|
||||
|
||||
|
||||
<Route path="/moderation/category/delete/:token">
|
||||
<ModerationCategoryDeletePage
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
@@ -438,7 +446,7 @@ class NewVocodesContainer extends React.Component<Props, State> {
|
||||
|
||||
<NewFooterNavFc
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
/>
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
import React, { useState } from 'react';
|
||||
import { CreateAccount, CreateAccountIsError, CreateAccountIsSuccess } from '@storyteller/components/src/api/user/CreateAccount';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { SessionWrapper } from '@storyteller/components/src/session/SessionWrapper';
|
||||
import { iconEmailField, iconPasswordField, iconUser } from '@storyteller/components/src/icons/SemanticIcons';
|
||||
|
||||
enum FieldTriState {
|
||||
EMPTY_FALSE,
|
||||
FALSE,
|
||||
TRUE,
|
||||
}
|
||||
|
||||
interface Props {
|
||||
sessionWrapper: SessionWrapper,
|
||||
querySessionCallback: () => void,
|
||||
}
|
||||
|
||||
function PricingPage(props: Props) {
|
||||
|
||||
const [username, setUsername] = useState('');
|
||||
const [usernameValid, setUsernameValid] = useState(FieldTriState.EMPTY_FALSE);
|
||||
const [usernameInvalidReason, setUsernameInvalidReason] = useState('');
|
||||
|
||||
const [email, setEmail] = useState('');
|
||||
const [emailValid, setEmailValid] = useState(FieldTriState.EMPTY_FALSE);
|
||||
const [emailInvalidReason, setEmailInvalidReason] = useState('');
|
||||
|
||||
const [password, setPassword] = useState('');
|
||||
const [passwordValid, setPasswordValid] = useState(FieldTriState.EMPTY_FALSE);
|
||||
const [passwordInvalidReason, setPasswordInvalidReason] = useState('');
|
||||
|
||||
const [passwordConfirmation, setPasswordConfirmation] = useState('');
|
||||
const [passwordConfirmationValid, setPasswordConfirmationValid] = useState(FieldTriState.EMPTY_FALSE);
|
||||
const [passwordConfirmationInvalidReason, setPasswordConfirmationInvalidReason] = useState('');
|
||||
|
||||
const handleUsernameChange = (ev: React.FormEvent<HTMLInputElement>) => {
|
||||
ev.preventDefault();
|
||||
|
||||
const newUsername = (ev.target as HTMLInputElement).value;
|
||||
|
||||
let usernameValid = FieldTriState.EMPTY_FALSE;
|
||||
let usernameInvalidReason = "";
|
||||
|
||||
if (newUsername.length > 1) {
|
||||
if (newUsername.length < 3) {
|
||||
usernameValid = FieldTriState.FALSE;
|
||||
usernameInvalidReason = "username is too short";
|
||||
} else if (newUsername.length > 15) {
|
||||
usernameValid = FieldTriState.FALSE;
|
||||
usernameInvalidReason = "username is too long";
|
||||
} else {
|
||||
usernameValid = FieldTriState.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
setUsername(newUsername);
|
||||
setUsernameValid(usernameValid);
|
||||
setUsernameInvalidReason(usernameInvalidReason);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const handleEmailChange = (ev: React.FormEvent<HTMLInputElement>) => {
|
||||
ev.preventDefault();
|
||||
|
||||
const newEmail = (ev.target as HTMLInputElement).value;
|
||||
|
||||
let emailValid = FieldTriState.EMPTY_FALSE;
|
||||
let emailInvalidReason = "";
|
||||
|
||||
if (newEmail.length > 1) {
|
||||
if (newEmail.length < 3) {
|
||||
emailValid = FieldTriState.FALSE;
|
||||
emailInvalidReason = "email is too short";
|
||||
} else if (!newEmail.includes("@")) {
|
||||
emailValid = FieldTriState.FALSE;
|
||||
emailInvalidReason = "email is invalid";
|
||||
} else {
|
||||
emailValid = FieldTriState.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
setEmail(newEmail);
|
||||
setEmailValid(emailValid);
|
||||
setEmailInvalidReason(emailInvalidReason);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const handlePasswordChange = (ev: React.FormEvent<HTMLInputElement>) => {
|
||||
ev.preventDefault();
|
||||
|
||||
const newPassword = (ev.target as HTMLInputElement).value;
|
||||
|
||||
let passwordValid = FieldTriState.EMPTY_FALSE;
|
||||
let passwordInvalidReason = "";
|
||||
let passwordConfirmationValid = FieldTriState.EMPTY_FALSE;
|
||||
let passwordConfirmationInvalidReason = "";
|
||||
|
||||
if (newPassword.length > 1) {
|
||||
if (newPassword.length < 5) {
|
||||
passwordValid = FieldTriState.FALSE;
|
||||
passwordInvalidReason = "password is too short";
|
||||
} else {
|
||||
passwordValid = FieldTriState.TRUE;
|
||||
}
|
||||
|
||||
if (newPassword !== passwordConfirmation) {
|
||||
passwordConfirmationValid = FieldTriState.FALSE;
|
||||
passwordConfirmationInvalidReason = "passwords do not match";
|
||||
} else {
|
||||
passwordConfirmationValid = FieldTriState.TRUE;
|
||||
passwordConfirmationInvalidReason = "";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
setPassword(newPassword);
|
||||
setPasswordValid(passwordValid);
|
||||
setPasswordInvalidReason(passwordInvalidReason);
|
||||
setPasswordConfirmationValid(passwordConfirmationValid);
|
||||
setPasswordConfirmationInvalidReason(passwordConfirmationInvalidReason)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const handlePasswordConfirmationChange = (ev: React.FormEvent<HTMLInputElement>) => {
|
||||
ev.preventDefault();
|
||||
|
||||
const newPasswordConfirmation = (ev.target as HTMLInputElement).value;
|
||||
|
||||
let passwordConfirmationValid = FieldTriState.EMPTY_FALSE;
|
||||
let passwordConfirmationInvalidReason = "";
|
||||
|
||||
if (newPasswordConfirmation.length > 1) {
|
||||
|
||||
if (newPasswordConfirmation !== password) {
|
||||
passwordConfirmationValid = FieldTriState.FALSE;
|
||||
passwordConfirmationInvalidReason = "passwords do not match";
|
||||
} else {
|
||||
passwordConfirmationValid = FieldTriState.TRUE;
|
||||
passwordConfirmationInvalidReason = "";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
setPasswordConfirmation(newPasswordConfirmation);
|
||||
setPasswordConfirmationValid(passwordConfirmationValid);
|
||||
setPasswordConfirmationInvalidReason(passwordConfirmationInvalidReason);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const handleFormSubmit = async (ev: React.FormEvent<HTMLFormElement>): Promise<boolean> => {
|
||||
ev.preventDefault();
|
||||
|
||||
if (!usernameValid ||
|
||||
!emailValid ||
|
||||
!passwordValid ||
|
||||
!passwordConfirmationValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const request = {
|
||||
username: username,
|
||||
email_address: email,
|
||||
password: password,
|
||||
password_confirmation: passwordConfirmation,
|
||||
};
|
||||
|
||||
const response = await CreateAccount(request);
|
||||
|
||||
if (CreateAccountIsError(response)) {
|
||||
if ('email_address' in response.error_fields) {
|
||||
setEmailValid(FieldTriState.FALSE);
|
||||
setEmailInvalidReason(response.error_fields['email_address'] || "");
|
||||
}
|
||||
if ('username' in response.error_fields) {
|
||||
setUsernameValid(FieldTriState.FALSE);
|
||||
setUsernameInvalidReason(response.error_fields['username'] || "");
|
||||
}
|
||||
} else if (CreateAccountIsSuccess(response)) {
|
||||
console.log('querying new session');
|
||||
props.querySessionCallback();
|
||||
|
||||
// TODO: Switch to functional component.
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (props.sessionWrapper.isLoggedIn()) {
|
||||
return <div>Invalid view for logged in users.</div>;
|
||||
}
|
||||
|
||||
let usernameInputClass = "input";
|
||||
let usernameHelpClass = "help";
|
||||
switch (usernameValid) {
|
||||
case FieldTriState.EMPTY_FALSE:
|
||||
break;
|
||||
case FieldTriState.FALSE:
|
||||
usernameInputClass += " is-danger";
|
||||
usernameHelpClass += " is-danger";
|
||||
break;
|
||||
case FieldTriState.TRUE:
|
||||
usernameInputClass += " is-success";
|
||||
usernameHelpClass += " is-success";
|
||||
break;
|
||||
}
|
||||
|
||||
let emailInputClass = "input";
|
||||
let emailHelpClass = "help";
|
||||
switch (emailValid) {
|
||||
case FieldTriState.EMPTY_FALSE:
|
||||
break;
|
||||
case FieldTriState.FALSE:
|
||||
emailInputClass += " is-danger";
|
||||
emailHelpClass += " is-danger";
|
||||
break;
|
||||
case FieldTriState.TRUE:
|
||||
emailInputClass += " is-success";
|
||||
emailHelpClass += " is-success";
|
||||
break;
|
||||
}
|
||||
|
||||
let passwordInputClass = "input";
|
||||
let passwordHelpClass = "help";
|
||||
switch (passwordValid) {
|
||||
case FieldTriState.EMPTY_FALSE:
|
||||
break;
|
||||
case FieldTriState.FALSE:
|
||||
passwordInputClass += " is-danger";
|
||||
passwordHelpClass += " is-danger";
|
||||
break;
|
||||
case FieldTriState.TRUE:
|
||||
passwordInputClass += " is-success";
|
||||
passwordHelpClass += " is-success";
|
||||
break;
|
||||
}
|
||||
|
||||
let passwordConfirmationInputClass = "input";
|
||||
let passwordConfirmationHelpClass = "help";
|
||||
switch (passwordConfirmationValid) {
|
||||
case FieldTriState.EMPTY_FALSE:
|
||||
break;
|
||||
case FieldTriState.FALSE:
|
||||
passwordConfirmationInputClass += " is-danger";
|
||||
passwordConfirmationHelpClass += " is-danger";
|
||||
break;
|
||||
case FieldTriState.TRUE:
|
||||
passwordConfirmationInputClass += " is-success";
|
||||
passwordConfirmationHelpClass += " is-success";
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="title is-1">
|
||||
Pricing
|
||||
</h1>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export { PricingPage };
|
||||
Reference in new issue
Block a user