Skip to content

Commit

Permalink
Created Campaign Form that is publicly available
Browse files Browse the repository at this point in the history
  • Loading branch information
srp-pawar committed Mar 26, 2024
1 parent 8edda7a commit de60b63
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 20 deletions.
11 changes: 6 additions & 5 deletions packages/twenty-front/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
import { Route, Routes, useLocation } from 'react-router-dom';

import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { AppPath } from '@/types/AppPath';
Expand All @@ -9,16 +9,18 @@ import { PageTitle } from '@/ui/utilities/page-title/PageTitle';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { CommandMenuEffect } from '~/effect-components/CommandMenuEffect';
import { GotoHotkeysEffect } from '~/effect-components/GotoHotkeysEffect';
import { ChooseYourPlan } from '~/pages/auth/ChooseYourPlan.tsx';
import { useDefaultHomePagePath } from '~/hooks/useDefaultHomePagePath';
import { ChooseYourPlan } from '~/pages/auth/ChooseYourPlan.tsx';
import { CreateProfile } from '~/pages/auth/CreateProfile';
import { CreateWorkspace } from '~/pages/auth/CreateWorkspace';
import { PasswordReset } from '~/pages/auth/PasswordReset';
import { PaymentSuccess } from '~/pages/auth/PaymentSuccess.tsx';
import { PlanRequired } from '~/pages/auth/PlanRequired';
import { SignInUp } from '~/pages/auth/SignInUp';
import { VerifyEffect } from '~/pages/auth/VerifyEffect';
import { CampaignForm } from '~/pages/campaigns/CampaignForm';
import { Campaigns } from '~/pages/campaigns/Campaigns';
import { DefaultHomePage } from '~/pages/DefaultHomePage';
import { ImpersonateEffect } from '~/pages/impersonate/ImpersonateEffect';
import { NotFound } from '~/pages/not-found/NotFound';
import { RecordIndexPage } from '~/pages/object-record/RecordIndexPage';
Expand Down Expand Up @@ -51,8 +53,6 @@ import { TemplatesList } from '~/pages/Templates/TemplatesList';
import { TextTemplate } from '~/pages/Templates/TextTemplate';
import { VideoTemplate } from '~/pages/Templates/VideoTemplate';
import { getPageTitleFromPath } from '~/utils/title-utils';
import { DefaultHomePage } from '~/pages/DefaultHomePage';
import { Scrollbar } from '~/pages/campaigns/scrollbar';

export const App = () => {
const isSelfBillingEnabled = useIsFeatureEnabled('IS_SELF_BILLING_ENABLED');
Expand Down Expand Up @@ -209,6 +209,8 @@ export const App = () => {
element={<TextTemplate />}
/>
<Route path={CustomPath.CampaignsPage} element={<Campaigns />} />
<Route path={CustomPath.CampaignForm} element={<CampaignForm />} />

<Route
path={CustomPath.AudioTemplatePage}
element={<AudioTemplate targetableObject={targetableObject} />}
Expand All @@ -222,7 +224,6 @@ export const App = () => {
element={<DocumentTemplate targetableObject={targetableObject} />}
/>
<Route path={CustomPath.TemplatesPage} element={<TemplatesList />} />

</Routes>
</DefaultLayout>
</>
Expand Down
14 changes: 12 additions & 2 deletions packages/twenty-front/src/effect-components/PageChangeEffect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CommandType } from '@/command-menu/types/Command';
import { TableHotkeyScope } from '@/object-record/record-table/types/TableHotkeyScope';
import { AppBasePath } from '@/types/AppBasePath';
import { AppPath } from '@/types/AppPath';
import { CustomPath } from '@/types/CustomPath';
import { PageHotkeyScope } from '@/types/PageHotkeyScope';
import { SettingsPath } from '@/types/SettingsPath';
import { IconCheckbox } from '@/ui/display/icon';
Expand Down Expand Up @@ -72,8 +73,10 @@ export const PageChangeEffect = () => {
});
navigate(AppPath.SignUp);
};

if (
if (isMatchingLocation(CustomPath.CampaignForm)) {
navigate(CustomPath.CampaignForm);
return;
} else if (
onboardingStatus === OnboardingStatus.OngoingUserCreation &&
!isMatchingOngoingUserCreationRoute &&
!isMatchingLocation(AppPath.ResetPassword)
Expand Down Expand Up @@ -150,6 +153,13 @@ export const PageChangeEffect = () => {
});
break;
}
case isMatchingLocation(CustomPath.CampaignForm): {
setHotkeyScope(PageHotkeyScope.CampaignForm, {
goto: true,
keyboardShortcutMenu: true,
});
break;
}
case isMatchingLocation(AppPath.OpportunitiesPage): {
setHotkeyScope(PageHotkeyScope.OpportunitiesPage, {
goto: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useRecoilState } from 'recoil';
import { tokenPairState } from '@/auth/states/tokenPairState';
import { isDebugModeState } from '@/client-config/states/isDebugModeState';
import { AppPath } from '@/types/AppPath';
import { CustomPath } from '@/types/CustomPath';
import { REACT_APP_SERVER_BASE_URL } from '~/config';
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
import { useUpdateEffect } from '~/hooks/useUpdateEffect';
Expand Down Expand Up @@ -37,8 +38,10 @@ export const useApolloFactory = () => {
setTokenPair(tokenPair);
},
onUnauthenticatedError: () => {
setTokenPair(null);
if (
// setTokenPair(null);
if (isMatchingLocation(CustomPath.CampaignForm)) {
navigate(CustomPath.CampaignForm);
} else if (
!isMatchingLocation(AppPath.Verify) &&
!isMatchingLocation(AppPath.SignIn) &&
!isMatchingLocation(AppPath.SignUp) &&
Expand Down
8 changes: 6 additions & 2 deletions packages/twenty-front/src/modules/auth/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import { Modal as UIModal } from '@/ui/layout/modal/components/Modal';

const StyledContent = styled(UIModal.Content)`
align-items: center;
width: calc(400px - ${({ theme }) => theme.spacing(10 * 2)});
display: flex;
flex-direction: column;
justify-content: center;
padding: ${({ theme }) => theme.spacing(0)};
width: 100%;
`;

type AuthModalProps = { children: React.ReactNode };

export const AuthModal = ({ children }: AuthModalProps) => (
<UIModal isOpen={true} padding={'none'}>
<UIModal isOpen={true} padding={'none'} size="extralarge">
<StyledContent>{children}</StyledContent>
</UIModal>
);
2 changes: 1 addition & 1 deletion packages/twenty-front/src/modules/types/AppBasePath.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum AppBasePath {
Auth = '/auth',
Settings = '/settings',
Root = '/',
Root = '/root',
}
12 changes: 7 additions & 5 deletions packages/twenty-front/src/modules/types/AppPath.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { AppBasePath } from '@/types/AppBasePath';

export enum AppPath {
// Not logged-in
Verify = '/verify',
SignIn = '/sign-in',
SignUp = '/sign-up',
Invite = '/invite/:workspaceInviteHash',
ResetPassword = '/reset-password/:passwordResetToken',
Verify = `${AppBasePath.Auth}/verify`,
SignIn = `${AppBasePath.Auth}/sign-in`,
SignUp = `${AppBasePath.Auth}/sign-up`,
Invite = `${AppBasePath.Auth}/invite/:workspaceInviteHash`,
ResetPassword = `${AppBasePath.Auth}/reset-password/:passwordResetToken`,

// Onboarding
CreateWorkspace = '/create/workspace',
Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-front/src/modules/types/CustomPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export enum CustomPath {
CampaignsPage = '/campaigns',

DatePickerPage = '/datepicker',

CampaignForm = '/campaignform',
}
1 change: 1 addition & 0 deletions packages/twenty-front/src/modules/types/PageHotkeyScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export enum PageHotkeyScope {
ProfilePage = 'profile-page',
WorkspaceMemberPage = 'workspace-member-page',
TaskPage = 'task-page',
CampaignForm = 'campaignform',
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const StyledModalDiv = styled(motion.div)<{
color: ${({ theme }) => theme.font.color.primary};
border-radius: ${({ theme }) => theme.border.radius.md};
overflow: hidden;
max-height: 90vh;
height: 100vh;
z-index: 10000; // should be higher than Backdrop's z-index
width: ${({ size, theme }) => {
Expand All @@ -33,6 +33,8 @@ const StyledModalDiv = styled(motion.div)<{
return theme.modal.size.md;
case 'large':
return theme.modal.size.lg;
case 'extralarge':
return theme.modal.size.xl;
default:
return 'auto';
}
Expand Down Expand Up @@ -120,11 +122,10 @@ type ModalFooterProps = React.PropsWithChildren & {
const ModalFooter = ({ children, className }: ModalFooterProps) => (
<StyledFooter className={className}>{children}</StyledFooter>
);

/**
* Modal
*/
export type ModalSize = 'small' | 'medium' | 'large';
export type ModalSize = 'small' | 'medium' | 'large' | 'extralarge';
export type ModalPadding = 'none' | 'small' | 'medium' | 'large';

type ModalProps = React.PropsWithChildren & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export const MODAL = {
sm: '300px',
md: '400px',
lg: '53%',
xl: '100%',
},
};
188 changes: 188 additions & 0 deletions packages/twenty-front/src/pages/campaigns/CampaignForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import { useState } from 'react';
import styled from '@emotion/styled';
import { Section } from '@react-email/components';
import {
Button,
Checkbox,
CheckboxShape,
CheckboxSize,
CheckboxVariant,
TextArea,
TextInput,
} from 'tsup.ui.index';

import { H2Title } from '@/ui/display/typography/components/H2Title';

const StyledCard = styled.div`
border: 1px solid ${({ theme }) => theme.border.color.medium};
border-radius: ${({ theme }) => theme.border.radius.sm};
color: ${({ theme }) => theme.font.color.secondary};
box-shadow: ${({ theme }) => theme.boxShadow.strong};
display: flex;
flex-direction: column;
justify-content: center;
background: ${({ theme }) => theme.background.primary};
height: 100%;
width: 100%;
margin: auto;
align-items: center;
`;

const StyledInputCard = styled.div`
color: ${({ theme }) => theme.font.color.secondary};
display: flex;
flex-direction: column;
justify-content: center;
height: 1005%;
justify-content: space-between;
width: 70%;
align-items: center;
`;

const StyledCheckboxInput = styled.div`
margin-top: ${({ theme }) => theme.spacing(4)};
`;

const StyledTitleCard = styled.div`
/* align-items: center; */
color: ${({ theme }) => theme.font.color.secondary};
display: flex;
flex-direction: column;
height: 10%;
width: 100%;
justify-content: flex-start;
`;

const StyledAreaLabel = styled.span`
align-content: flex-start;
display: flex;
flex-direction: column;
margin-bottom: 2%;
width: 100%;
`;
const StyledButton = styled.span`
display: flex;
justify-content: space-between;
width: 100%;
`;

const StyledTitle = styled.h3`
color: ${({ theme }) => theme.font.color.secondary};
font-weight: ${({ theme }) => theme.font.weight.medium};
font-size: ${({ theme }) => theme.font.size.md};
`;

const StyledCheckboxLabel = styled.span`
margin-left: ${({ theme }) => theme.spacing(2)};
`;

const StyledComboInputContainer = styled.div`
display: flex;
flex-direction: row;
> * + * {
margin-left: ${({ theme }) => theme.spacing(4)};
}
`;

export const CampaignForm = () => {
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [contact, setContact] = useState('');
const [email, setEmail] = useState('');
const [comments, setComments] = useState('');
return (
<>
<StyledCard>
<StyledTitleCard>
<StyledTitle></StyledTitle>
</StyledTitleCard>
<StyledInputCard>
<Section>
<H2Title title="First Name" description="Enter your first name" />
<TextInput
placeholder={'Enter first name'}
value={firstName}
name="firstName"
required
fullWidth
onChange={(e) => setFirstName(e)}
/>
</Section>
<Section>
<H2Title title="Email" description="Enter your email address" />
<TextInput
placeholder={'Enter email address'}
value={email}
name="email"
required
fullWidth
onChange={(e) => setEmail(e)}
/>
</Section>
<Section>
<H2Title title="Last Name" description="Enter your last name" />
<TextInput
placeholder={'Enter last name'}
value={lastName}
name="lastName"
required
fullWidth
onChange={(e) => setLastName(e)}
/>
</Section>
<Section>
<H2Title
title="Contact Number"
description="Enter your contact number"
/>
<TextInput
placeholder={'Enter contact number'}
value={contact}
name="contact"
required
fullWidth
onChange={(e) => setContact(e)}
/>
</Section>

<StyledAreaLabel>
<Section>
<H2Title
title="Campaign Description"
description="Describe the main objectives and goals of the campaign "
/>
</Section>
<TextArea
value={comments}
placeholder={'State the reason for the apppointment'}
minRows={5}
onChange={(e) => setComments(e)}
/>

<StyledCheckboxInput>
<H2Title
title="Consent*"
description="Read the terms and conditions before agreeing."
/>
</StyledCheckboxInput>
<StyledComboInputContainer>
<Checkbox
checked={false}
indeterminate={false}
variant={CheckboxVariant.Primary}
size={CheckboxSize.Small}
shape={CheckboxShape.Squared}
/>
<StyledCheckboxLabel>
I agree to the terms and conditions.
</StyledCheckboxLabel>
</StyledComboInputContainer>
</StyledAreaLabel>
<StyledButton>
<Button title="Submit" variant="primary" accent="blue" />
</StyledButton>
</StyledInputCard>
</StyledCard>
</>
);
};

0 comments on commit de60b63

Please sign in to comment.