chore(shared): Move org stuff to shared to be used by the lab
This commit is contained in:
parent
2dcf46befa
commit
a41b3f09a2
22 changed files with 33 additions and 15 deletions
|
@ -12,14 +12,14 @@ import Link from 'next/link'
|
|||
// Components
|
||||
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
|
||||
import { BareLayout, ns as layoutNs } from 'site/components/layouts/bare.mjs'
|
||||
import { WelcomeWrapper } from 'site/components/wrappers/welcome.mjs'
|
||||
import { WelcomeWrapper } from 'shared/components/wrappers/welcome.mjs'
|
||||
import { Spinner } from 'shared/components/spinner.mjs'
|
||||
import { Popout } from 'shared/components/popout.mjs'
|
||||
import {
|
||||
GdprProfileDetails,
|
||||
GdprMeasurementsDetails,
|
||||
ns as gdprNs,
|
||||
} from 'site/components/gdpr/details.mjs'
|
||||
} from 'shared/components/gdpr/details.mjs'
|
||||
|
||||
// Translation namespaces used on this page
|
||||
const ns = Array.from(new Set([...pageNs, ...layoutNs, ...gdprNs, 'confirm', 'locales', 'themes']))
|
||||
|
|
|
@ -6,14 +6,14 @@ import { useTranslation } from 'next-i18next'
|
|||
import { ModalContext } from 'shared/context/modal-context.mjs'
|
||||
// Dependencies
|
||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||
import { validateEmail, validateTld } from 'site/utils.mjs'
|
||||
import { validateEmail, validateTld } from 'shared/utils.mjs'
|
||||
// Components
|
||||
import Link from 'next/link'
|
||||
import { PageWrapper } from 'shared/components/wrappers/page.mjs'
|
||||
import { BareLayout } from 'site/components/layouts/bare.mjs'
|
||||
import { SusiWrapper } from 'site/components/wrappers/susi.mjs'
|
||||
import { SusiWrapper } from 'shared/components/wrappers/susi.mjs'
|
||||
import { Robot } from 'shared/components/robot/index.mjs'
|
||||
import { EmailValidButton } from 'site/components/buttons/email-valid-button.mjs'
|
||||
import { EmailValidButton } from 'shared/components/buttons/email-valid-button.mjs'
|
||||
import { LeftIcon, HelpIcon } from 'shared/components/icons.mjs'
|
||||
import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { useToast } from 'shared/hooks/use-toast.mjs'
|
|||
import { LoadingContext } from 'shared/context/loading-context.mjs'
|
||||
// Components
|
||||
import { Choice, Icons, welcomeSteps, BackToAccountButton } from './shared.mjs'
|
||||
import { ContinueButton } from 'site/components/buttons/continue-button.mjs'
|
||||
import { ContinueButton } from 'shared/components/buttons/continue-button.mjs'
|
||||
|
||||
export const ns = ['account', 'toast']
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { useToast } from 'shared/hooks/use-toast.mjs'
|
|||
import { LoadingContext } from 'shared/context/loading-context.mjs'
|
||||
// Components
|
||||
import { BackToAccountButton, Choice, Icons, welcomeSteps } from './shared.mjs'
|
||||
import { ContinueButton } from 'site/components/buttons/continue-button.mjs'
|
||||
import { ContinueButton } from 'shared/components/buttons/continue-button.mjs'
|
||||
|
||||
export const ns = ['account', 'toast']
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { useToast } from 'shared/hooks/use-toast.mjs'
|
|||
import { LoadingContext } from 'shared/context/loading-context.mjs'
|
||||
// Components
|
||||
import { Choice, Icons, welcomeSteps, BackToAccountButton } from './shared.mjs'
|
||||
import { ContinueButton } from 'site/components/buttons/continue-button.mjs'
|
||||
import { ContinueButton } from 'shared/components/buttons/continue-button.mjs'
|
||||
|
||||
export const ns = ['account', 'toast']
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { useToast } from 'shared/hooks/use-toast.mjs'
|
|||
import { LoadingContext } from 'shared/context/loading-context.mjs'
|
||||
// Components
|
||||
import { BackToAccountButton, Choice, Icons, welcomeSteps } from './shared.mjs'
|
||||
import { ContinueButton } from 'site/components/buttons/continue-button.mjs'
|
||||
import { ContinueButton } from 'shared/components/buttons/continue-button.mjs'
|
||||
|
||||
export const ns = ['account', 'toast']
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import { CopyToClipboard } from 'react-copy-to-clipboard'
|
|||
import orderBy from 'lodash.orderby'
|
||||
import { measurements, isDegreeMeasurement } from 'config/measurements.mjs'
|
||||
import { measurementAsMm, formatMm } from 'shared/utils.mjs'
|
||||
import { measurements as designMeasurements } from 'site/prebuild/design-measurements.mjs'
|
||||
import { measurements as designMeasurements } from 'shared/prebuild/data/design-measurements.mjs'
|
||||
import { freeSewingConfig as conf } from 'shared/config/freesewing.config.mjs'
|
||||
// Hooks
|
||||
import { useDropzone } from 'react-dropzone'
|
||||
|
|
|
@ -11,7 +11,7 @@ import { LoadingContext } from 'shared/context/loading-context.mjs'
|
|||
import { Spinner } from 'shared/components/spinner.mjs'
|
||||
import { Icons, welcomeSteps, BackToAccountButton } from './shared.mjs'
|
||||
import { OkIcon, NoIcon } from 'shared/components/icons.mjs'
|
||||
import { ContinueButton } from 'site/components/buttons/continue-button.mjs'
|
||||
import { ContinueButton } from 'shared/components/buttons/continue-button.mjs'
|
||||
|
||||
export const ns = ['account', 'toast']
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { useContext } from 'react'
|
||||
import { validateEmail, validateTld } from 'site/utils.mjs'
|
||||
import { validateEmail, validateTld } from 'shared/utils.mjs'
|
||||
import { Spinner } from 'shared/components/spinner.mjs'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { EmailIcon, RightIcon, WarningIcon } from 'shared/components/icons.mjs'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { validateEmail, validateTld } from 'site/utils.mjs'
|
||||
import { validateEmail, validateTld } from 'shared/utils.mjs'
|
||||
import { Spinner } from 'shared/components/spinner.mjs'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { EmailIcon, RightIcon, WarningIcon } from 'shared/components/icons.mjs'
|
||||
|
|
|
@ -2,7 +2,7 @@ import { social } from 'config/social.mjs'
|
|||
|
||||
export const freeSewingConfig = {
|
||||
monorepo: 'https://github.com/freesewing/freesewing',
|
||||
backend: process.env.NEXT_PUBLIC_BACKEND,
|
||||
backend: process.env.NEXT_PUBLIC_BACKEND || 'https://backend3.freesewing.org',
|
||||
maxWidth: 2800,
|
||||
account: {
|
||||
fields: {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import axios from 'axios'
|
||||
import process from 'process'
|
||||
import { freeSewingConfig } from 'shared/config/freesewing.config.mjs'
|
||||
|
||||
/*
|
||||
* Helper methods to interact with the FreeSewing backend
|
||||
*/
|
||||
const apiHandler = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_BACKEND || 'https://backend.freesewing.org',
|
||||
baseURL: freeSewingConfig.backend,
|
||||
timeout: 3000,
|
||||
})
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import tlds from 'tlds/index.json' assert { type: 'json' }
|
||||
import get from 'lodash.get'
|
||||
import set from 'lodash.set'
|
||||
import orderBy from 'lodash.orderby'
|
||||
|
@ -222,3 +223,19 @@ export const objUpdate = (obj = {}, path, val = 'unset') => {
|
|||
|
||||
return obj
|
||||
}
|
||||
|
||||
/** Validates an email address for correct syntax */
|
||||
export const validateEmail = (email) => {
|
||||
/* eslint-disable */
|
||||
const re =
|
||||
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||
/* eslint-enable */
|
||||
return re.test(email)
|
||||
}
|
||||
|
||||
/** Validates the top level domain (TLT) for an email address */
|
||||
export const validateTld = (email) => {
|
||||
const tld = email.split('@').pop().split('.').pop().toLowerCase()
|
||||
if (tlds.indexOf(tld) === -1) return tld
|
||||
else return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue