fix: created by in detail categories
This commit is contained in:
parent
a0cb4cc9bf
commit
a7c7275590
|
|
@ -26,6 +26,7 @@ type CategoryDetail = {
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
createdByFullname : string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type CurrentUser = {
|
type CurrentUser = {
|
||||||
|
|
@ -39,11 +40,11 @@ export default function CategoriesDetailForm() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [detail, setDetail] = useState<CategoryDetail | null>(null);
|
const [detail, setDetail] = useState<CategoryDetail | null>(null);
|
||||||
const [currentUser, setCurrentUser] = useState<CurrentUser | null>(null);
|
const [currentUser, setCurrentUser] = useState<CurrentUser | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getUserInfo().then((res) => setCurrentUser(res.data.data));
|
getUserInfo().then((res) => setCurrentUser(res.data.data));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function init() {
|
async function init() {
|
||||||
if (id) {
|
if (id) {
|
||||||
|
|
@ -123,14 +124,7 @@ export default function CategoriesDetailForm() {
|
||||||
{/* Creator */}
|
{/* Creator */}
|
||||||
<div>
|
<div>
|
||||||
<Label>Created By</Label>
|
<Label>Created By</Label>
|
||||||
<Input
|
<Input readOnly value={detail.createdByFullname || "-"} />
|
||||||
readOnly
|
|
||||||
value={
|
|
||||||
currentUser && currentUser.id === detail.createdById
|
|
||||||
? currentUser.fullname || currentUser.username
|
|
||||||
: `User ID ${detail.createdById}`
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* <Input
|
{/* <Input
|
||||||
type="text"
|
type="text"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue