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

fix: fix the wrong delete organization function parameter #952

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ export function useDeleteOrganization() {
const queryClient = useQueryClient();
return useMutation(
async ({
organizationName,
organizationID,
accessToken,
}: {
organizationName: Nullable<string>;
organizationID: Nullable<string>;
accessToken: Nullable<string>;
}) => {
if (!accessToken) {
return Promise.reject(new Error("AccessToken not provided"));
}
if (!organizationName) {
return Promise.reject(new Error("Organization Name not provided"));
if (!organizationID) {
return Promise.reject(new Error("organizationID not provided"));
}

await deleteOrganizationMutation({ organizationName, accessToken });
await deleteOrganizationMutation({ organizationID, accessToken });

return Promise.resolve(organizationName);
return Promise.resolve(organizationID);
},
{
onSuccess: (organizationName) => {
onSuccess: (organizationID) => {
queryClient.setQueryData<Organization[]>(["organizations"], (old) =>
old ? old.filter((e) => e.id !== organizationName) : []
old ? old.filter((e) => e.id !== organizationID) : []
);
},
}
Expand Down
6 changes: 3 additions & 3 deletions packages/toolkit/src/lib/vdp-sdk/organization/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ export async function updateOrganizationMembershipMutation({
}

export async function deleteOrganizationMutation({
organizationName,
organizationID,
accessToken,
}: {
organizationName: string;
organizationID: string;
accessToken: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "core");

await client.delete(`/organizations/${organizationName}`);
await client.delete(`/organizations/${organizationID}`);
} catch (err) {
return Promise.reject(err);
}
Expand Down
Loading