Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions examples/sheets/SmartDateSheet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import _ from 'lodash'
import {
FlatfileRecord,
} from '@flatfile/hooks'

import {
Portal,
Sheet,
Expand All @@ -14,17 +19,28 @@ import {SmartDateField } from '../fields/SmartDateField'
*
* This sheet combined with sample-uploads shows how SmartDateField handles a variety of date formats
*/
const DateSheet = new Sheet('DateSheet', {
fstring: TextField(),
raw_date: TextField(),
base_date: SmartDateField({}),
en_date: SmartDateField({locale:'en'}),
Fr_date: SmartDateField({locale:'fr'}),
Nl_date: SmartDateField({locale:'nl'}),
Ru_date: SmartDateField({locale:'ru'}),
De_date: SmartDateField({locale:'de'}),
descriptions: TextField()
})
const DateSheet = new Sheet(
'DateSheet',
{
fstring: TextField(),
raw_date: TextField(),
base_date: SmartDateField({}),
en_date: SmartDateField({locale:'en', formatString:'yyyy-MM-dd'}),
Fr_date: SmartDateField({locale:'fr'}),
Nl_date: SmartDateField({locale:'nl'}),
Ru_date: SmartDateField({locale:'ru'}),
De_date: SmartDateField({locale:'de'}),
descriptions: TextField()
},
{
recordCompute: (rec:FlatfileRecord) => {

if(!_.isEqual(rec.get('base_date'), rec.get('en_date'))) {
rec.pushInfoMessage('en_date', 'Not equal to base_date', 'error', 'other')
}
}
}
)

/**
* Portals
Expand Down