Skip to content
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

Marcos/user forms #77

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 29 additions & 20 deletions src/components/ManagerComponents/userCard/UserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Formik, Form, FormikHelpers, FormikValues } from 'formik'
import { Stack, Button } from '@mui/material'

import * as Yup from 'yup'
import { TextInput } from '../../shared/forms/CustomFormikFields' //, SelectInput
import { TextInput, SelectInput } from '../../shared/forms/CustomFormikFields' //, SelectInput
import {
selectUserById,
useAddNewUserMutation,
Expand All @@ -14,6 +14,7 @@ import React from 'react'
import { RootState } from '../../../store/store'
import { EntityId } from '@reduxjs/toolkit'
import { User } from '../../../types/schema'
import { generatePinNumber } from '../../../firebase/helpers'
// import { useUserContext } from '../../../context/UserContext'

//** Yup allows us to define a schema, transform a value to match, and/or assert the shape of an existing value. */
Expand All @@ -34,23 +35,9 @@ const UserSchema = Yup.object({
runningTotalPenatlyHours: Yup.number(),
})

// const daysList = [
// '',
// 'Monday',
// 'Tuesday',
// 'Wednesday',
// 'Thursday',
// 'Friday',
// 'Saturday',
// 'Sunday',
// ]

// const userCategories = [
// 'cook dinner',
// 'clean bathroom',
// 'wash dishes',
// 'clean basement',
// ]
const houseIDs = ['EUC', 'CLO']

const userRoles = ['member', 'manager']

const emptyUser = {
// Role of the user
Expand Down Expand Up @@ -100,6 +87,7 @@ const UserForm = ({
setOpen: (value: React.SetStateAction<boolean>) => void
userId?: string
isNewUser: boolean
pinNumber?: number
}) => {
// const { authUser, house } = useUserContext()
// const [currentUser, setCurrentUser] = React.useState(User)
Expand Down Expand Up @@ -136,7 +124,7 @@ const UserForm = ({
formikBag: FormikHelpers<any>
) => {
// console.log('Submiting UserForm: ', values)
const { firstName, lastName, displayName, email } = values
const { firstName, lastName, displayName, email, role, houseID } = values

// console.log(dayjs('1900', 'HHmm').format('HHmm'))
// const num = 1900
Expand All @@ -146,16 +134,21 @@ const UserForm = ({
let result

const data = { data: {}, houseId: '', userId: '' }
const pinNumber = generatePinNumber(5)
data.data = {
firstName,
lastName,
displayName,
email,
role,
houseID,
pinNumber,
}
data.houseId = 'EUC'
// data.houseId = 'EUC'
data.userId = userId ? userId : ''
// console.log('data: ', data)
if (isNewUser || !userId) {
console.log('Adds user works')
result = await addNewUser(data)
} else {
result = await updateUser(data)
Expand All @@ -166,6 +159,7 @@ const UserForm = ({

formikBag.resetForm()
setOpen(false)
console.log(data)
}

// React.useEffect(() => {
Expand All @@ -182,6 +176,7 @@ const UserForm = ({
displayName: user ? user.displayName : emptyUser.displayName,
email: user ? user.email : emptyUser.email,
role: user ? user.role : emptyUser.role,
houseID: user ? user.houseID : emptyUser.houseID,
}}
onSubmit={onSubmit}
>
Expand All @@ -191,6 +186,20 @@ const UserForm = ({
<TextInput name="lastName" label="Last Name" />
<TextInput name="displayName" label="Display Name" />
<TextInput name="email" label="Email" />
<SelectInput
name="role"
label="Role"
labelid="role"
id="role"
options={userRoles}
/>
<SelectInput
name="houseID"
label="House ID"
labelid="houseID"
id="houseID"
options={houseIDs}
/>

<Stack direction="row" alignItems="center" spacing={2}>
<Button
Expand Down
14 changes: 14 additions & 0 deletions src/pages/manager/members/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Button, Typography } from '@mui/material'
import Layout from '../../../components/Layout/Layout'
import NewUserCard from '../../../components/ManagerComponents/userCard/NewUserCard'

export default function memberPage() {
return (
<Layout>
<Typography variant="h4" color={'#000'}>
Members
</Typography>
<NewUserCard />
</Layout>
)
}
29 changes: 29 additions & 0 deletions src/pages/manager/planner/UnassignedTabContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@ const shiftHeadCells: HeadCell<
label: 'Value',
isSortable: true,
align: 'left',
<<<<<<< HEAD
},
]

const userHeadCells: HeadCell<
Shift & { [key in keyof Shift]: string | number }
>[] = [
{
id: 'email',
isNumeric: false,
label: 'Email',
isSortable: true,
align: 'left',
},
{
id: 'hoursRequired',
isNumeric: true,
label: 'Hours Required',
isSortable: true,
align: 'left',
},
{
id: 'hoursAssigned',
isNumeric: true,
label: 'Value',
isSortable: true,
align: 'left',
=======
>>>>>>> 3304dd218d055e766ce5b32d47368969c8de4d32
},
]

Expand Down