Skip to content

Commit

Permalink
chore: types, imports
Browse files Browse the repository at this point in the history
  • Loading branch information
VariableVic committed Dec 19, 2024
1 parent d3ef66c commit cf9e86b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
17 changes: 10 additions & 7 deletions backend/src/admin/components/companies/company-form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Drawer, Input, Label, Select, Text } from "@medusajs/ui";
import { AdminUpdateCompany } from "@starter/types";
import { useState } from "react";
import { UpdateCompanyDTO } from "src/modules/company/types/mutations";
import { useRegions } from "../../hooks";

export function CompanyForm({
Expand All @@ -9,13 +9,13 @@ export function CompanyForm({
loading,
error,
}: {
company?: Partial<UpdateCompanyDTO>;
handleSubmit: (data: Partial<UpdateCompanyDTO>) => Promise<void>;
company?: AdminUpdateCompany;
handleSubmit: (data: AdminUpdateCompany) => Promise<void>;
loading: boolean;
error: Error | null;
}) {
const [formData, setFormData] = useState<Partial<UpdateCompanyDTO>>(
company || ({} as Partial<UpdateCompanyDTO>)
const [formData, setFormData] = useState<AdminUpdateCompany>(
company || ({} as AdminUpdateCompany)
);

const { data: regions, loading: regionsLoading } = useRegions();
Expand Down Expand Up @@ -109,8 +109,11 @@ export function CompanyForm({
</Select.Trigger>
<Select.Content className="z-50">
{countries?.map((country) => (
<Select.Item key={country.iso_2} value={country.iso_2}>
{country.name}
<Select.Item
key={country?.iso_2 || ""}
value={country?.iso_2 || ""}
>
{country?.name}
</Select.Item>
))}
</Select.Content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Drawer, toast as toastType } from "@medusajs/ui";
import { QueryCompany, QueryEmployee } from "@starter/types";
import { UpdateEmployeeDTO } from "src/modules/company/types/mutations";
import {
AdminUpdateEmployee,
QueryCompany,
QueryEmployee,
} from "@starter/types";
import { EmployeesUpdateForm } from ".";
import { useUpdateEmployee } from "../../hooks";

Expand All @@ -24,7 +27,7 @@ export function EmployeesUpdateDrawer({
employee.id
);

const handleSubmit = async (formData: UpdateEmployeeDTO) => {
const handleSubmit = async (formData: AdminUpdateEmployee) => {
await mutate(formData).then(() => {
setOpen(false);
refetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@medusajs/ui";
import { QueryCompany, QueryEmployee } from "@starter/types";
import { useState } from "react";
import { UpdateEmployeeDTO } from "src/modules/company/types/mutations";
import { AdminUpdateEmployee } from "@starter/types";
import { currencySymbolMap } from "../../utils";
import { CoolSwitch } from "../common";

Expand All @@ -22,7 +22,7 @@ export function EmployeesUpdateForm({
}: {
employee: QueryEmployee;
company: QueryCompany;
handleSubmit: (data: UpdateEmployeeDTO) => Promise<void>;
handleSubmit: (data: AdminUpdateEmployee) => Promise<void>;
loading: boolean;
error: Error | null;
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/framework";
import { removeCompanyFromCustomerGroupWorkflow } from "src/workflows/company/workflows/remove-company-from-customer-group";
import { removeCompanyFromCustomerGroupWorkflow } from "../../../../../../workflows/company/workflows/remove-company-from-customer-group";
import { AdminRemoveCompanyFromCustomerGroupType } from "../../../validators";

export const DELETE = async (
Expand Down
8 changes: 1 addition & 7 deletions backend/src/types/company/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ export type AdminCreateEmployee = {
customer_id?: string;
};

export type AdminUpdateEmployee = {
id: string;
spending_limit: number;
is_admin: boolean;
company_id: string;
customer_id?: string;
};
export type AdminUpdateEmployee = Partial<AdminCreateEmployee>;

/* Store */

Expand Down

0 comments on commit cf9e86b

Please sign in to comment.