-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from 2060-io/38-terms-and-conditions
feat: Terms and Conditions, AND url page
- Loading branch information
Showing
11 changed files
with
520 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Translations } from '../components/utils' | ||
|
||
export interface TranslationsKey { | ||
name: string | ||
isParagraph: boolean | ||
isTitle1: boolean | ||
isTitle2: boolean | ||
isTitle3: boolean | ||
classNameExtra?: string | ||
} | ||
|
||
export interface TermsAndPrivacy { | ||
translations: Translations | undefined | ||
} | ||
|
||
const classNamesTitle1 = 'text-2xl lg:text-4xl xl:text-4xl 2xl:text-4xl text-hologram-color font-semibold' | ||
const classNameTitle2 = 'text-xl lg:text-4xl xl:text-4xl 2xl:text-4xl font-semibold my-6' | ||
const classNameTitle3 = 'lg:text-3xl xl:text-3xl 2xl:text-3xl font-semibold my-6' | ||
const classNameParagraph = 'lg:text-xl xl:lg:text-xl 2xl:lg:text-xl text-justify' | ||
|
||
export const getStyleText = (translation: TranslationsKey): string => { | ||
return translation.isParagraph | ||
? classNameParagraph | ||
: translation.isTitle1 | ||
? classNamesTitle1 | ||
: translation.isTitle2 | ||
? classNameTitle2 | ||
: translation.isTitle3 | ||
? classNameTitle3 | ||
: '' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
'use client' | ||
|
||
import { useEffect, useLayoutEffect, useRef, useState } from 'react' | ||
|
||
import loadTranslations from '../../utils/loadTranslations' | ||
import { Footer } from '../components/footer' | ||
import { NavBarTopPage } from '../components/navBars' | ||
import { Header, Translations } from '../components/utils' | ||
|
||
import Privacy from './privacy' | ||
import Terms from './terms' | ||
|
||
const TermsAndPrivacy = () => { | ||
const [translations, setTranslations] = useState<Translations>() | ||
const termsRef = useRef<HTMLDivElement | null>(null) | ||
const privacyRef = useRef<HTMLDivElement | null>(null) | ||
const [url, setUrl] = useState<string>('') | ||
const [urlData, setUrlData] = useState<string>('') | ||
|
||
useEffect(() => { | ||
const userLocale = navigator.language.startsWith('es') ? 'es' : 'en' | ||
const loadedTranslations = loadTranslations(userLocale) | ||
setTranslations(loadedTranslations) | ||
setUrl(window.location.href) | ||
|
||
const handleScroll = () => setUrl(window.location.href) | ||
window.addEventListener('scroll', handleScroll) | ||
|
||
return () => window.removeEventListener('scroll', handleScroll) | ||
}, []) | ||
|
||
useEffect(() => { | ||
if (typeof window !== 'undefined') { | ||
const url = new URL(window.location.href) | ||
const searchParams = new URLSearchParams(url.hash.substring(url.hash.indexOf('?'))) | ||
const oobValue = searchParams.get('oob') | ||
const _oobValue = searchParams.get('_oob') | ||
|
||
setUrlData(oobValue ? `/?oob=${oobValue}` : _oobValue ? `/?_oob=${_oobValue}` : '') | ||
} | ||
}, [url]) | ||
|
||
useLayoutEffect(() => { | ||
const scrollTarget = url.includes('terms') ? termsRef : url.includes('privacy') ? privacyRef : null | ||
scrollTarget?.current?.scrollIntoView({ behavior: 'smooth' }) | ||
}, [url]) | ||
|
||
return ( | ||
<div className="mt-5 bg-white dark:bg-gray-900 text-black dark:text-gray-300"> | ||
<Header translations={translations ?? {}} urlData={urlData}></Header> | ||
|
||
<NavBarTopPage translations={translations ?? {}} urlData={urlData}></NavBarTopPage> | ||
|
||
<div ref={termsRef} className="container mx-auto px-6 2xl:px-28 xl:px-28 lg:px-28 mb-10"> | ||
<Terms translations={translations} /> | ||
</div> | ||
|
||
<div ref={privacyRef} id="privacy" className="container mx-auto px-6 2xl:px-28 xl:px-28 lg:px-28 mb-16"> | ||
<Privacy translations={translations} /> | ||
</div> | ||
<Footer translations={translations ?? {}} currentPage={url} urlData={urlData}></Footer> | ||
</div> | ||
) | ||
} | ||
|
||
export default TermsAndPrivacy |
Oops, something went wrong.