@mantajs/core 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +138 -3
- package/.medusa/server/src/admin/index.mjs +141 -6
- package/.medusa/server/src/api/admin/employees/middlewares.js +15 -0
- package/.medusa/server/src/api/admin/employees/route.js +21 -0
- package/.medusa/server/src/api/middlewares.js +3 -2
- package/package.json +1 -1
|
@@ -5316,29 +5316,164 @@ const CompaniesPage = () => {
|
|
|
5316
5316
|
] }) })
|
|
5317
5317
|
] });
|
|
5318
5318
|
};
|
|
5319
|
-
const config = adminSdk.defineRouteConfig({
|
|
5319
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
5320
5320
|
label: "Companies",
|
|
5321
5321
|
icon: icons.BuildingStorefront,
|
|
5322
5322
|
rank: 4
|
|
5323
5323
|
});
|
|
5324
|
+
const EmployeesPage = () => {
|
|
5325
|
+
const [searchQuery, setSearchQuery] = React.useState("");
|
|
5326
|
+
const [companyFilter, setCompanyFilter] = React.useState("all");
|
|
5327
|
+
const [roleFilter, setRoleFilter] = React.useState("all");
|
|
5328
|
+
const { data, isLoading, isError, error } = reactQuery.useQuery({
|
|
5329
|
+
queryFn: () => sdk.client.fetch(`/admin/employees`, {
|
|
5330
|
+
query: {
|
|
5331
|
+
limit: 100,
|
|
5332
|
+
offset: 0
|
|
5333
|
+
}
|
|
5334
|
+
}),
|
|
5335
|
+
queryKey: ["employees", "list"]
|
|
5336
|
+
});
|
|
5337
|
+
const employees = (data == null ? void 0 : data.employees) || [];
|
|
5338
|
+
const companies = React.useMemo(() => {
|
|
5339
|
+
const uniqueCompanies = /* @__PURE__ */ new Map();
|
|
5340
|
+
employees.forEach((emp) => {
|
|
5341
|
+
if (emp.company) {
|
|
5342
|
+
uniqueCompanies.set(emp.company.id, emp.company);
|
|
5343
|
+
}
|
|
5344
|
+
});
|
|
5345
|
+
return Array.from(uniqueCompanies.values()).sort(
|
|
5346
|
+
(a2, b) => a2.name.localeCompare(b.name)
|
|
5347
|
+
);
|
|
5348
|
+
}, [employees]);
|
|
5349
|
+
const filteredEmployees = React.useMemo(() => {
|
|
5350
|
+
return employees.filter((employee) => {
|
|
5351
|
+
var _a, _b, _c;
|
|
5352
|
+
if (searchQuery) {
|
|
5353
|
+
const query = searchQuery.toLowerCase();
|
|
5354
|
+
const companyName = ((_b = (_a = employee.company) == null ? void 0 : _a.name) == null ? void 0 : _b.toLowerCase()) || "";
|
|
5355
|
+
if (!companyName.includes(query)) {
|
|
5356
|
+
return false;
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
if (companyFilter !== "all" && ((_c = employee.company) == null ? void 0 : _c.id) !== companyFilter) {
|
|
5360
|
+
return false;
|
|
5361
|
+
}
|
|
5362
|
+
if (roleFilter === "admin" && !employee.is_admin) {
|
|
5363
|
+
return false;
|
|
5364
|
+
}
|
|
5365
|
+
if (roleFilter === "buyer" && employee.is_admin) {
|
|
5366
|
+
return false;
|
|
5367
|
+
}
|
|
5368
|
+
return true;
|
|
5369
|
+
});
|
|
5370
|
+
}, [employees, searchQuery, companyFilter, roleFilter]);
|
|
5371
|
+
const formatCurrency = (amount) => {
|
|
5372
|
+
if (amount === 0) return "Unlimited";
|
|
5373
|
+
return new Intl.NumberFormat("fr-FR", {
|
|
5374
|
+
style: "currency",
|
|
5375
|
+
currency: "EUR"
|
|
5376
|
+
}).format(amount / 100);
|
|
5377
|
+
};
|
|
5378
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "divide-y p-0", children: [
|
|
5379
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
5380
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Employees" }),
|
|
5381
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", children: "Manage B2B company employees and their permissions." })
|
|
5382
|
+
] }) }),
|
|
5383
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 px-6 py-4", children: [
|
|
5384
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1 max-w-sm", children: [
|
|
5385
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.MagnifyingGlass, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-ui-fg-muted" }),
|
|
5386
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5387
|
+
ui.Input,
|
|
5388
|
+
{
|
|
5389
|
+
placeholder: "Search by company name...",
|
|
5390
|
+
value: searchQuery,
|
|
5391
|
+
onChange: (e2) => setSearchQuery(e2.target.value),
|
|
5392
|
+
className: "pl-10"
|
|
5393
|
+
}
|
|
5394
|
+
)
|
|
5395
|
+
] }),
|
|
5396
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { value: companyFilter, onValueChange: setCompanyFilter, children: [
|
|
5397
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { className: "w-[200px]", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, { placeholder: "All companies" }) }),
|
|
5398
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select.Content, { children: [
|
|
5399
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: "all", children: "All companies" }),
|
|
5400
|
+
companies.map((company) => /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: company.id, children: company.name }, company.id))
|
|
5401
|
+
] })
|
|
5402
|
+
] }),
|
|
5403
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { value: roleFilter, onValueChange: setRoleFilter, children: [
|
|
5404
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { className: "w-[150px]", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, { placeholder: "All roles" }) }),
|
|
5405
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select.Content, { children: [
|
|
5406
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: "all", children: "All roles" }),
|
|
5407
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: "admin", children: "Admin" }),
|
|
5408
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: "buyer", children: "Buyer" })
|
|
5409
|
+
] })
|
|
5410
|
+
] }),
|
|
5411
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "text-ui-fg-muted text-sm", children: [
|
|
5412
|
+
filteredEmployees.length,
|
|
5413
|
+
" employee",
|
|
5414
|
+
filteredEmployees.length !== 1 ? "s" : ""
|
|
5415
|
+
] })
|
|
5416
|
+
] }),
|
|
5417
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-4", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Spinner, { className: "animate-spin" }) }) : isError ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "text-ui-fg-error py-8 text-center", children: [
|
|
5418
|
+
"Error: ",
|
|
5419
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
5420
|
+
] }) : filteredEmployees.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle py-8 text-center", children: employees.length === 0 ? "No employees yet." : "No employees match your filters." }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Table, { children: [
|
|
5421
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Table.Row, { children: [
|
|
5422
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.HeaderCell, { children: "ID" }),
|
|
5423
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.HeaderCell, { children: "Company" }),
|
|
5424
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.HeaderCell, { children: "Location" }),
|
|
5425
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.HeaderCell, { children: "Role" }),
|
|
5426
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.HeaderCell, { children: "Spending Limit" }),
|
|
5427
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.HeaderCell, { children: "Created" })
|
|
5428
|
+
] }) }),
|
|
5429
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.Body, { children: filteredEmployees.map((employee) => {
|
|
5430
|
+
var _a, _b, _c, _d, _e;
|
|
5431
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Table.Row, { children: [
|
|
5432
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { className: "font-mono text-sm", children: employee.id.slice(-8) }),
|
|
5433
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { className: "font-medium", children: ((_a = employee.company) == null ? void 0 : _a.name) || "-" }),
|
|
5434
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { children: ((_b = employee.company) == null ? void 0 : _b.city) && ((_c = employee.company) == null ? void 0 : _c.country) ? `${employee.company.city}, ${employee.company.country}` : ((_d = employee.company) == null ? void 0 : _d.city) || ((_e = employee.company) == null ? void 0 : _e.country) || "-" }),
|
|
5435
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: employee.is_admin ? "purple" : "grey", children: employee.is_admin ? "Admin" : "Buyer" }) }),
|
|
5436
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { children: formatCurrency(employee.spending_limit) }),
|
|
5437
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { children: new Date(employee.created_at).toLocaleDateString() })
|
|
5438
|
+
] }, employee.id);
|
|
5439
|
+
}) })
|
|
5440
|
+
] }) })
|
|
5441
|
+
] });
|
|
5442
|
+
};
|
|
5443
|
+
const config = adminSdk.defineRouteConfig({
|
|
5444
|
+
label: "Employees",
|
|
5445
|
+
icon: icons.Users
|
|
5446
|
+
});
|
|
5324
5447
|
const widgetModule = { widgets: [] };
|
|
5325
5448
|
const routeModule = {
|
|
5326
5449
|
routes: [
|
|
5327
5450
|
{
|
|
5328
5451
|
Component: CompaniesPage,
|
|
5329
5452
|
path: "/companies"
|
|
5453
|
+
},
|
|
5454
|
+
{
|
|
5455
|
+
Component: EmployeesPage,
|
|
5456
|
+
path: "/employees"
|
|
5330
5457
|
}
|
|
5331
5458
|
]
|
|
5332
5459
|
};
|
|
5333
5460
|
const menuItemModule = {
|
|
5334
5461
|
menuItems: [
|
|
5335
5462
|
{
|
|
5336
|
-
label: config.label,
|
|
5337
|
-
icon: config.icon,
|
|
5463
|
+
label: config$1.label,
|
|
5464
|
+
icon: config$1.icon,
|
|
5338
5465
|
path: "/companies",
|
|
5339
5466
|
nested: void 0,
|
|
5340
5467
|
rank: 4,
|
|
5341
5468
|
translationNs: void 0
|
|
5469
|
+
},
|
|
5470
|
+
{
|
|
5471
|
+
label: config.label,
|
|
5472
|
+
icon: config.icon,
|
|
5473
|
+
path: "/employees",
|
|
5474
|
+
nested: void 0,
|
|
5475
|
+
rank: void 0,
|
|
5476
|
+
translationNs: void 0
|
|
5342
5477
|
}
|
|
5343
5478
|
]
|
|
5344
5479
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
|
-
import { toast, Container, Heading, Text, Button, Table, FocusModal, Label, Input } from "@medusajs/ui";
|
|
4
|
-
import { BuildingStorefront, Plus, Spinner } from "@medusajs/icons";
|
|
3
|
+
import { toast, Container, Heading, Text, Button, Table, FocusModal, Label, Input, Select, Badge } from "@medusajs/ui";
|
|
4
|
+
import { BuildingStorefront, Plus, Spinner, Users, MagnifyingGlass } from "@medusajs/icons";
|
|
5
5
|
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
|
|
6
|
-
import React, { useState } from "react";
|
|
6
|
+
import React, { useState, useMemo } from "react";
|
|
7
7
|
import Medusa from "@medusajs/js-sdk";
|
|
8
8
|
var isCheckBoxInput = (element) => element.type === "checkbox";
|
|
9
9
|
var isDateObject = (value) => value instanceof Date;
|
|
@@ -5312,29 +5312,164 @@ const CompaniesPage = () => {
|
|
|
5312
5312
|
] }) })
|
|
5313
5313
|
] });
|
|
5314
5314
|
};
|
|
5315
|
-
const config = defineRouteConfig({
|
|
5315
|
+
const config$1 = defineRouteConfig({
|
|
5316
5316
|
label: "Companies",
|
|
5317
5317
|
icon: BuildingStorefront,
|
|
5318
5318
|
rank: 4
|
|
5319
5319
|
});
|
|
5320
|
+
const EmployeesPage = () => {
|
|
5321
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
5322
|
+
const [companyFilter, setCompanyFilter] = useState("all");
|
|
5323
|
+
const [roleFilter, setRoleFilter] = useState("all");
|
|
5324
|
+
const { data, isLoading, isError, error } = useQuery({
|
|
5325
|
+
queryFn: () => sdk.client.fetch(`/admin/employees`, {
|
|
5326
|
+
query: {
|
|
5327
|
+
limit: 100,
|
|
5328
|
+
offset: 0
|
|
5329
|
+
}
|
|
5330
|
+
}),
|
|
5331
|
+
queryKey: ["employees", "list"]
|
|
5332
|
+
});
|
|
5333
|
+
const employees = (data == null ? void 0 : data.employees) || [];
|
|
5334
|
+
const companies = useMemo(() => {
|
|
5335
|
+
const uniqueCompanies = /* @__PURE__ */ new Map();
|
|
5336
|
+
employees.forEach((emp) => {
|
|
5337
|
+
if (emp.company) {
|
|
5338
|
+
uniqueCompanies.set(emp.company.id, emp.company);
|
|
5339
|
+
}
|
|
5340
|
+
});
|
|
5341
|
+
return Array.from(uniqueCompanies.values()).sort(
|
|
5342
|
+
(a2, b) => a2.name.localeCompare(b.name)
|
|
5343
|
+
);
|
|
5344
|
+
}, [employees]);
|
|
5345
|
+
const filteredEmployees = useMemo(() => {
|
|
5346
|
+
return employees.filter((employee) => {
|
|
5347
|
+
var _a, _b, _c;
|
|
5348
|
+
if (searchQuery) {
|
|
5349
|
+
const query = searchQuery.toLowerCase();
|
|
5350
|
+
const companyName = ((_b = (_a = employee.company) == null ? void 0 : _a.name) == null ? void 0 : _b.toLowerCase()) || "";
|
|
5351
|
+
if (!companyName.includes(query)) {
|
|
5352
|
+
return false;
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5355
|
+
if (companyFilter !== "all" && ((_c = employee.company) == null ? void 0 : _c.id) !== companyFilter) {
|
|
5356
|
+
return false;
|
|
5357
|
+
}
|
|
5358
|
+
if (roleFilter === "admin" && !employee.is_admin) {
|
|
5359
|
+
return false;
|
|
5360
|
+
}
|
|
5361
|
+
if (roleFilter === "buyer" && employee.is_admin) {
|
|
5362
|
+
return false;
|
|
5363
|
+
}
|
|
5364
|
+
return true;
|
|
5365
|
+
});
|
|
5366
|
+
}, [employees, searchQuery, companyFilter, roleFilter]);
|
|
5367
|
+
const formatCurrency = (amount) => {
|
|
5368
|
+
if (amount === 0) return "Unlimited";
|
|
5369
|
+
return new Intl.NumberFormat("fr-FR", {
|
|
5370
|
+
style: "currency",
|
|
5371
|
+
currency: "EUR"
|
|
5372
|
+
}).format(amount / 100);
|
|
5373
|
+
};
|
|
5374
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
5375
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
5376
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Employees" }),
|
|
5377
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Manage B2B company employees and their permissions." })
|
|
5378
|
+
] }) }),
|
|
5379
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 px-6 py-4", children: [
|
|
5380
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex-1 max-w-sm", children: [
|
|
5381
|
+
/* @__PURE__ */ jsx(MagnifyingGlass, { className: "absolute left-3 top-1/2 -translate-y-1/2 text-ui-fg-muted" }),
|
|
5382
|
+
/* @__PURE__ */ jsx(
|
|
5383
|
+
Input,
|
|
5384
|
+
{
|
|
5385
|
+
placeholder: "Search by company name...",
|
|
5386
|
+
value: searchQuery,
|
|
5387
|
+
onChange: (e2) => setSearchQuery(e2.target.value),
|
|
5388
|
+
className: "pl-10"
|
|
5389
|
+
}
|
|
5390
|
+
)
|
|
5391
|
+
] }),
|
|
5392
|
+
/* @__PURE__ */ jsxs(Select, { value: companyFilter, onValueChange: setCompanyFilter, children: [
|
|
5393
|
+
/* @__PURE__ */ jsx(Select.Trigger, { className: "w-[200px]", children: /* @__PURE__ */ jsx(Select.Value, { placeholder: "All companies" }) }),
|
|
5394
|
+
/* @__PURE__ */ jsxs(Select.Content, { children: [
|
|
5395
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "all", children: "All companies" }),
|
|
5396
|
+
companies.map((company) => /* @__PURE__ */ jsx(Select.Item, { value: company.id, children: company.name }, company.id))
|
|
5397
|
+
] })
|
|
5398
|
+
] }),
|
|
5399
|
+
/* @__PURE__ */ jsxs(Select, { value: roleFilter, onValueChange: setRoleFilter, children: [
|
|
5400
|
+
/* @__PURE__ */ jsx(Select.Trigger, { className: "w-[150px]", children: /* @__PURE__ */ jsx(Select.Value, { placeholder: "All roles" }) }),
|
|
5401
|
+
/* @__PURE__ */ jsxs(Select.Content, { children: [
|
|
5402
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "all", children: "All roles" }),
|
|
5403
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "admin", children: "Admin" }),
|
|
5404
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "buyer", children: "Buyer" })
|
|
5405
|
+
] })
|
|
5406
|
+
] }),
|
|
5407
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-muted text-sm", children: [
|
|
5408
|
+
filteredEmployees.length,
|
|
5409
|
+
" employee",
|
|
5410
|
+
filteredEmployees.length !== 1 ? "s" : ""
|
|
5411
|
+
] })
|
|
5412
|
+
] }),
|
|
5413
|
+
/* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ jsx(Spinner, { className: "animate-spin" }) }) : isError ? /* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-error py-8 text-center", children: [
|
|
5414
|
+
"Error: ",
|
|
5415
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
5416
|
+
] }) : filteredEmployees.length === 0 ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle py-8 text-center", children: employees.length === 0 ? "No employees yet." : "No employees match your filters." }) : /* @__PURE__ */ jsxs(Table, { children: [
|
|
5417
|
+
/* @__PURE__ */ jsx(Table.Header, { children: /* @__PURE__ */ jsxs(Table.Row, { children: [
|
|
5418
|
+
/* @__PURE__ */ jsx(Table.HeaderCell, { children: "ID" }),
|
|
5419
|
+
/* @__PURE__ */ jsx(Table.HeaderCell, { children: "Company" }),
|
|
5420
|
+
/* @__PURE__ */ jsx(Table.HeaderCell, { children: "Location" }),
|
|
5421
|
+
/* @__PURE__ */ jsx(Table.HeaderCell, { children: "Role" }),
|
|
5422
|
+
/* @__PURE__ */ jsx(Table.HeaderCell, { children: "Spending Limit" }),
|
|
5423
|
+
/* @__PURE__ */ jsx(Table.HeaderCell, { children: "Created" })
|
|
5424
|
+
] }) }),
|
|
5425
|
+
/* @__PURE__ */ jsx(Table.Body, { children: filteredEmployees.map((employee) => {
|
|
5426
|
+
var _a, _b, _c, _d, _e;
|
|
5427
|
+
return /* @__PURE__ */ jsxs(Table.Row, { children: [
|
|
5428
|
+
/* @__PURE__ */ jsx(Table.Cell, { className: "font-mono text-sm", children: employee.id.slice(-8) }),
|
|
5429
|
+
/* @__PURE__ */ jsx(Table.Cell, { className: "font-medium", children: ((_a = employee.company) == null ? void 0 : _a.name) || "-" }),
|
|
5430
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: ((_b = employee.company) == null ? void 0 : _b.city) && ((_c = employee.company) == null ? void 0 : _c.country) ? `${employee.company.city}, ${employee.company.country}` : ((_d = employee.company) == null ? void 0 : _d.city) || ((_e = employee.company) == null ? void 0 : _e.country) || "-" }),
|
|
5431
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Badge, { color: employee.is_admin ? "purple" : "grey", children: employee.is_admin ? "Admin" : "Buyer" }) }),
|
|
5432
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: formatCurrency(employee.spending_limit) }),
|
|
5433
|
+
/* @__PURE__ */ jsx(Table.Cell, { children: new Date(employee.created_at).toLocaleDateString() })
|
|
5434
|
+
] }, employee.id);
|
|
5435
|
+
}) })
|
|
5436
|
+
] }) })
|
|
5437
|
+
] });
|
|
5438
|
+
};
|
|
5439
|
+
const config = defineRouteConfig({
|
|
5440
|
+
label: "Employees",
|
|
5441
|
+
icon: Users
|
|
5442
|
+
});
|
|
5320
5443
|
const widgetModule = { widgets: [] };
|
|
5321
5444
|
const routeModule = {
|
|
5322
5445
|
routes: [
|
|
5323
5446
|
{
|
|
5324
5447
|
Component: CompaniesPage,
|
|
5325
5448
|
path: "/companies"
|
|
5449
|
+
},
|
|
5450
|
+
{
|
|
5451
|
+
Component: EmployeesPage,
|
|
5452
|
+
path: "/employees"
|
|
5326
5453
|
}
|
|
5327
5454
|
]
|
|
5328
5455
|
};
|
|
5329
5456
|
const menuItemModule = {
|
|
5330
5457
|
menuItems: [
|
|
5331
5458
|
{
|
|
5332
|
-
label: config.label,
|
|
5333
|
-
icon: config.icon,
|
|
5459
|
+
label: config$1.label,
|
|
5460
|
+
icon: config$1.icon,
|
|
5334
5461
|
path: "/companies",
|
|
5335
5462
|
nested: void 0,
|
|
5336
5463
|
rank: 4,
|
|
5337
5464
|
translationNs: void 0
|
|
5465
|
+
},
|
|
5466
|
+
{
|
|
5467
|
+
label: config.label,
|
|
5468
|
+
icon: config.icon,
|
|
5469
|
+
path: "/employees",
|
|
5470
|
+
nested: void 0,
|
|
5471
|
+
rank: void 0,
|
|
5472
|
+
translationNs: void 0
|
|
5338
5473
|
}
|
|
5339
5474
|
]
|
|
5340
5475
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.employeesMiddlewares = void 0;
|
|
4
|
+
const http_1 = require("@medusajs/framework/http");
|
|
5
|
+
exports.employeesMiddlewares = [
|
|
6
|
+
{
|
|
7
|
+
matcher: "/admin/employees",
|
|
8
|
+
middlewares: [(0, http_1.authenticate)("user", ["bearer", "session", "api-key"])],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
matcher: "/admin/employees/:id",
|
|
12
|
+
middlewares: [(0, http_1.authenticate)("user", ["bearer", "session", "api-key"])],
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlkZGxld2FyZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvYXBpL2FkbWluL2VtcGxveWVlcy9taWRkbGV3YXJlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxtREFBd0U7QUFFM0QsUUFBQSxvQkFBb0IsR0FBc0I7SUFDckQ7UUFDRSxPQUFPLEVBQUUsa0JBQWtCO1FBQzNCLFdBQVcsRUFBRSxDQUFDLElBQUEsbUJBQVksRUFBQyxNQUFNLEVBQUUsQ0FBQyxRQUFRLEVBQUUsU0FBUyxFQUFFLFNBQVMsQ0FBQyxDQUFDLENBQUM7S0FDdEU7SUFDRDtRQUNFLE9BQU8sRUFBRSxzQkFBc0I7UUFDL0IsV0FBVyxFQUFFLENBQUMsSUFBQSxtQkFBWSxFQUFDLE1BQU0sRUFBRSxDQUFDLFFBQVEsRUFBRSxTQUFTLEVBQUUsU0FBUyxDQUFDLENBQUMsQ0FBQztLQUN0RTtDQUNGLENBQUEifQ==
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET = GET;
|
|
4
|
+
async function GET(req, res) {
|
|
5
|
+
const query = req.scope.resolve("query");
|
|
6
|
+
const queryConfig = {
|
|
7
|
+
...req.queryConfig,
|
|
8
|
+
fields: req.queryConfig?.fields || ["id", "spending_limit", "is_admin", "created_at", "updated_at", "company.*"],
|
|
9
|
+
};
|
|
10
|
+
const { data: employees, metadata } = await query.graph({
|
|
11
|
+
entity: "employee",
|
|
12
|
+
...queryConfig,
|
|
13
|
+
});
|
|
14
|
+
return res.json({
|
|
15
|
+
employees,
|
|
16
|
+
count: metadata?.count ?? employees.length,
|
|
17
|
+
limit: req.queryConfig?.pagination?.take ?? 50,
|
|
18
|
+
offset: req.queryConfig?.pagination?.skip ?? 0,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvYXBpL2FkbWluL2VtcGxveWVlcy9yb3V0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBLGtCQW1CQztBQW5CTSxLQUFLLFVBQVUsR0FBRyxDQUFDLEdBQWtCLEVBQUUsR0FBbUI7SUFDL0QsTUFBTSxLQUFLLEdBQUcsR0FBRyxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUE7SUFFeEMsTUFBTSxXQUFXLEdBQUc7UUFDbEIsR0FBRyxHQUFHLENBQUMsV0FBVztRQUNsQixNQUFNLEVBQUUsR0FBRyxDQUFDLFdBQVcsRUFBRSxNQUFNLElBQUksQ0FBQyxJQUFJLEVBQUUsZ0JBQWdCLEVBQUUsVUFBVSxFQUFFLFlBQVksRUFBRSxZQUFZLEVBQUUsV0FBVyxDQUFDO0tBQ2pILENBQUE7SUFFRCxNQUFNLEVBQUUsSUFBSSxFQUFFLFNBQVMsRUFBRSxRQUFRLEVBQUUsR0FBRyxNQUFNLEtBQUssQ0FBQyxLQUFLLENBQUM7UUFDdEQsTUFBTSxFQUFFLFVBQVU7UUFDbEIsR0FBRyxXQUFXO0tBQ2YsQ0FBQyxDQUFBO0lBRUYsT0FBTyxHQUFHLENBQUMsSUFBSSxDQUFDO1FBQ2QsU0FBUztRQUNULEtBQUssRUFBRSxRQUFRLEVBQUUsS0FBSyxJQUFJLFNBQVMsQ0FBQyxNQUFNO1FBQzFDLEtBQUssRUFBRSxHQUFHLENBQUMsV0FBVyxFQUFFLFVBQVUsRUFBRSxJQUFJLElBQUksRUFBRTtRQUM5QyxNQUFNLEVBQUUsR0FBRyxDQUFDLFdBQVcsRUFBRSxVQUFVLEVBQUUsSUFBSSxJQUFJLENBQUM7S0FDL0MsQ0FBQyxDQUFBO0FBQ0osQ0FBQyJ9
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const http_1 = require("@medusajs/framework/http");
|
|
4
4
|
const middlewares_1 = require("./admin/companies/middlewares");
|
|
5
|
+
const middlewares_2 = require("./admin/employees/middlewares");
|
|
5
6
|
exports.default = (0, http_1.defineMiddlewares)({
|
|
6
|
-
routes: [...middlewares_1.companiesMiddlewares],
|
|
7
|
+
routes: [...middlewares_1.companiesMiddlewares, ...middlewares_2.employeesMiddlewares],
|
|
7
8
|
});
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlkZGxld2FyZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBpL21pZGRsZXdhcmVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsbURBQTREO0FBQzVELCtEQUFvRTtBQUNwRSwrREFBb0U7QUFFcEUsa0JBQWUsSUFBQSx3QkFBaUIsRUFBQztJQUMvQixNQUFNLEVBQUUsQ0FBQyxHQUFHLGtDQUFvQixFQUFFLEdBQUcsa0NBQW9CLENBQUM7Q0FDM0QsQ0FBQyxDQUFBIn0=
|