"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getServerSideProps = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
// Route given by an account or organization name.
const owner_1 = __importDefault(require("lib/names/owner"));
const get_account_info_1 = __importDefault(require("lib/share/get-account-info"));
const account_1 = __importDefault(require("components/account/account"));
const with_customize_1 = __importDefault(require("lib/with-customize"));
function Owner(props) {
    if (props.type == "account") {
        return (0, jsx_runtime_1.jsx)(account_1.default, { ...props });
    }
    // TODO
    return ((0, jsx_runtime_1.jsxs)("div", { style: { margin: "30px" }, children: [(0, jsx_runtime_1.jsxs)("h1", { children: ["Organization: ", props.owner] }), "Organization pages are under construction and not yet available."] }));
}
exports.default = Owner;
async function getServerSideProps(context) {
    const { owner } = context.params;
    let info;
    try {
        info = await (0, owner_1.default)(owner);
    }
    catch (_err) {
        //console.log(_err);
        return { notFound: true };
    }
    if (info.type == "account") {
        const accountInfo = await (0, get_account_info_1.default)(info.owner_id, context.req);
        return await (0, with_customize_1.default)({ context, props: { ...info, ...accountInfo } });
    }
    return await (0, with_customize_1.default)({ context, props: { owner, ...info } });
}
exports.getServerSideProps = getServerSideProps;
//# sourceMappingURL=%5Bowner%5D.js.map