-
Notifications
You must be signed in to change notification settings - Fork 0
Info Chip #43 #86
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
Merged
Merged
Info Chip #43 #86
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
19df7a4
Added basic embedded map in newly created components folder under Emb…
MasonMines2006 86fb542
Implemented basic embed map
MasonMines2006 d35c431
created react map
MasonMines2006 c7d3a4e
Created changed to
MasonMines2006 d11eb73
Merge branch 'main' into embedded-map/#23
MasonMines2006 5e1be29
Fixed Embedded Map to include the react integration library ( vis.gl/…
MasonMines2006 ba97c83
Merge branch 'main' into embedded-map/#23
naasanov df68222
Created Party Demo test page
MasonMines2006 119936a
Merge remote-tracking branch 'origin/main' into embedded-map/#23
MasonMines2006 9128996
First mockup of party list props, and page created to be displayed in…
MasonMines2006 49a441b
Added popup text box and color to map
MasonMines2006 e527ab9
Removed package and package lock in root directory, updated .env.temp…
MasonMines2006 e09d155
Created functioning dropdown for party list
MasonMines2006 adcf2e0
Modified styling to be accurate with the Lo-Fi wireframe
MasonMines2006 2b5c3af
Changed API keys and added basic sidebar functionality
MasonMines2006 b9f17ce
Working global sidebar
MasonMines2006 f7c714f
Created generic implementation of info chips
MasonMines2006 0a33dbd
Finished implementation of generic info chip details, added specific …
MasonMines2006 0f40423
Merge branch 'main' into mason-info-chip
MasonMines2006 6e95b02
Merge branch 'main' of https://github.com/cssgunc/party-registration …
naasanov 8dfdd64
Minor changes to PartyList before merge with main
MasonMines2006 acdee3e
Merging with Main
MasonMines2006 af89dcf
fixed type erros
MasonMines2006 90a68ca
Resolved corrections suggested in PR review
MasonMines2006 a3bb5f3
Merge remote-tracking branch 'origin/mason-info-chip' into mason-info…
MasonMines2006 03693b0
Changes to sidebar functionality and chip information
MasonMines2006 6ff4e3d
Reverted to old non-shadCN sidebar implementation
MasonMines2006 1a490b4
Merge branch 'main' of https://github.com/cssgunc/party-registration …
naasanov e1319e9
chore: update package.json
naasanov 3f6ec84
chore: reverted whitespace changes to prevent merge conflicts
naasanov 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| "use client"; | ||
|
|
||
| import { GenericInfoChip } from "@/components/GenericInfoChip"; | ||
| import LocationInfoChipDetails from "@/components/LocationInfoChipDetails"; | ||
| import { useSidebar } from "@/components/SidebarContext"; | ||
| import StudentInfoChipDetails from "@/components/StudentInfoChipDetails"; | ||
| import { Location } from "@/types/api/location"; | ||
| import { Student } from "@/types/api/student"; | ||
|
|
||
| const Page = () => { | ||
| const { openSidebar } = useSidebar(); | ||
| const { student: defaultStudent, location: defaultLocation } = | ||
| getTestChipData(); | ||
|
|
||
| return ( | ||
| <div className="font-sans min-h-screen flex flex-col items-center justify-center p-8 sm:p-20 max-w-2xl mx-auto"> | ||
| <h1 className="text-3xl font-bold mb-4">Info Chip Demo Page</h1> | ||
|
|
||
| <h2 className="text-2xl font-bold mb-4">Test Sidebar</h2> | ||
| <button | ||
| className="bg-gray-200 px-3 py-1 rounded mb-6" | ||
| onClick={() => | ||
| openSidebar( | ||
| "test-sidebar", | ||
| "Example", | ||
| "Example Description", | ||
| <div>Hello from Sidebar!</div> | ||
| ) | ||
| } | ||
| > | ||
| Open Sidebar | ||
| </button> | ||
|
|
||
| <h2 className="text-2xl font-bold mb-4">Student Info Chip</h2> | ||
| <GenericInfoChip | ||
| chipKey="student-1" | ||
| shortName={`${defaultStudent.firstName} ${defaultStudent.lastName}`} | ||
| title="Student Information" | ||
| description="Detailed information about the selected student" | ||
| sidebarContent={<StudentInfoChipDetails data={defaultStudent} />} | ||
| /> | ||
|
|
||
| <h2 className="text-2xl font-bold mt-6 mb-4">Location Info Chip</h2> | ||
| <GenericInfoChip | ||
| chipKey="location-1" | ||
| title="Location Information" | ||
| description="Detailed information about the selected location" | ||
| shortName={defaultLocation.formattedAddress} | ||
| sidebarContent={<LocationInfoChipDetails data={defaultLocation} />} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export function getTestChipData() { | ||
| const student: Student = { | ||
| id: 1, | ||
| firstName: "Mr", | ||
| lastName: "Beast", | ||
| contactPreference: "text", | ||
| email: "[email protected]", | ||
| pid: "123456789", | ||
| lastRegistered: new Date("2023-08-15"), | ||
| phoneNumber: "555-1234", | ||
| }; | ||
|
|
||
| const location: Location = { | ||
| id: 1, | ||
| warningCount: 2, | ||
| citationCount: 1, | ||
| hasActiveHold: true, | ||
| holdExpirationDate: new Date("2025-12-31"), | ||
| googlePlaceId: "abcd1234", | ||
| formattedAddress: "123 Main St, Chapel Hill, NC", | ||
| latitude: 35.9132, | ||
| longitude: -79.0558, | ||
| streetNumber: "123", | ||
| streetName: "Main St", | ||
| unit: "Apt 4", | ||
| city: "Chapel Hill", | ||
| county: "Orange", | ||
| state: "NC", | ||
| country: "USA", | ||
| zipCode: "27514", | ||
| }; | ||
|
|
||
| return { student, location }; | ||
| } | ||
|
|
||
| export default Page; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| "use client"; | ||
|
|
||
| import { ReactNode } from "react"; | ||
|
|
||
| interface GenericChipDetailsProps<T> { | ||
| data: T; | ||
| title: string; | ||
| description: string; | ||
| renderView: (value: T) => ReactNode; | ||
| } | ||
|
|
||
| export function GenericChipDetails<T>({ | ||
| data, | ||
| title, | ||
| description, | ||
| renderView, | ||
| }: GenericChipDetailsProps<T>) { | ||
| return ( | ||
| <div className="space-y-3"> | ||
| <h1 className="text-lg font-bold">{title}</h1> | ||
| <h2 className="text-lg">{description}</h2> | ||
| {renderView(data)} | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| "use client"; | ||
|
|
||
| import { useSidebar } from "@/components/SidebarContext"; | ||
| import { Badge } from "@/components/ui/badge"; | ||
| import { ReactNode } from "react"; | ||
|
|
||
| interface GenericInfoChipProps { | ||
| chipKey: string; | ||
| shortName: string; | ||
| title: string; | ||
| description: string; | ||
| sidebarContent: ReactNode; | ||
| } | ||
|
|
||
| export function GenericInfoChip({ | ||
| chipKey, | ||
| shortName, | ||
| title, | ||
| description, | ||
| sidebarContent, | ||
| }: GenericInfoChipProps) { | ||
| const { openSidebar, selectedKey, closeSidebar } = useSidebar(); | ||
| const isSelected = selectedKey === chipKey; | ||
|
|
||
| const handleOpen = () => { | ||
| if (isSelected) { | ||
| closeSidebar(); | ||
| return; | ||
| } else { | ||
| openSidebar(chipKey, title, description, sidebarContent); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <Badge | ||
| onClick={handleOpen} | ||
| className={`cursor-pointer px-3 py-1 ${ | ||
| isSelected ? "bg-blue-500 text-white" : "bg-gray-200 text-black" | ||
| }`} | ||
| > | ||
| {shortName} | ||
| </Badge> | ||
naasanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| "use client"; | ||
| import { useSidebar } from "@/components/SidebarContext"; | ||
|
|
||
| function GenericSidebar() { | ||
| const { isOpen, closeSidebar, content } = useSidebar(); | ||
|
|
||
| if (!isOpen) return null; | ||
|
|
||
| return ( | ||
| <div className="fixed top-0 right-0 w-96 h-full bg-white shadow-lg p-4 overflow-auto z-50"> | ||
| <button | ||
| className="mb-4 px-3 py-1 bg-gray-200 rounded" | ||
| onClick={closeSidebar} | ||
| > | ||
| Close | ||
| </button> | ||
| {content} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default GenericSidebar; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| "use client"; | ||
|
|
||
| import { Location } from "@/types/api/location"; | ||
| import { GenericChipDetails } from "./GenericChipDetails"; | ||
|
|
||
| interface LocationInfoChipDetailsProps { | ||
| data: Location; | ||
| } | ||
|
|
||
| function LocationInfoChipDetails({ data }: LocationInfoChipDetailsProps) { | ||
| return ( | ||
| <GenericChipDetails<Location> | ||
| data={data} | ||
| title={"Info about the Location"} | ||
| description={"View information on the Location you just clicked on"} | ||
| renderView={(d) => ( | ||
| <div className="space-y-3"> | ||
| <div> | ||
| <label className="block text-sm font-medium">Address</label> | ||
| <p className="p-2 border rounded">{d.formattedAddress}</p> | ||
| </div> | ||
| <div> | ||
| <label className="block text-sm font-medium">Warning Count</label> | ||
| <p className="p-2 border rounded">{d.warningCount}</p> | ||
| </div> | ||
| <div> | ||
| <label className="block text-sm font-medium">Citation Count</label> | ||
| <p className="p-2 border rounded">{d.citationCount}</p> | ||
| </div> | ||
| <div> | ||
| <label className="block text-sm font-medium">Active Hold</label> | ||
| <p className="p-2 border rounded"> | ||
| {d.hasActiveHold | ||
| ? "Active: Expires " + d.holdExpirationDate?.toDateString() | ||
| : "No"} | ||
| </p> | ||
| </div> | ||
| </div> | ||
| )} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default LocationInfoChipDetails; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| "use client"; | ||
|
|
||
| import { Party } from "@/types/api/party"; | ||
| import { GenericChipDetails } from "./GenericChipDetails"; | ||
|
|
||
| interface PartyInfoChipDetailsProps { | ||
| data: Party; | ||
| } | ||
|
|
||
| export function PartyInfoChipDetails({ data }: PartyInfoChipDetailsProps) { | ||
| return ( | ||
| <GenericChipDetails<Party> | ||
| data={data} | ||
| title={"Info about the Party"} | ||
| description={"View information on the Party you just clicked on"} | ||
| renderView={(d) => ( | ||
| <div className="space-y-3"> | ||
| <div> | ||
| <label className="block text-sm font-medium">Address</label> | ||
| <p className="p-2 border rounded">{d.location.formattedAddress}</p> | ||
| </div> | ||
| <div> | ||
| <label className="block text-sm font-medium">Date</label> | ||
| <p className="p-2 border rounded">{d.datetime.toDateString()}</p> | ||
| </div> | ||
| <div> | ||
| <label className="block text-sm font-medium">First name</label> | ||
| <p className="p-2 border rounded">{d.contactOne.firstName}</p> | ||
| </div> | ||
| <div> | ||
| <label className="block text-sm font-medium">Last Name</label> | ||
| <p className="p-2 border rounded">{d.contactOne.lastName}</p> | ||
| </div> | ||
| </div> | ||
| )} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default PartyInfoChipDetails; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| "use client"; | ||
| import { createContext, ReactNode, useContext, useState } from "react"; | ||
|
|
||
| type SidebarContextType = { | ||
| isOpen: boolean; | ||
| title: string | null; | ||
| description: string | null; | ||
| content: ReactNode | null; | ||
| selectedKey: string | null; | ||
| openSidebar: ( | ||
| key: string, | ||
| title: string, | ||
| description: string, | ||
| content: ReactNode | ||
| ) => void; | ||
| closeSidebar: () => void; | ||
| }; | ||
| interface SidebarProviderProps { | ||
| children: ReactNode; | ||
| } | ||
|
|
||
| const SidebarContext = createContext<SidebarContextType | undefined>(undefined); | ||
|
|
||
| export function SidebarProvider({ children }: SidebarProviderProps) { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [title, setTitle] = useState<string | null>(null); | ||
| const [description, setDescription] = useState<string | null>(null); | ||
| const [content, setContent] = useState<ReactNode | null>(null); | ||
| const [selectedKey, setSelectedKey] = useState<string | null>(null); | ||
|
|
||
| const openSidebar = ( | ||
| key: string, | ||
| title: string, | ||
| description: string, | ||
| content: ReactNode | ||
| ) => { | ||
| setContent(content); | ||
| setTitle(title); | ||
| setDescription(description); | ||
| setSelectedKey(key); | ||
| setIsOpen(true); | ||
| }; | ||
|
|
||
| const closeSidebar = () => { | ||
| setIsOpen(false); | ||
| setContent(null); | ||
| setSelectedKey(null); | ||
| setTitle(null); | ||
| setDescription(null); | ||
| }; | ||
|
|
||
| return ( | ||
| <SidebarContext.Provider | ||
| value={{ | ||
| isOpen, | ||
| title, | ||
| description, | ||
| content, | ||
| selectedKey, | ||
| openSidebar, | ||
| closeSidebar, | ||
| }} | ||
| > | ||
| {children} | ||
| </SidebarContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| export const useSidebar = () => { | ||
| const context = useContext(SidebarContext); | ||
| if (!context) | ||
| throw new Error("useSidebar must be used within SidebarProvider"); | ||
| return context; | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.