-
Notifications
You must be signed in to change notification settings - Fork 13
Add date and time support client-side #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
|
||
import { useDateInput } from 'react-google-forms-hooks' | ||
|
||
export default function DateInput({ id }) { | ||
const { register } = useDateInput(id) | ||
|
||
return ( | ||
<div> | ||
<input type='date' {...register()} /> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
|
||
import { useTimeInput } from 'react-google-forms-hooks' | ||
|
||
export default function TimeInput({ id }) { | ||
const { register } = useTimeInput(id) | ||
|
||
return ( | ||
<div> | ||
<input type='time' {...register()} /> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { UseTextFieldReturn } from '../types' | ||
import useTextInput from './utils/useTextInput' | ||
|
||
export const useDateInput = (id: string): UseTextFieldReturn => { | ||
return useTextInput(id, 'DATE') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { UseTextFieldReturn } from '../types' | ||
import useTextInput from './utils/useTextInput' | ||
|
||
export const useTimeInput = (id: string): UseTextFieldReturn => { | ||
return useTextInput(id, 'TIME') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,7 @@ export interface BaseField { | |
} | ||
|
||
export interface TextField extends BaseField { | ||
type: 'SHORT_ANSWER' | 'LONG_ANSWER' | ||
} | ||
|
||
export interface DateField extends BaseField { | ||
type: 'DATE' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DATE and TIME fields act exactly like SHORT_ANSWER and LONG_ANSWER from what I could see, since they're basically just strings, so it makes more sense to group them together There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are their format the same? Would it make sense to add some validation regarding the date format? I will have to take a deeper look into how google forms handles these type of inputs |
||
type: 'SHORT_ANSWER' | 'LONG_ANSWER' | 'DATE' | 'TIME' | ||
} | ||
|
||
export interface CustomOptionField extends BaseField { | ||
|
@@ -59,7 +55,6 @@ export interface GridField extends BaseField { | |
|
||
export type Field = | ||
| TextField | ||
| DateField | ||
| CustomOptionField | ||
| DropdownField | ||
| GridField | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, will fix