"use strict";
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getServerSideProps = void 0;
/*
Page for a given user.
*/
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
const path_1 = require("path");
const base_path_1 = __importDefault(require("lib/base-path"));
const get_account_info_1 = __importDefault(require("lib/share/get-account-info"));
const with_customize_1 = __importDefault(require("lib/with-customize"));
const account_1 = __importDefault(require("components/account/account"));
exports.default = account_1.default;
async function getServerSideProps(context) {
    const { account_id } = context.params;
    try {
        const accountInfo = await (0, get_account_info_1.default)(account_id, context.req);
        if (accountInfo.name) {
            // This account has a nice username. Redirect to that instead
            // of rendering here.
            return { props: { redirect: (0, path_1.join)(base_path_1.default, accountInfo.name) } };
        }
        return await (0, with_customize_1.default)({
            context,
            props: accountInfo,
        });
    }
    catch (_err) {
        // console.log(err);
        return { notFound: true };
    }
}
exports.getServerSideProps = getServerSideProps;
//# sourceMappingURL=%5Baccount_id%5D.js.map