-
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
base: main
Are you sure you want to change the base?
Changes from all commits
2feb1c9
d2c8f74
62d20af
bb59975
93da783
632130b
ad5d99e
3c83d68
58ef645
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 |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { FoodRequest } from '../foodRequests/request.entity'; | |
| import { FoodManufacturer } from '../foodManufacturers/manufacturers.entity'; | ||
| import { OrderStatus } from './types'; | ||
| import { Allocation } from '../allocations/allocations.entity'; | ||
| import { User } from '../users/users.entity'; | ||
|
|
||
| @Entity('orders') | ||
| export class Order { | ||
|
|
@@ -99,4 +100,11 @@ export class Order { | |
| }, | ||
| }) | ||
| shippingCost!: number | null; | ||
|
|
||
swarkewalia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @ManyToOne(() => User, { nullable: false, onDelete: 'RESTRICT' }) | ||
| @JoinColumn({ name: 'assignee_id' }) | ||
| assignee!: User; | ||
|
|
||
| @Column({ name: 'assignee_id' }) | ||
|
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. add type: 'int'
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. ^ bumping |
||
| assigneeId!: number; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,14 +120,6 @@ const AdminOrderManagement: React.FC = () => { | |
| const status = order.status; | ||
|
|
||
| const orderWithColor: OrderWithColor = { ...order }; | ||
| if ( | ||
| order.request.pantry.volunteers && | ||
| order.request.pantry.volunteers.length > 0 | ||
| ) { | ||
| orderWithColor.assigneeColor = | ||
|
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. still need to assign assigneeColor so UI doesn't fall back to gray! rn every user on the page is gray |
||
| ASSIGNEE_COLORS[counters[status] % ASSIGNEE_COLORS.length]; | ||
| counters[status]++; | ||
| } | ||
| grouped[status].push(orderWithColor); | ||
| } | ||
|
|
||
|
|
@@ -613,7 +605,6 @@ const OrderStatusSection: React.FC<OrderStatusSectionProps> = ({ | |
| <Table.Body> | ||
| {orders.map((order, index) => { | ||
| const pantry = order.request.pantry; | ||
| const volunteers = pantry.volunteers || []; | ||
|
|
||
| return ( | ||
| <Table.Row | ||
|
|
@@ -670,26 +661,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 */} | ||
| {volunteers[0].firstName.charAt(0).toUpperCase()} | ||
| {volunteers[0].lastName.charAt(0).toUpperCase()} | ||
| </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 | ||
|
|
@@ -712,10 +698,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