This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react' | |
import { | |
Grid, | |
TextField, | |
Button, | |
makeStyles, | |
createStyles, | |
Theme, | |
} from '@material-ui/core' | |
import { Formik, Form, FormikProps } from 'formik' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With Yup validationSchema | |
validationSchema={Yup.object().shape({ | |
email: Yup.string() | |
.email() | |
.required('Enter valid email-id'), | |
})} | |
// With Formik Validate | |
validate={values => { | |
const errors = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const d = new Date() | |
// convert to msec since Jan 1 1970 | |
const localTime = d.getTime() | |
// obtain local UTC offset and convert to msec | |
const localOffset = d.getTimezoneOffset() * 60 * 1000 | |
// obtain UTC time in msec | |
const utcTime = localTime + localOffset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const d = new Date() | |
const date = d.getDate() | |
const month = d.getMonth() | |
const year = d.getFullYear() | |
return date + '/' + (month + 1) + '/' + year | |
// which will return somethig like 2/5/2020 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comment on table public.knex_migrations is E'@name knex_migrations\n@omit create,update,delete\nThis is the documentation.'; | |
comment on table public.knex_migrations_lock is E'@name knex_migrations_lock\n@omit create,update,delete\nThis is the documentation.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
useUpdateUserByIdMutation, | |
useGetUsersQuery, | |
} from '../generated/graphql' | |
export const useGetUsers = useGetUsersQuery | |
export const useUpdateUserById = useUpdateUserByIdMutation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react' | |
import { useUpdateUserById } from '../utils/services' | |
interface updateUser { | |
id: number | |
name: string | |
} | |
const UpdateUser = (props: updateUser) => { | |
const [updateUserById] = useUpdateUserById() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react' | |
import { useGetUsers } from '../utils/services' | |
import { User } from '../generated/graphql' | |
import UpdateUser from './UpdateUser' | |
const Users: React.FC = () => { | |
const [users, setUsers] = useState() | |
const { data, error, loading } = useGetUsers() | |
const [values, setValues] = useState({ | |
id: 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gql from 'graphql-tag' | |
export default gql` | |
mutation updateUserById($id: Int!, $UserPatch: UserPatch!) { | |
updateUserById(input: { id: $id, userPatch: $UserPatch }) { | |
clientMutationId | |
} | |
} | |
` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react' | |
import { useGetUsersQuery, User } from '../generated/graphql' | |
const Users: React.FC = () => { | |
const [users, setUsers] = useState() | |
const { data, error, loading } = useGetUsersQuery() | |
useEffect(() => { | |
if (data) { | |
if (data && data.allUsers && data.allUsers.nodes) { |
NewerOlder