mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
move helpers out again
seems anything under pages, besides api needs to be a react component
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Schema } from 'mongoose'
|
||||
|
||||
import { getDays, dateFormat } from '../../helpers/date'
|
||||
import { getDays, dateFormat } from '../../../helpers/date'
|
||||
|
||||
export const BookerSchema = new Schema(
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'react-dates/initialize'
|
||||
import { DateRangePicker, SingleDatePicker } from 'react-dates'
|
||||
|
||||
import Required from './required'
|
||||
import { dateFormat } from '../helpers/date'
|
||||
import { dateFormat } from '../../helpers/date'
|
||||
|
||||
const fetcher = (path) => fetch(path).then((r) => r.json())
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useReducer, useEffect } from 'react'
|
||||
|
||||
import { storeFormData, loadFormData } from '../helpers/storage'
|
||||
import { storeFormData, loadFormData } from '../../helpers/storage'
|
||||
|
||||
export const WizardContext = React.createContext()
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import moment from 'moment'
|
||||
|
||||
export function getDays({ startDate, endDate }) {
|
||||
let currentDay = moment(startDate)
|
||||
const days = [dateFormat(currentDay)]
|
||||
|
||||
if (!endDate) {
|
||||
return days
|
||||
}
|
||||
|
||||
const end = moment(endDate)
|
||||
while (currentDay < end) {
|
||||
currentDay = currentDay.add(1, 'day')
|
||||
days.push(dateFormat(currentDay))
|
||||
}
|
||||
|
||||
return days
|
||||
}
|
||||
|
||||
export function dateFormat(date) {
|
||||
if (!date) {
|
||||
return null
|
||||
}
|
||||
return moment(date).format('YYYY-MM-DD')
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
const FORM_DATA_KEY = 'pfadiBussleFormData'
|
||||
|
||||
function getStorage() {
|
||||
return localStorage
|
||||
}
|
||||
|
||||
export function storeFormData({ org, name, email, street, zip, city }) {
|
||||
getStorage().setItem(
|
||||
FORM_DATA_KEY,
|
||||
JSON.stringify({ org, name, email, street, zip, city })
|
||||
)
|
||||
}
|
||||
|
||||
export function loadFormData() {
|
||||
const dataAsString = getStorage().getItem(FORM_DATA_KEY)
|
||||
return JSON.parse(dataAsString || '{}')
|
||||
}
|
||||
Reference in New Issue
Block a user