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

Search, sort, and filters #43

Merged
merged 85 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
d23ac73
Writing Architecture for api/user
SamvritSrinath Apr 8, 2024
760646a
profile page frontend progress
sydneyzhang18 Apr 8, 2024
35dce85
admin info progress, will fix alignment issues
sydneyzhang18 Apr 9, 2024
d231e02
Initial branch
yotzkim Apr 9, 2024
3ecaf9f
Initial branch
yotzkim Apr 9, 2024
cb4f383
added delete api route
holychickencow Apr 9, 2024
9f2b367
Made POST route to create furniture item and furniture item validator
yotzkim Apr 9, 2024
3c9b2f1
Merge commit
yotzkim Apr 9, 2024
a55c805
Made POST route to create furniture item and furniture item validator
yotzkim Apr 9, 2024
a025190
more frontend, waiting on designer clarification to finalize
sydneyzhang18 Apr 9, 2024
29a3df1
fixed frontend alignment issue
sydneyzhang18 Apr 14, 2024
e76c278
Added PUT route for updating furniture items
yotzkim Apr 16, 2024
2442c8d
Initial frontend and components structure
yotzkim Apr 16, 2024
51eb55a
Fixed Header bar
yotzkim Apr 19, 2024
b457985
Edit template component
yotzkim Apr 23, 2024
baf5265
Added backend for search function, haven't tested
2s2e Apr 25, 2024
44cd0b5
Removed other get route, and made search functionality work with vsr …
2s2e Apr 25, 2024
4e59205
added sorting based on status and then date received
HarshGurnani Apr 29, 2024
c891e66
added searchability on frontend; bug: can only search by name, and ne…
HarshGurnani Apr 29, 2024
adffffe
added a button and have yet to add functionality to it
holychickencow Apr 30, 2024
8b86ca1
Merge branch 'main' into feat/daniel+yoto/furniture-edit-template
yotzkim Apr 30, 2024
d709394
temp commit
2s2e May 1, 2024
d404f88
complete merge
2s2e May 1, 2024
365f6bf
Revert "added searchability on frontend; bug: can only search by name…
2s2e May 1, 2024
8b39a02
Revert "Revert "added searchability on frontend; bug: can only search…
2s2e May 1, 2024
b167ec7
pasted harsh's original vsr.ts in, hopefully will solve merge issues
2s2e May 1, 2024
f540b60
Added draft of backend code for testing
2s2e May 1, 2024
471cc83
Added props for editing ability for EditTemplate and added comments f…
yotzkim May 2, 2024
2c66a2a
Added a popup, blank so far
2s2e May 3, 2024
e09f0b5
modified FilterModal and zip code filtering
HarshGurnani May 3, 2024
a3a8fe4
Merge branch 'main' into feature/samvrit+sydney/Profile-Home-Page
SamvritSrinath May 3, 2024
6b80568
Fixed word-only issue with search
2s2e May 3, 2024
db289d5
Adding Profile Picture and Firebase Profile WIP
SamvritSrinath May 4, 2024
c106889
Added multiple choice to filter modal, began work for frontend sendin…
2s2e May 7, 2024
ca2276a
Added frontend api functions to send requests to backend, fixed bug w…
yotzkim May 7, 2024
4f01503
added connection to backend for filtering by zipcode and income; need…
HarshGurnani May 9, 2024
00ed973
Rough first start to edit section
yotzkim May 9, 2024
f3afafc
When no VSRs are found, a message is now displayed
2s2e May 9, 2024
75bca69
Income filtering works
2s2e May 10, 2024
8c57470
Filtering by zip code works
2s2e May 10, 2024
6350512
Merge remote-tracking branch 'origin' into feat/daniel+yoto/furniture…
holychickencow May 10, 2024
7c422b4
filter by status added
HarshGurnani May 10, 2024
9de10c4
merged yoto changes and added nonfunctional elements
holychickencow May 13, 2024
b2b1fe3
merged yoto work and added static code
holychickencow May 13, 2024
19c8456
Full functionality for add, edit, and delete furniture items. Updated…
yotzkim May 14, 2024
17b9d31
reset filters button works
2s2e May 16, 2024
2b507b3
Added functionality for chips on filtering
2s2e May 16, 2024
1a440b0
fixed styling for applied filters and added Any button to status (nee…
HarshGurnani May 21, 2024
a584520
Added styling to box shadows and buttons
yotzkim May 22, 2024
d4588ac
fixed coloring on any tag
HarshGurnani May 23, 2024
c1affeb
merging main
HarshGurnani May 23, 2024
9d90428
modified zip code filtering
HarshGurnani May 23, 2024
4c44944
Added error for when zipcode isn't formatted properly
2s2e May 23, 2024
ad0a2b5
minor changes
HarshGurnani May 24, 2024
6ce5944
Zip code filtering appends zip codes instead of overwritting what is …
2s2e May 24, 2024
1cd5ee7
changes discussed in meeting; need to change popup to not be full screen
HarshGurnani May 24, 2024
bcc3c57
Merge branch 'feature/harsh-steven/search-sort-filter' of https://git…
2s2e May 26, 2024
c586f67
Merge branch 'main' into feature/harsh-steven/search-sort-filter
benjaminJohnson2204 May 27, 2024
8059c1b
Remove commented-out code & touch up styles
benjaminJohnson2204 May 27, 2024
0c767f1
Apply filters to VSR bulk exporting
benjaminJohnson2204 May 27, 2024
795ef94
Remove unused zip code invalid error code
benjaminJohnson2204 May 27, 2024
9c3f0fa
Merge search/sort/filter branch
benjaminJohnson2204 May 27, 2024
7e94593
Remove unused files
benjaminJohnson2204 May 27, 2024
8131cc4
Save edits from VSR individual page directly rather than showing conf…
benjaminJohnson2204 May 27, 2024
2cb2a86
Fix linter issues
benjaminJohnson2204 May 27, 2024
d73a39a
Fix styling for edit furniture items feature
benjaminJohnson2204 May 28, 2024
2f3c4a3
Require admin role for modifying furniture items
benjaminJohnson2204 May 28, 2024
ba9adbc
Merge branch 'feature/samvrit+sydney/Profile-Home-Page' into feature/…
benjaminJohnson2204 May 28, 2024
9122f81
Add mobile & tablet styles for profile page
benjaminJohnson2204 May 28, 2024
7e8007b
Redirect staff to profile page by default
benjaminJohnson2204 May 28, 2024
ca61cad
Implement V2 nav bar
benjaminJohnson2204 May 28, 2024
9375693
Implement create user feature
benjaminJohnson2204 May 28, 2024
129f479
Delete user & change password features
benjaminJohnson2204 May 28, 2024
357d6bf
Display confirmation dialog if user has unsaved changes
benjaminJohnson2204 May 28, 2024
6c8e6d8
Notification emails to user & admin when password is changed
benjaminJohnson2204 May 28, 2024
7f22e2f
Edit confirmation email feature
benjaminJohnson2204 May 30, 2024
837fb44
New build of backend
benjaminJohnson2204 May 30, 2024
64483f5
Fix NextJS build errors
benjaminJohnson2204 May 30, 2024
a370ed1
Add type declaration files to dev dependencies
benjaminJohnson2204 May 30, 2024
0f128d1
More type decl files
benjaminJohnson2204 May 30, 2024
84fff9b
Debug firebase settings env var
benjaminJohnson2204 Jun 1, 2024
db3dc24
Revert Firebase debugging
benjaminJohnson2204 Jun 1, 2024
306581f
Fix styling issues Aska found with deployment
benjaminJohnson2204 Jun 14, 2024
c37d1df
Make VSRs searching case insensitive
benjaminJohnson2204 Jun 14, 2024
24c436b
Rebuild backend
benjaminJohnson2204 Jun 14, 2024
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
Prev Previous commit
Next Next commit
modified FilterModal and zip code filtering
  • Loading branch information
HarshGurnani committed May 3, 2024
commit e09f0b5ce5fff3bbabec714c9a333bad25bb16f6
5 changes: 5 additions & 0 deletions frontend/src/api/VSRs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,17 @@ export async function createVSR(vsr: CreateVSRRequest): Promise<APIResult<VSR>>
export async function getAllVSRs(
firebaseToken: string,
search?: string,
zipCodes?: string[],
): Promise<APIResult<VSR[]>> {
try {
if (search) {
const response = await get(`/api/vsr?search=${search}`, createAuthHeader(firebaseToken));
const json = (await response.json()) as VSRListJson;
return { success: true, data: json.vsrs.map(parseVSR) };
} else if (zipCodes) {
const response = await get(`/api/vsr?zipCode=${zipCodes}`, createAuthHeader(firebaseToken));
const json = (await response.json()) as VSRListJson;
return { success: true, data: json.vsrs.map(parseVSR) };
} else {
const response = await get("/api/vsr", createAuthHeader(firebaseToken));
const json = (await response.json()) as VSRListJson;
Expand Down
60 changes: 42 additions & 18 deletions frontend/src/app/staff/vsr/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default function VSRTableView() {

const [selectedVsrIds, setSelectedVsrIds] = useState<string[]>([]);
const [deleteVsrModalOpen, setDeleteVsrModalOpen] = useState(false);

const [isFilterModalOpen, setIsFilterModalOpen] = useState(false);
const [filteredZipCodes, setFilteredZipCodes] = useState<string[]>([]);

useRedirectToLoginIfNotSignedIn();

Expand All @@ -48,27 +50,46 @@ export default function VSRTableView() {
/**
* Fetches the list of all VSRs from the backend and updates our vsrs state.
*/
const fetchVSRs = () => {
const fetchVSRs = (zipCodes = null) => {
if (!firebaseUser) {
return;
}

setLoadingVsrs(true);
firebaseUser?.getIdToken().then((firebaseToken) => {
getAllVSRs(firebaseToken).then((result) => {
if (result.success) {
setVsrs(result.data);
} else {
if (result.error === "Failed to fetch") {
setTableError(VSRTableError.CANNOT_FETCH_VSRS_NO_INTERNET);
if (zipCodes !== null) {
setLoadingVsrs(true);
firebaseUser?.getIdToken().then((firebaseToken) => {
getAllVSRs(firebaseToken, zipCodes).then((result) => {
if (result.success) {
setVsrs(result.data);
} else {
console.error(`Error retrieving VSRs: ${result.error}`);
setTableError(VSRTableError.CANNOT_FETCH_VSRS_INTERNAL);
if (result.error === "Failed to fetch") {
setTableError(VSRTableError.CANNOT_FETCH_VSRS_NO_INTERNET);
} else {
console.error(`Error retrieving VSRs: ${result.error}`);
setTableError(VSRTableError.CANNOT_FETCH_VSRS_INTERNAL);
}
}
}
setLoadingVsrs(false);
setLoadingVsrs(false);
});
});
});
} else {
setLoadingVsrs(true);
firebaseUser?.getIdToken().then((firebaseToken) => {
getAllVSRs(firebaseToken).then((result) => {
if (result.success) {
setVsrs(result.data);
} else {
if (result.error === "Failed to fetch") {
setTableError(VSRTableError.CANNOT_FETCH_VSRS_NO_INTERNET);
} else {
console.error(`Error retrieving VSRs: ${result.error}`);
setTableError(VSRTableError.CANNOT_FETCH_VSRS_INTERNAL);
}
}
setLoadingVsrs(false);
});
});
}
};

// Fetch the VSRs from the backend once the Firebase user loads.
Expand Down Expand Up @@ -197,10 +218,6 @@ export default function VSRTableView() {
onClick={() => setIsFilterModalOpen(true)}
/>
)}
<FilterModal
isOpen={isFilterModalOpen}
onClose={() => setIsFilterModalOpen(false)}
></FilterModal>
<Button
variant="primary"
outlined={false}
Expand Down Expand Up @@ -239,6 +256,13 @@ export default function VSRTableView() {
}}
vsrIds={selectedVsrIds}
/>
<FilterModal
isOpen={isFilterModalOpen}
onClose={() => setIsFilterModalOpen(false)}
onZipCodesEntered={(zipCodes: string[]) => {
setFilteredZipCodes(zipCodes);
}}
/>
</div>
);
}
63 changes: 53 additions & 10 deletions frontend/src/components/VSRTable/FilterModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,67 @@
import styles from "@/components/VSRTable/FilterModal/styles.module.css";
import { useState } from "react";
import Image from "next/image";
import ReactDOM from "react-dom";
import { BaseModal } from "@/components/shared/BaseModal";
import { Button } from "@/components/shared/Button";
import TextField from "@/components/shared/input/TextField";

interface FilterModalProps {
isOpen: boolean;
onClose: () => void;
onZipCodesEntered: (zipCodes: string[]) => void;
}

const FilterModal = ({ isOpen, onClose }: FilterModalProps) => {
const FilterModal = ({ isOpen, onClose, onZipCodesEntered }: FilterModalProps) => {
if (!isOpen) return null;

return ReactDOM.createPortal(
<div className={styles.overlay}>
<div className={styles.modal}>
<button onClick={onClose} className={styles.closeButton}>
X
</button>
</div>
</div>,
document.body,
const [zipCodes, setZipCodes] = useState<string[]>([]);

const handleZipCodeChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setZipCodes(e.target.value.split(",").map((zip) => zip.trim())); // Assuming zip codes are comma-separated
};

const handleApplyFilter = () => {
// Pass the entered zip codes to the parent component when the user applies the filter
onZipCodesEntered(zipCodes);
onClose(); // Close the modal
};

return (
<>
<BaseModal
isOpen={isOpen}
onClose={onClose}
title=""
content={
<TextField
label="Zip Code(s)"
variant="outlined"
placeholder="e.g. 92093"
onChange={handleZipCodeChange}
required={false}
/>
}
bottomRow={
<div className={styles.buttonContainer}>
<Button
variant="error"
outlined
text="Reset Selection"
onClick={onClose}
className={styles.button}
/>
<Button
variant="primary"
outlined={false}
text="Apply Filters"
onClick={handleApplyFilter}
className={styles.button}
/>
</div>
}
/>
</>
);
};

Expand Down
13 changes: 13 additions & 0 deletions frontend/src/components/VSRTable/FilterModal/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@
background: "none";
cursor: "pointer";
}
.buttonContainer {
display: flex;
flex-direction: row;
gap: 32px;
}
.button {
width: 100%;
padding: 12px 24px;
text-align: center;
font-family: "Lora";
font-size: 24px;
font-weight: 700;
}