Skip to content

Commit

Permalink
Merge pull request #262 from alexrobaina/feat/terms
Browse files Browse the repository at this point in the history
add terms
  • Loading branch information
alexrobaina authored Aug 20, 2024
2 parents 77eb39a + ccca5c9 commit 525b13e
Show file tree
Hide file tree
Showing 14 changed files with 1,679 additions and 33 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"react-helmet-async": "^2.0.5",
"react-i18next": "^14.1.0",
"react-image-file-resizer": "^0.4.8",
"react-markdown": "8.0.6",
"react-modal": "^3.16.1",
"react-phone-input-2": "^2.15.1",
"react-places-autocomplete": "^7.3.0",
Expand All @@ -56,6 +57,7 @@
"react-router-dom": "^6.15.0",
"react-select": "^5.7.5",
"react-toastify": "^9.1.3",
"remark-gfm": "^4.0.0",
"serve": "^14.2.1",
"swiper": "^10.3.0",
"tailwindcss": "^3.3.3",
Expand Down Expand Up @@ -89,4 +91,4 @@
"vite": "^4.4.5",
"vitest": "^1.3.1"
}
}
}
1 change: 1 addition & 0 deletions public/locales/en/login.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"warning": "If you didn't request this, please ignore this email.",
"thanks": "Thanks",
"emailSent": "Please check your email",
"terms": "Terms & Conditions",
"last": "Last"
}
1 change: 1 addition & 0 deletions public/locales/es/login.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"warning": "Este enlace solo es válido por 15 minutos.",
"thanks": "Gracias",
"emailSent": "Revisa tu correo.",
"terms": "Términos y condiciones",
"last": "Last"
}
1 change: 1 addition & 0 deletions public/locales/fr/login.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"warning": "Si vous n'avez pas demandé cela, veuillez ignorer cet e-mail.",
"thanks": "Merci",
"emailSent": "Veuillez vérifier votre courriel",
"terms": "Conditions d'utilisation",
"last": "Dernier"
}
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { AppContext, AppContextProps } from './services/AppContext'

import './api/axiosInstance'
import { ExpensePage } from './pages/ExpensePage'
import { TermsPage } from './pages/Terms'

interface Props {
appContext: AppContextProps
Expand Down
10 changes: 8 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AdoptionPetPage } from './pages/AdoptionPetPage/index.tsx'
import { CommunityPage } from './pages/CommunityPage/index.tsx'
import { LoginPage } from './pages/LoginPage/index.tsx'
import { ProfilePetPage } from './pages/ProfilePetPage/index.tsx'
import { TermsPage } from './pages/Terms/index.tsx'
import { UserProfilePage } from './pages/UserProfilePage/index.tsx'
import { AppContextProps } from './services/AppContext.tsx'
import { getCookie } from './utils/getCookie.ts'
Expand Down Expand Up @@ -49,6 +50,10 @@ async function main() {
path: '/community',
element: <CommunityPage />,
},
{
path: '/terms',
element: <TermsPage />,
},
{
path: '/',
element: <AdoptionPetPage />,
Expand Down Expand Up @@ -85,7 +90,9 @@ async function main() {
throw new Error('User not signed in')
}
} catch (_e) {
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
return ReactDOM.createRoot(
document.getElementById('root') as HTMLElement,
).render(
<React.StrictMode>
<HelmetProvider>
<QueryClientProvider client={queryClient}>
Expand All @@ -94,7 +101,6 @@ async function main() {
</HelmetProvider>
</React.StrictMode>,
)
return
}

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
Expand Down
66 changes: 40 additions & 26 deletions src/pages/LoginPage/components/LoginGoogle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,26 @@ import { BaseInput } from '../../../components/common/BaseInput'
import { BaseLoading } from '../../../components/common/BaseLoading'

export const LoginGoogle: FC = () => {
const [successEmailLogin, setSuccessEmailLogin] = useState(false);
const [loading, setLoading] = useState(true);
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('token');
const { t } = useTranslation(['common', 'login']);
const [successEmailLogin, setSuccessEmailLogin] = useState(false)
const [loading, setLoading] = useState(true)
const urlParams = new URLSearchParams(window.location.search)
const token = urlParams.get('token')
const { t } = useTranslation(['common', 'login'])

useEffect(() => {
setSuccessEmailLogin(false);
setSuccessEmailLogin(false)
if (token) {
setLoading(true);
document.cookie = `token=${token}; path=/`;
window.location.href = '/dashboard';
setLoading(true)
document.cookie = `token=${token}; path=/`
window.location.href = '/dashboard'
}
setTimeout(() => setLoading(false), 500);
}, [token]);
setTimeout(() => setLoading(false), 500)
}, [token])

const loginSchema = Yup.object().shape({
email: Yup.string().email(t('common:emailInvalid')).required(t('common:requiredField')),
email: Yup.string()
.email(t('common:emailInvalid'))
.required(t('common:requiredField')),
})

const formik = useFormik({
Expand All @@ -48,10 +50,9 @@ export const LoginGoogle: FC = () => {
location.href = data?.location
}


const loginEmailCallback = async (email: string) => {
try {
setLoading(true);
setLoading(true)
await axios.post('/api/auth/email/', {
email: email,
texts: {
Expand All @@ -63,13 +64,13 @@ export const LoginGoogle: FC = () => {
thanks: t('login:thanks'),
welcome: t('login:welcome'),
},
});
setSuccessEmailLogin(true);
setLoading(false);
})
setSuccessEmailLogin(true)
setLoading(false)
} catch (error) {
setLoading(false);
setLoading(false)
}
};
}

const { values, errors, handleSubmit, handleChange } = formik

Expand All @@ -78,7 +79,7 @@ export const LoginGoogle: FC = () => {
<div className="flex justify-center">
<BaseLoading large />
</div>
);
)
}

return (
Expand All @@ -91,13 +92,14 @@ export const LoginGoogle: FC = () => {
<div className="z-1 flex min-h-full flex-col justify-center py-8 sm:px-6 lg:px-8">
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-[480px]">
<div className="bg-primary-300 shadow-2xl sm:rounded-lg p-8 sm:px-12 w-[400px]">
{successEmailLogin ?
{successEmailLogin ? (
<h2 className="mb-5 text-center text-2xl font-bold leading-9 tracking-tight text-primary-900">
{t('login:emailSent')}
</h2> :
</h2>
) : (
<>
<div className="mb-4 flex-col gap-4">
<div className='flex justify-center mb-2'>
<div className="flex justify-center mb-2">
<PetsLoveLogo width={50} height={50} />
</div>
<h2 className="text-center text-2xl font-bold leading-9 tracking-tight text-primary-900">
Expand Down Expand Up @@ -130,15 +132,27 @@ export const LoginGoogle: FC = () => {
/>
</div>
<div className="mt-6 w-full">
<BaseButton onClick={handleSubmit} wFull text={t('login:magicLink')} />
<BaseButton
onClick={handleSubmit}
wFull
text={t('login:magicLink')}
/>
</div>
<div className="mt-6">
<a
href="/terms"
className="cursor-pointer text-center text-sm text-primary-900"
>
{t('login:terms')}
</a>
</div>
</div>
</div>
</>
}
)}
</div>
</div>
</div>
</div>
)
}
}
Loading

0 comments on commit 525b13e

Please sign in to comment.