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

♻️ Regenerate client to use UUID instead of ID integers and update frontend #1281

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

rehanabdul
Copy link
Contributor

Description

Problem:
Previously, the deleteEntity function was designed to handle IDs as numbers. After updating the ID format to UUIDs (strings), the function's type handling needed adjustment to correctly process these new string-based IDs.

Solution:
The function deleteEntity was modified to handle IDs as strings. The fix ensures compatibility with UUIDs and correctly routes the deletion request based on the entity type.

Changes Made

  1. Type Update:

    • Updated the id parameter type from number to string to accommodate UUIDs.
  2. Function Logic:

    • Item Deletion: Calls ItemsService.deleteItem with an id parameter of type string.
    • User Deletion: Calls UsersService.deleteUser with userId as a string.
    • Error Handling: Includes a check to throw an error if the type is unexpected.

Code Changes

interface DeleteProps {
	type: string;
	id: string;
	isOpen: boolean;
	onClose: () => void;
}


```typescript
const deleteEntity = async (id: **string**) => {
    if (type === "Item") {
        await ItemsService.deleteItem({ id: id });
    } else if (type === "User") {
        await UsersService.deleteUser({ userId: id });
    } else {
        throw new Error(`Unexpected type: ${type}`);
    }
};

@alejsdev alejsdev changed the title DeleteAlert UI Component Fix ♻️ Regenerate client to use UUID instead of id integers and update frontend Aug 1, 2024
@alejsdev alejsdev merged commit 3676734 into fastapi:master Aug 1, 2024
5 checks passed
@alejsdev
Copy link
Member

alejsdev commented Aug 1, 2024

Hi @rehanabdul! Yes, this update was missing on the frontend, but the client needed to be regenerated as well (this is why tests were failing), so I pushed this to your branch and now it's ready to be merged. 🥳
Thanks for the help! 🤓 🚀

@alejsdev alejsdev changed the title ♻️ Regenerate client to use UUID instead of id integers and update frontend ♻️ Regenerate client to use UUID instead of ID integers and update frontend Aug 1, 2024
gusevyaroslove pushed a commit to gusevyaroslove/fastapi-template that referenced this pull request Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants