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

Fola/upload house list #29

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cedcc5d
upload csv file up until comparing new members to old memebers
foloye Apr 14, 2023
42b8af2
fixed testing page merging conflicts
foloye Apr 14, 2023
c2b7110
Merge branch 'main' of https://github.com/calblueprint/bsc-web-app in…
foloye Apr 15, 2023
b33584a
Merge branch 'main' of https://github.com/calblueprint/bsc-web-app in…
foloye Apr 20, 2023
ceacbcf
semi working upload House List
foloye Apr 23, 2023
5c7cb9f
Merge branch 'main' of https://github.com/calblueprint/bsc-web-app in…
foloye Apr 23, 2023
a14eeba
new api
christianjc Apr 23, 2023
56545b1
merged main
christianjc Apr 23, 2023
4625372
Merge branch 'features/authorizedUsersApi' of https://github.com/calb…
foloye Apr 23, 2023
c9a3a2d
"Tested api"
christianjc Apr 23, 2023
785d754
Merge branch 'features/authorizedUsersApi' of https://github.com/calb…
foloye Apr 23, 2023
e40f521
added changes
christianjc Apr 23, 2023
8a3a3f4
need to commit before merge, but mostly done with upload House list n…
foloye Apr 23, 2023
0ef8b00
Merge branch 'features/authorizedUsersApi' of https://github.com/calb…
foloye Apr 23, 2023
6d1dcff
upload house list currently
foloye Apr 25, 2023
fb39eda
Merge branch 'main' of https://github.com/calblueprint/bsc-web-app in…
foloye Apr 27, 2023
4fa3b52
done iwth upload house list
foloye Apr 29, 2023
366b6f8
fixed margin of btns
foloye Apr 29, 2023
ca647e0
Merge branch 'main' of https://github.com/calblueprint/bsc-web-app in…
foloye Apr 29, 2023
5ee223c
vercel pls let me live
foloye Apr 29, 2023
2bcaaff
eslint slay
foloye Apr 29, 2023
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ yarn-error.log*

# local env files
.env*.local
.env.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

18 changes: 18 additions & 0 deletions package-lock.json

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

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
"formik": "^2.2.9",
"material-ui-popup-state": "^5.0.8",
"next": "13.2.4",
"papaparse": "^5.4.1",
"prettier": "^2.8.7",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "^8.0.5",
"react-uuid": "^2.0.0",
"typescript": "5.0.2",
"yup": "^1.0.2"
},
"devDependencies": {
"@types/papaparse": "^5.3.7"
}
}
3 changes: 2 additions & 1 deletion src/features/auth/AuthState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const AuthState = ({ children }: Props) => {
const [isProcessing, setIsProcessing] = useState(true)

useEffect(() => {
// console.log('*****AuthState Component ran')
console.log('*****AuthState Component ran')
console.log(auth)

const unsubscribe = onAuthStateChanged(auth, async (user) => {
if (user) {
Expand Down
41 changes: 34 additions & 7 deletions src/features/authorizedUser/authorizedUserApiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AuthorizedUser, User } from '../../types/schema'
import { apiSlice } from '../../store/api/apiSlice'
import { RootState } from '../../store/store'

const authorizedUsersAdapter = createEntityAdapter<User>({})
const authorizedUsersAdapter = createEntityAdapter<AuthorizedUser>({})

const initialState = authorizedUsersAdapter.getInitialState()

Expand All @@ -15,7 +15,36 @@ export const authorizedUsersApiSlice = apiSlice.injectEndpoints({
method: 'GET',
params: { queryType: 'authorized users' },
}),
transformResponse: (responseData: User[]) => {
transformResponse: (responseData: AuthorizedUser[]) => {
const loadedAuthorizedUsers = responseData.map((entity) => {
entity.id = entity.id
return entity
})
console.debug(loadedAuthorizedUsers)
return authorizedUsersAdapter.setAll(
initialState,
loadedAuthorizedUsers
)
},
providesTags: (result) => {
if (result?.ids) {
return [
{ type: 'AuthorizedUser', id: 'LIST' },
...result.ids.map((id) => ({
type: 'AuthorizedUser' as const,
id,
})),
]
} else return [{ type: 'AuthorizedUser', id: 'LIST' }]
},
}),
getHouseAuthorizedUsers: builder.query({
query: (value: string) => ({
url: `authorizedUsers`,
method: 'GET',
params: { filter: { fieldPath: 'houseID', opStr: '==', value } },
}),
transformResponse: (responseData: AuthorizedUser[]) => {
const loadedAuthorizedUsers = responseData.map((entity) => {
entity.id = entity.id
return entity
Expand Down Expand Up @@ -49,10 +78,7 @@ export const authorizedUsersApiSlice = apiSlice.injectEndpoints({
invalidatesTags: [{ type: 'AuthorizedUser', id: 'LIST' }],
}),
updateAuthorizedUser: builder.mutation({
query: (data: {
userId: string,
data: Partial<AuthorizedUser>
}) => ({
query: (data: { userId: string; data: Partial<AuthorizedUser> }) => ({
url: `authorizedUsers/${data.userId}`,
method: 'PATCH',
body: {
Expand All @@ -71,6 +97,7 @@ export const {
useGetAuthorizedUsersQuery,
useAddNewAuthorizedUserMutation,
useUpdateAuthorizedUserMutation,
useGetHouseAuthorizedUsersQuery,
} = authorizedUsersApiSlice

// Creates memoized selector to get normalized state based on the query parameter
Expand All @@ -91,4 +118,4 @@ export const selectAuthorizedUsersById = (queryParameter: string) =>
data: { entities: { [x: string]: unknown } },
authorizedUserId: string | number
) => data.entities[authorizedUserId]
)
)
Empty file.
11 changes: 11 additions & 0 deletions src/pages/account/testing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ import {
selectCurrentUser,
} from '@/features/auth/authSlice'
import { Typography } from '@mui/material'
import { useGetAuthorizedUsersQuery } from '@/features/authorizedUser/authorizedUserApiSlice'
import ShiftInfoHeader from '@/components/shared/shiftCardHeader/ShiftInfoHeader'
import { useGetShiftsQuery } from '@/features/shift/shiftApiSlice'

const TestingPage = () => {
const authUser = useSelector(selectCurrentUser)
const { data: authHouseUsersData } = useGetAuthorizedUsersQuery('EUC')
// console.log(authUser)

useEffect(() => {
if (authHouseUsersData) {
console.log('Auth User', authHouseUsersData)
}
}, [authHouseUsersData])

/**
* Here is an example of how I tested my ShiftInfoHeader component.
* Feel free to delete whatever here and replace with what you want to test!
Expand Down
13 changes: 13 additions & 0 deletions src/pages/testing/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// use this to test your stuff
import UploadHouseListCard from '../../sprintFiles/uploadHouseListCard'
import UploadHouseListBtn from '../../sprintFiles/uploadHouseListBtn'

const index = () => {
return (
<div>
<UploadHouseListCard/>
</div>

)
}
export default index
9 changes: 9 additions & 0 deletions src/sprintFiles/uploadHouseListBtn.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Button from '@mui/material/Button';
import AddIcon from '@mui/icons-material/Add';
const uploadHouseListBtn = () => {

return (
<Button>Add Members <AddIcon/></Button>
)
}
export default uploadHouseListBtn
Loading