Skip to content

Conversation

@lachimo
Copy link
Contributor

@lachimo lachimo commented May 1, 2025

No description provided.

@lachimo lachimo requested a review from Copilot May 5, 2025 18:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces changes to support inventory receipt functionality, including new types, schemas, API service updates, and UI components. Key updates include renaming inventory code properties to receipt code numbers, adding a new batchNumber field, and updating endpoints and query functions to support farm-specific receipt retrieval.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/types/custom.type.ts Adds inventoryReceipts to InventoryRequestResponse and renames inventoryCode to receiptCodeNumber in ReceiptResponse.
src/utils/schemas/inventory-receipt.schema.ts Updates schema validations and property names, and modifies optional warehouse IDs.
src/utils/data/table.data.ts Updates property names from inventoryCode to receiptCodeNumber.
src/services/warehouse.service.ts Adjusts the endpoint path for fetching warehouse stock.
src/services/request.service.ts Updates the receipt creation function to use the new CreateInventoryReceipt type and adds a new API for farm-specific receipts.
src/components/card/resource-card.ts Introduces a new resource card component with enhanced loading and error states.
src/components/badge/BadgeReceipt.tsx Enhances badge display modes with new 'title' mode and updates loading/fallback content.
src/app/farm/register/page2.tsx Removes a redundant type attribute from an Input component.
src/app/(main)/warehouse/inventory-receipt/page.tsx Switches to farm-specific receipt retrieval and comments out unused user filtering code.
src/app/(main)/warehouse/inventory-receipt/columns.tsx Cleans up table column definitions for inventory receipts and leaves commented code blocks.
Comments suppressed due to low confidence (3)

src/services/request.service.ts:57

  • [nitpick] The function name 'createInvetoryReceiptFromRequest' appears to have a typographical error. Consider renaming it to 'createInventoryReceiptFromRequest' for clarity.
export const createInvetoryReceiptFromRequest = async (body: CreateInventoryReceipt) => {

src/app/farm/register/page2.tsx:473

  • The removal of the type='number' attribute from the Input component may lead to unexpected behavior for numeric inputs. Consider restoring the type attribute if the input is meant for numeric values.
                                                                    type="number"

src/app/(main)/warehouse/inventory-receipt/page.tsx:24

  • [nitpick] There is commented-out code for fetching users and filtering receipts. Removing unused commented code can improve maintainability.
// useQuery({ ... })

Comment on lines 57 to 65
// {
// accessorKey: 'subcategoryName',
// header: ({ column }) => <DataTableColumnHeader column={column} title="Danh mục" />,
// cell: ({ row }) => <div>{row.getValue('subcategoryName')}</div>,
// accessorKey: 'createdByUserId',
// header: ({ column }) => <DataTableColumnHeader column={column} title="Tạo bởi" />,
// cell: ({ row }) => {
// const users: User[] = JSON.parse(sessionStorage.getItem('users') || '[]');
// const createBy = users.find((user) => user.userId === row.getValue('createdByUserId'));
// return <span>{createBy?.fullName ?? '-'}</span>;
// },
// },
Copy link

Copilot AI May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider removing the commented-out block of code for the 'createdByUserId' column if it is no longer needed, to enhance code clarity.

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 12
import { getWareById } from '@/services/warehouse.service';

Copy link

Copilot AI May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import 'getWareById' is not used within this file. Consider removing the unused import to clean up the code.

Suggested change
import { getWareById } from '@/services/warehouse.service';

Copilot uses AI. Check for mistakes.
@lachimo lachimo requested a review from Copilot May 6, 2025 20:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality for creating and managing inventory receipts and stock receipts, including associated schema updates, API service methods, and UI components. Key changes include renaming and restructuring of receipt fields (e.g. inventoryCode to receiptCodeNumber), updates to warehouse service endpoints, and new pages/components for creating stock receipts and viewing inventory receipt details.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/schemas/stock-receipt.schema.ts Introduces the StockReceipt schema with commented alternatives for unitId handling.
src/utils/schemas/inventory-receipt.schema.ts Renames inventoryCode to receiptCodeNumber and updates handling of warehouse IDs.
src/services/warehouse.service.ts Updates endpoint paths for warehouse stock requests.
src/app/farm/register/page2.tsx Removes the type="number" attribute from an Input component for coordinate input.
src/app/(main)/warehouse/inventory-receipt/[inventoryReceiptId]/page.tsx Updates user lookup and adds navigation logic for receipt details.
(Other files) Various UI, schema, and API adjustments to support the new inventory receipt workflow.
Comments suppressed due to low confidence (4)

src/app/farm/register/page2.tsx:473

  • [nitpick] The removal of the type="number" attribute from the Input component may affect numeric input behavior; consider restoring it if numeric validation is required.
<Input step="any" {...field} />

src/utils/schemas/inventory-receipt.schema.ts:11

  • [nitpick] Using .optional().or(z.literal('')) for wareFromId may lead to ambiguous value handling; please confirm that an empty string is the desired fallback value.
.optional() // undefined

src/services/warehouse.service.ts:39

  • The endpoint path has changed from '/warestocks/' to '/warestock/'; please verify that this matches the current backend API specification to avoid call mismatches.
const endpoint = `${PREFIX}/warestock/${resourceId}`;

src/app/(main)/warehouse/inventory-receipt/[inventoryReceiptId]/page.tsx:69

  • Switching from receipt.createdByUserId to receipt.userId for user lookup may result in an incorrect creator name; please verify that this change is intentional.
const createdBy = users?.find((user) => user.userId === receipt.userId);

Comment on lines 20 to 21
// .optional() // undefined
// .or(z.literal('')), // null,
Copy link

Copilot AI May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider removing commented-out alternatives for unitId handling if they are no longer needed.

Suggested change
// .optional() // undefined
// .or(z.literal('')), // null,

Copilot uses AI. Check for mistakes.
@hdang09 hdang09 merged commit 9de8eb5 into dev May 7, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants