import React, { useState } from "react";
import MkdSDK from "@/utils/MkdSDK";
import { Link, useNavigate, useParams } from "react-router-dom";
import { GlobalContext } from "@/globalContext";
import ViewAdminPageLayout from "@/layouts/ViewAdminPageLayout";
import History from "@/components/History";
import Icon from "@/components/Icons";
import EditAdminPropertyPage from "./EditAdminPropertyPage";
let sdk = new MkdSDK();
const ViewAdminPropertyPage = ({ page }) => {
const [profileInfo, setProfileInfo] = useState();
const { dispatch: globalDispatch } = React.useContext(GlobalContext);
const params = useParams();
const [activeTab, setActiveTab] = useState(0);
const tabs = [
{
key: 0,
name: "Profile Details",
component: page === "view" ? : ,
},
{
key: 1,
name: "History",
component: (
),
},
// {
// key: 2,
// name: "Spaces",
// component:
// },
// {
// key: 3,
// name: "Addons",
// component:
// }
];
React.useEffect(() => {
globalDispatch({
type: "SETPATH",
payload: {
path: "property",
},
});
(async function () {
const result = await sdk.callRawAPI(
"/v2/api/custom/ergo/property/PAGINATE",
{
where: [params?.id ? `${params?.id ? `ergo_property.id = '${params?.id}'` : "1"}` : 1],
page: 1,
limit: 1,
},
"POST",
);
if (!result.error) {
setProfileInfo(result.list[0]);
}
})();
}, []);
return (
{tabs.map((tab) => (
-
))}
{tabs[activeTab].component}
);
};
const ProfileDetails = ({ profileInfo }) => {
const navigate = useNavigate();
const params = useParams();
const selectVerified = [
{ key: "0", value: "No" },
{ key: "1", value: "Yes" },
];
const selectStatus = [
{
key: "0",
value: "Inactive",
},
{ key: "1", value: "Active" },
];
return (
<>
Profile Details
Host ID
{profileInfo?.host_id}
Host Email
{profileInfo?.email}
Address
{profileInfo?.address_line_1} {profileInfo?.address_line_2}
Zip Code
{profileInfo?.zip}
Country
{profileInfo?.country}
Verified
{selectVerified[profileInfo?.verified]?.value}
Num of Spaces
{profileInfo?.spaces}
Status
{selectStatus[profileInfo?.status]?.value}
View Addons
>
);
};
export default ViewAdminPropertyPage;