diff --git a/gui/rpk-gui/src/components/Cartouche.tsx b/gui/rpk-gui/src/components/Cartouche.tsx
index 404b9a5..0d9e34e 100644
--- a/gui/rpk-gui/src/components/Cartouche.tsx
+++ b/gui/rpk-gui/src/components/Cartouche.tsx
@@ -1,4 +1,6 @@
import { useTranslation } from "@refinedev/core";
+import { useContext } from "react";
+import { FirmContext } from "../contexts/FirmContext";
type CartoucheProps = {
record: any
@@ -11,11 +13,22 @@ const Cartouche = (props: CartoucheProps) => {
<>
{record.label}
- { record.created_at && - {t("resource.created_at")}: {record.created_at} {t("resource.created_at")}: {record.created_by}
}
- { record.updated_at && - {t("resource.updated_at")}: {record.updated_at} {t("resource.updated_by")}: {record.updated_by}
}
+ { record.created_at && - {t("resource.created_at")}: {record.created_at} {t("resource.created_at")}:
}
+ { record.updated_at && - {t("resource.updated_at")}: {record.updated_at} {t("resource.updated_by")}:
}
>
)
}
export default Cartouche;
+
+const AuthorField = (props: {partnerId: string})=> {
+ const { partnerId } = props;
+ const { partnerMap } = useContext(FirmContext);
+ const { translate: t } = useTranslation();
+
+ if (partnerMap && partnerMap.has(partnerId)) {
+ return <>{ partnerMap.get(partnerId) }>
+ }
+ return <>{t("REDACTED")}>
+}
diff --git a/gui/rpk-gui/src/contexts/FirmContext.tsx b/gui/rpk-gui/src/contexts/FirmContext.tsx
index 536bd56..19b9fb2 100644
--- a/gui/rpk-gui/src/contexts/FirmContext.tsx
+++ b/gui/rpk-gui/src/contexts/FirmContext.tsx
@@ -1,9 +1,12 @@
import React, { createContext, PropsWithChildren } from 'react';
import { IFirm } from "../interfaces";
import { useParams } from "react-router";
+import { useOne } from "@refinedev/core";
+import { CircularProgress } from "@mui/material";
type FirmContextType = {
currentFirm: IFirm,
+ partnerMap?: Map
}
export const FirmContext = createContext(
@@ -12,13 +15,27 @@ export const FirmContext = createContext(
export const FirmContextProvider: React.FC = ({ children }: PropsWithChildren) => {
- const { instance, firm } = useParams()
+ const { instance, firm } = useParams();
+ const { data, isError, error, isLoading } = useOne({resource: 'firm', id: `${instance}/${firm}/`, errorNotification: false});
if (instance === undefined || firm === undefined) {
return "Error"
}
+
+ if (isLoading) {
+ return
+ }
+
+ let value: FirmContextType = {
+ currentFirm: {instance, firm}
+ }
+ if (!isError || error?.statusCode != 405) {
+ value.currentFirm.entity = data?.data.entity;
+ value.partnerMap = new Map(data?.data.partner_list.map((item: any) => [item.id, item.label]));
+ }
+
return (
-
+
{ children }
);
diff --git a/gui/rpk-gui/src/interfaces/index.tsx b/gui/rpk-gui/src/interfaces/index.tsx
index cf7eb48..4ab0342 100644
--- a/gui/rpk-gui/src/interfaces/index.tsx
+++ b/gui/rpk-gui/src/interfaces/index.tsx
@@ -2,6 +2,7 @@
export type IFirm = {
instance: string,
firm: string
+ entity?: any
}
type User = {
diff --git a/gui/rpk-gui/src/pages/firm/index.tsx b/gui/rpk-gui/src/pages/firm/index.tsx
index 951cffd..d39ede6 100644
--- a/gui/rpk-gui/src/pages/firm/index.tsx
+++ b/gui/rpk-gui/src/pages/firm/index.tsx
@@ -33,17 +33,8 @@ export const FirmRoutes = () => {
const FirmHome = () => {
const { currentFirm } = useContext(FirmContext);
- const { data: firm, isError, error, isLoading } = useOne({resource: 'firm', id: `${currentFirm.instance}/${currentFirm.firm}/`, errorNotification: false})
const { translate: t } = useTranslation();
- if (isLoading) {
- return Loading...
- }
-
- if (isError && error?.statusCode == 405) {
- return
- }
-
return (
<>
This is la firme {currentFirm.instance} / {currentFirm.firm}