-
Notifications
You must be signed in to change notification settings - Fork 0
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
Style and Create User Pop up Modal in Registration Page #33 #34
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e04139c
achieved front-end view for pop up. just need to plan how the data wi…
m20arcusk 8b3ce41
frontend visuals achieved, just need to refactor the method the data …
m20arcusk 0960883
updated and imported some types for the questions and respones as wel…
m20arcusk 7a29faa
small fix on a comment
m20arcusk a519108
didn't mean to delete BasicInformation in types.ts so I added it back
m20arcusk bdf2754
removed console.log testing lines and updated tailwind with divider c…
m20arcusk d16fc21
updated the fetchQuestion function to use async and await
m20arcusk f817709
changed to use async and await and now grabbing user responses from r…
m20arcusk edbbf14
updated userResponse type and changed how it is accessed in userRespo…
m20arcusk 5ab669a
resolved merge conflicts
m20arcusk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
75 changes: 75 additions & 0 deletions
75
src/components/RegistrationTable/editCellPopUp.tsx/userInfo.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React, { ChangeEvent, useEffect, useState } from 'react' | ||
import { Row, Table } from "@tanstack/react-table" | ||
import { Attendee } from "../columns" | ||
import SelectCell from './userPopupEdit' | ||
import { ColumnMeta } from '../columns' | ||
|
||
interface EditCellProps { | ||
row: Row<Attendee>, | ||
table: Table<Attendee> | ||
} | ||
|
||
const UserInfo: React.FC<EditCellProps> = ({ row, table }) => { | ||
const [fieldLabels, setFieldLabels] = useState<{ [key: string]: string }>({}); | ||
const [dropDownList, setDropDownList] = useState<{ [key: string]: string[] }>({}); | ||
|
||
useEffect(() => { | ||
const generateFieldLabels = () => { | ||
const columns = table.getAllColumns(); | ||
const labels: { [key: string]: string } = {}; | ||
|
||
columns.forEach((column) => { | ||
const accessorKey = column.id; | ||
const header = column.columnDef.header; | ||
|
||
if (accessorKey && typeof header === 'string') { | ||
labels[accessorKey] = header; | ||
} | ||
}); | ||
return labels; | ||
}; | ||
|
||
setFieldLabels(generateFieldLabels()); | ||
|
||
const generateDropDownList = () => { | ||
const columns = table.getAllColumns(); | ||
const options: { [key: string]: string[] } = {}; | ||
columns.forEach(column => { | ||
// had to import meta as Column Meta or else encountered errors | ||
const meta = column.columnDef.meta as ColumnMeta | undefined; | ||
|
||
if (meta?.type === 'select') { | ||
options[column.id] = meta.options?.map(opt => opt.value) || []; | ||
} | ||
}); | ||
|
||
return options; | ||
}; | ||
|
||
setDropDownList(generateDropDownList()); | ||
|
||
}, [table]); | ||
|
||
const fieldsToDisplay = Object.keys(row.original).filter(key => key !== 'shouldNotDisplay' && key !== 'id' && key != 'dynamicResponses'); | ||
|
||
|
||
return ( | ||
<div className="text-white gap-4 m-3 grid auto-cols-fr sm:grid-cols-2"> | ||
{fieldsToDisplay?.map((key) => ( | ||
<div key={key}> | ||
<label className="block font-bold text-baby-blue">{fieldLabels[key]}:</label> | ||
{key === 'regStatus' || key === 'appStatus' ? ( | ||
<SelectCell originalValue={row.original[key]} dropDownList={dropDownList[key]}/> | ||
) : key === 'points' ? ( | ||
<SelectCell originalValue={row.original[key]} dropDownList={dropDownList[key]}/> | ||
) : ( | ||
<span>{row.original[key]}</span> | ||
)} | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export default UserInfo | ||
|
57 changes: 57 additions & 0 deletions
57
src/components/RegistrationTable/editCellPopUp.tsx/userPopupEdit.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" | ||
import { Input } from "@/components/ui/input" | ||
import React, { useState } from 'react' | ||
|
||
|
||
interface SelectCellProps { | ||
originalValue: string | number, | ||
dropDownList: string[] | ||
} | ||
|
||
const SelectCell: React.FC<SelectCellProps> = ({ originalValue, dropDownList }) => { | ||
const [value, setValue] = useState(originalValue) | ||
|
||
const onSelectChange = (newValue: string) => { | ||
setValue(newValue) | ||
console.log("TODO - update data") | ||
} | ||
|
||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setValue(e.target.value); | ||
}; | ||
|
||
|
||
return ( | ||
<div> | ||
{dropDownList ? ( | ||
<Select onValueChange={onSelectChange} defaultValue="Not Found"> | ||
<SelectTrigger className="p3 rounded-none bg-events-active-tab-bg text-white p-0 border-0 border-b-2 border-b-baby-blue"> | ||
<SelectValue> | ||
{value} | ||
</SelectValue> | ||
</SelectTrigger> | ||
<SelectContent className='focus:border-0 bg-white'> | ||
<SelectGroup> | ||
{/* Use the key to access the correct dropDownList */} | ||
{dropDownList.map((item) => ( | ||
<SelectItem key={item} value={item}> | ||
{item} | ||
</SelectItem> | ||
))} | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
) : ( | ||
<Input | ||
className="p3 rounded-none bg-events-active-tab-bg text-white p-0 border-0 border-b-2 border-b-baby-blue" | ||
type="number" | ||
value={value} | ||
onChange={handleInputChange} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default SelectCell; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This data will already be fetched by
src/pages/admin/event/[eventId]/[year]/index.tsx
and we can pass it to this Pop-up component instead of needing to re-fetch everything. Leave this in for now though, and we can refactor it once we have the backend working with the Admin Event Registrations page