Improving user management and auto-refreshing user firms

This commit is contained in:
2025-04-10 01:31:37 +02:00
parent bc059de65b
commit f1fe81a146
13 changed files with 131 additions and 67 deletions

View File

@@ -1,7 +1,19 @@
import { useInvalidateAuthStore } from "@refinedev/core";
import { CrudForm } from "../../lib/crud/components/crud-form";
import {empty_user} from "../../providers/auth-provider";
export const CreateFirm = () => {
const invalidateAuthStore = useInvalidateAuthStore()
const refreshUser = () => {
empty_user();
invalidateAuthStore().then();
}
return (
<CrudForm schemaName={"FirmCreate"} resource={"firms"} />
<CrudForm
schemaName={"FirmCreate"}
resource={"firms"}
onSuccess={() => { refreshUser() }}
/>
)
}

View File

@@ -1,12 +1,38 @@
import { Button } from "@mui/material";
import { Link } from "react-router";
import { useGetIdentity } from "@refinedev/core";
type Firm = {
name: string,
instance: string,
}
type User = {
firms: [Firm],
}
export const Hub = () => {
const user = useGetIdentity<User>();
console.log(user);
let ownFirms = [];
let workFirms = [];
//firms.forEach((f, index) => {
// workFirms.push(<li>{f.instance}/{f.name}</li>)
//})
//{firms.map((f: Firm, index) => (
// <li key={index}>{f.instance} / {f.name}</li>
// ))}
return (
<div>
<h1>HUB</h1>
<p>List of managed firms</p>
<p>List of firm you're working atx</p>
<ul>
<li></li>
</ul>
<p>List of firm you're working at</p>
<ul>
</ul>
<Link to="/hub/create-firm" ><Button >Create a new firm</Button></Link>
</div>
);