refactor: använd moment för all datumhantering (#227)
This commit is contained in:
parent
9d8b6ddd18
commit
11dc1e1d17
|
@ -10,6 +10,10 @@ import CookieManager from '@react-native-community/cookies'
|
|||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
import { StatusBar } from 'react-native'
|
||||
import { useBackgroundBlur } from './utils/blur'
|
||||
import moment from 'moment'
|
||||
import 'moment/locale/sv'
|
||||
|
||||
moment.locale('sv')
|
||||
|
||||
const api = init(fetch, CookieManager)
|
||||
|
||||
|
|
|
@ -2,15 +2,12 @@ import { useCalendar } from '@skolplattformen/api-hooks'
|
|||
import { CalendarItem } from '@skolplattformen/embedded-api'
|
||||
import { Divider, List, ListItem, Text } from '@ui-kitten/components'
|
||||
import moment from 'moment'
|
||||
import 'moment/locale/sv'
|
||||
import React from 'react'
|
||||
import { Image, ListRenderItemInfo, StyleSheet, View } from 'react-native'
|
||||
import { useChild } from './childContext.component'
|
||||
import { CalendarOutlineIcon } from './icon.component'
|
||||
import { SaveToCalendar } from './saveToCalendar.component'
|
||||
|
||||
moment.locale('sv')
|
||||
|
||||
export const Calendar = () => {
|
||||
const child = useChild()
|
||||
const { data } = useCalendar(child)
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
} from '@skolplattformen/api-hooks'
|
||||
import { Child } from '@skolplattformen/embedded-api'
|
||||
import { Avatar, Button, Card, Text } from '@ui-kitten/components'
|
||||
import { DateTime } from 'luxon'
|
||||
import moment from 'moment'
|
||||
import React from 'react'
|
||||
import { StyleSheet, View } from 'react-native'
|
||||
|
@ -45,8 +44,8 @@ export const ChildListItem = ({ child, color }: ChildListItemProps) => {
|
|||
const { data: calendar, status: calendarStatus } = useCalendar(child)
|
||||
const { data: schedule } = useSchedule(
|
||||
child,
|
||||
DateTime.local().toISO(),
|
||||
DateTime.local().plus({ days: 7 }).toISO()
|
||||
moment().toISOString(),
|
||||
moment().add(7, 'days').toISOString()
|
||||
)
|
||||
|
||||
const notificationsThisWeek = notifications.filter((n) =>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { useNavigation } from '@react-navigation/native'
|
||||
import { StackNavigationProp } from '@react-navigation/stack'
|
||||
import { NewsItem } from '@skolplattformen/embedded-api'
|
||||
import { DateTime } from 'luxon'
|
||||
import React from 'react'
|
||||
import moment from 'moment'
|
||||
import { Dimensions, StyleSheet, Text, View } from 'react-native'
|
||||
import { TouchableOpacity } from 'react-native-gesture-handler'
|
||||
import { useChild } from './childContext.component'
|
||||
|
@ -25,9 +25,7 @@ export const NewsListItem = ({ item }: NewsListItemProps) => {
|
|||
const child = useChild()
|
||||
const hasDate = item.published || item.modified
|
||||
|
||||
const displayDate = hasDate
|
||||
? DateTime.fromISO(hasDate).toRelative({ locale: 'sv', style: 'long' })
|
||||
: null
|
||||
const displayDate = hasDate ? moment(hasDate).fromNow() : null
|
||||
|
||||
return (
|
||||
<TouchableOpacity
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Notification as NotificationType } from '@skolplattformen/embedded-api'
|
||||
import { Card, Text } from '@ui-kitten/components'
|
||||
import { DateTime } from 'luxon'
|
||||
import React from 'react'
|
||||
import { StyleSheet, View } from 'react-native'
|
||||
import { ModalWebView } from './modalWebView.component'
|
||||
import moment from 'moment'
|
||||
|
||||
interface NotificationProps {
|
||||
item: NotificationType
|
||||
|
@ -14,9 +14,9 @@ export const Notification = ({ item }: NotificationProps) => {
|
|||
const open = () => setIsOpen(true)
|
||||
const close = () => setIsOpen(false)
|
||||
|
||||
const displayDate = DateTime.fromISO(item.dateCreated).toRelative({
|
||||
locale: 'sv',
|
||||
})
|
||||
const displayDate = item.dateCreated
|
||||
? moment(item.dateCreated).fromNow()
|
||||
: null
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -24,14 +24,13 @@
|
|||
"@react-navigation/native": "5.9.3",
|
||||
"@react-navigation/stack": "5.14.3",
|
||||
"@skolplattformen/api-hooks": "2.0.0",
|
||||
"@skolplattformen/embedded-api": "^2.1.3",
|
||||
"@skolplattformen/embedded-api": "^2.1.7",
|
||||
"@ui-kitten/components": "5.0.0",
|
||||
"@ui-kitten/eva-icons": "5.0.0",
|
||||
"buffer": "6.0.3",
|
||||
"formik": "2.2.6",
|
||||
"hermes-engine": "0.7.2",
|
||||
"jsuri": "1.3.1",
|
||||
"luxon": "1.26.0",
|
||||
"personnummer": "3.1.1",
|
||||
"react": "17.0.1",
|
||||
"react-native": "0.64.0",
|
||||
|
@ -62,7 +61,6 @@
|
|||
"@testing-library/react-native": "7.1.0",
|
||||
"@types/jest": "^26.0.22",
|
||||
"@types/jsuri": "^1.3.30",
|
||||
"@types/luxon": "^1.26.2",
|
||||
"@types/markdown-it": "^12.0.1",
|
||||
"@types/react-native": "^0.64.1",
|
||||
"@ui-kitten/metro-config": "5.0.0",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import 'react-native-gesture-handler/jestSetup'
|
||||
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock'
|
||||
import moment from 'moment'
|
||||
import 'moment/locale/sv'
|
||||
|
||||
moment.locale('sv')
|
||||
|
||||
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": false,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"exclude": [
|
||||
|
|
|
@ -1456,10 +1456,10 @@
|
|||
react-redux "^7.2.2"
|
||||
redux "^4.0.5"
|
||||
|
||||
"@skolplattformen/embedded-api@^2.1.3":
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@skolplattformen/embedded-api/-/embedded-api-2.1.3.tgz#10ec310563f7f4fd7b90445f58dc4d9f1bf07466"
|
||||
integrity sha512-UdQQMKR9+rpiT1ieutHYOc9FuDAF/Selp1hMd8T8iRofwT/pNFhoYcLKRsctwGX65g4pXv5/lbwEBnEHyzKXqg==
|
||||
"@skolplattformen/embedded-api@^2.1.7":
|
||||
version "2.1.7"
|
||||
resolved "https://registry.yarnpkg.com/@skolplattformen/embedded-api/-/embedded-api-2.1.7.tgz#a9a8fef51c3765f1c3dc0ae2dc14af4ec0f3a520"
|
||||
integrity sha512-uKo4zal5pylqh4PefKogbBGGXYTr3Rpd2VNjnPrbx54PexoIcduQGw0lEtGcp3XHQXiw1fyEglWVgT9djD6www==
|
||||
dependencies:
|
||||
"@types/he" "^1.1.1"
|
||||
camelcase-keys "^6.2.2"
|
||||
|
@ -1714,11 +1714,6 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008"
|
||||
integrity sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q==
|
||||
|
||||
"@types/luxon@^1.26.2":
|
||||
version "1.26.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-1.26.2.tgz#656c24c1af3d41b8854700dc94ed556b9b6ce2f8"
|
||||
integrity sha512-2pvzy4LuxBMBBLAbml6PDcJPiIeZQ0Hqj3PE31IxkNI250qeoRMDovTrHXeDkIL4auvtarSdpTkLHs+st43EYQ==
|
||||
|
||||
"@types/markdown-it@^12.0.1":
|
||||
version "12.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-12.0.1.tgz#8391e19fea4796ff863edda55800c7e669beb358"
|
||||
|
@ -6023,7 +6018,7 @@ lru-cache@^6.0.0:
|
|||
dependencies:
|
||||
yallist "^4.0.0"
|
||||
|
||||
luxon@1.26.0, luxon@^1.25.0:
|
||||
luxon@^1.25.0:
|
||||
version "1.26.0"
|
||||
resolved "https://registry.yarnpkg.com/luxon/-/luxon-1.26.0.tgz#d3692361fda51473948252061d0f8561df02b578"
|
||||
integrity sha512-+V5QIQ5f6CDXQpWNICELwjwuHdqeJM1UenlZWx5ujcRMc9venvluCjFb4t5NYLhb6IhkbMVOxzVuOqkgMxee2A==
|
||||
|
|
Loading…
Reference in New Issue