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

feat: b2b approval settings #139

Merged
merged 10 commits into from
Jan 13, 2025
Merged
7 changes: 6 additions & 1 deletion backend/medusa-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { QUOTE_MODULE } from "./src/modules/quote";
import { APPROVAL_MODULE } from "./src/modules/approval";
import { COMPANY_MODULE } from "./src/modules/company";
import { loadEnv, defineConfig, Modules } from "@medusajs/framework/utils";

loadEnv(process.env.NODE_ENV!, process.cwd());
Expand All @@ -15,12 +17,15 @@ module.exports = defineConfig({
},
},
modules: {
companyModuleService: {
[COMPANY_MODULE]: {
resolve: "./modules/company",
},
[QUOTE_MODULE]: {
resolve: "./modules/quote",
},
[APPROVAL_MODULE]: {
resolve: "./modules/approval",
},
[Modules.CACHE]: {
resolve: "@medusajs/medusa/cache-inmemory",
},
Expand Down
4 changes: 2 additions & 2 deletions backend/src/admin/components/common/delete-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Trash } from "@medusajs/icons";
import { Button, Prompt } from "@medusajs/ui";

interface DeletePromptProps {
handleDelete: () => Promise<void>;
handleDelete: () => void;
loading: boolean;
open: boolean;
setOpen: (open: boolean) => void;
Expand All @@ -15,7 +15,7 @@ export const DeletePrompt = ({
setOpen,
}: DeletePromptProps) => {
const handleConfirmDelete = async () => {
await handleDelete();
handleDelete();
setOpen(false);
};

Expand Down
90 changes: 0 additions & 90 deletions backend/src/admin/components/companies/company-actions-menu.tsx

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions backend/src/admin/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export * from "./common";
export * from "./companies";
export * from "./employees";
44 changes: 44 additions & 0 deletions backend/src/admin/hooks/api/approvals.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { FetchError } from "@medusajs/js-sdk";
import {
AdminApprovalSettings,
AdminUpdateApprovalSettings,
} from "@starter/types";
import {
useMutation,
UseMutationOptions,
useQueryClient,
} from "@tanstack/react-query";
import { sdk } from "../../lib/client";
import { queryKeysFactory } from "../../lib/query-key-factory";

export const approvalQueryKey = queryKeysFactory("approval");

export const useUpdateApprovalSettings = (
companyId: string,
options?: UseMutationOptions<
AdminApprovalSettings,
FetchError,
AdminUpdateApprovalSettings
>
) => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: (payload: AdminUpdateApprovalSettings) =>
sdk.client.fetch<AdminUpdateApprovalSettings>(
`/admin/companies/${companyId}/approval-settings`,
{
body: payload,
method: "POST",
}
),
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: approvalQueryKey.detail(companyId),
});

options?.onSuccess?.(data, variables, context);
},
...options,
});
};
Loading