-
Notifications
You must be signed in to change notification settings - Fork 0
SSF-135 - admin order management changes #121
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
Changes from all commits
2feb1c9
d2c8f74
62d20af
bb59975
93da783
632130b
ad5d99e
3c83d68
58ef645
428f682
dc0482e
501007f
f3b61c3
0c775e8
058a8da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class AddAssigneeToOrders1773009000618 implements MigrationInterface { | ||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(`ALTER TABLE orders ADD COLUMN assignee_id INT`); | ||
|
|
||
| await queryRunner.query(` | ||
| UPDATE orders o SET assignee_id = ( | ||
| SELECT va.volunteer_id FROM volunteer_assignments va | ||
| JOIN food_requests fr ON fr.pantry_id = va.pantry_id | ||
| WHERE fr.request_id = o.request_id | ||
| LIMIT 1 | ||
| ) | ||
| `); | ||
|
|
||
| await queryRunner.query(` | ||
| ALTER TABLE orders | ||
| ALTER COLUMN assignee_id SET NOT NULL, | ||
| ADD CONSTRAINT fk_assignee_id FOREIGN KEY (assignee_id) REFERENCES users(user_id) ON DELETE RESTRICT | ||
| `); | ||
Yurika-Kan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE orders | ||
| DROP CONSTRAINT IF EXISTS fk_assignee_id, | ||
| DROP COLUMN assignee_id | ||
| `); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,25 +110,15 @@ const AdminOrderManagement: React.FC = () => { | |
| [OrderStatus.DELIVERED]: [], | ||
| }; | ||
|
|
||
| // Use a status specific counter for assignee color assignment | ||
| const counters: Record<OrderStatus, number> = { | ||
| [OrderStatus.SHIPPED]: 0, | ||
| [OrderStatus.PENDING]: 0, | ||
| [OrderStatus.DELIVERED]: 0, | ||
| }; | ||
|
|
||
| for (const order of data) { | ||
| const status = order.status; | ||
|
|
||
| const orderWithColor: OrderWithColor = { ...order }; | ||
| if ( | ||
| order.request.pantry.volunteers && | ||
| order.request.pantry.volunteers.length > 0 | ||
| ) { | ||
|
|
||
| if (order.assignee) { | ||
| orderWithColor.assigneeColor = | ||
swarkewalia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ASSIGNEE_COLORS[counters[status] % ASSIGNEE_COLORS.length]; | ||
| counters[status]++; | ||
| ASSIGNEE_COLORS[order.assignee.id % ASSIGNEE_COLORS.length]; | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we map user & color so a user across different orders would still be the same color? this is used in volunteerManagement.tsx ASSIGNEE_COLORS[assigneeCounter % ASSIGNEE_COLORS.length]; bg={ASSIGNEE_COLORS[order.assignee.id % ASSIGNEE_COLORS.length]} |
||
| grouped[status].push(orderWithColor); | ||
| } | ||
|
|
||
|
|
@@ -614,7 +604,6 @@ const OrderStatusSection: React.FC<OrderStatusSectionProps> = ({ | |
| <Table.Body> | ||
| {orders.map((order, index) => { | ||
| const pantry = order.request.pantry; | ||
| const volunteers = pantry.volunteers || []; | ||
|
|
||
| return ( | ||
| <Table.Row | ||
|
|
@@ -664,28 +653,21 @@ const OrderStatusSection: React.FC<OrderStatusSectionProps> = ({ | |
| alignItems="center" | ||
| justifyContent="center" | ||
| > | ||
| {volunteers && volunteers.length > 0 ? ( | ||
| <Box | ||
| key={index} | ||
| borderRadius="full" | ||
| bg={order.assigneeColor || 'gray'} | ||
| width="33px" | ||
| height="33px" | ||
| display="flex" | ||
| alignItems="center" | ||
| justifyContent="center" | ||
| color="white" | ||
| p={2} | ||
| > | ||
| {/* TODO: Change logic later to only get one volunteer */} | ||
| {getInitials( | ||
| volunteers[0].firstName, | ||
| volunteers[0].lastName, | ||
| )} | ||
| </Box> | ||
| ) : ( | ||
| <Box>No Assignees</Box> | ||
| )} | ||
| <Box | ||
| key={index} | ||
| borderRadius="full" | ||
| bg={order.assigneeColor || 'gray'} | ||
| width="33px" | ||
| height="33px" | ||
| display="flex" | ||
| alignItems="center" | ||
| justifyContent="center" | ||
| color="white" | ||
| p={2} | ||
| > | ||
| {order.assignee.firstName.charAt(0).toUpperCase()} | ||
| {order.assignee.lastName.charAt(0).toUpperCase()} | ||
| </Box> | ||
| </Box> | ||
| </Table.Cell> | ||
| <Table.Cell | ||
|
|
@@ -708,10 +690,8 @@ const OrderStatusSection: React.FC<OrderStatusSectionProps> = ({ | |
| <Table.Cell | ||
| {...tableCellStyles} | ||
| textAlign="left" | ||
| color="neutral.700" | ||
| > | ||
| {/* TODO: IMPLEMENT WHAT GOES HERE */} | ||
| </Table.Cell> | ||
| bg="#FAFAFA" | ||
| ></Table.Cell> | ||
| </Table.Row> | ||
| ); | ||
| })} | ||
|
|
||
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.
Also here we can edit the dummy data to add ids for the asignee for each order