Skip to content

Commit

Permalink
fix: complete creator profile
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Feb 17, 2025
1 parent b226381 commit 5521cc8
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 16 deletions.
14 changes: 7 additions & 7 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

/** @type {import('next').NextConfig} */
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true'
})
enabled: process.env.ANALYZE === 'true',
});

module.exports = withBundleAnalyzer({
// env: {
Expand All @@ -28,7 +28,7 @@ module.exports = withBundleAnalyzer({
swcMinify: true,
staticPageGenerationTimeout: 180,
experimental: {
serverActions: true
serverActions: true,
},
env: {
NEXT_PUBLIC_DOMAIN_ENV: process.env.NEXT_PUBLIC_DOMAIN_ENV,
Expand All @@ -44,14 +44,14 @@ module.exports = withBundleAnalyzer({
'imgse.com',
's3.us-west-1.amazonaws.com',
'file-cdn.openbuild.xyz',
'api.runllm.com'
'api.runllm.com',
],
},
webpack: config => {
config.externals.push('pino-pretty', 'lokijs', 'encoding', 'bufferutil', 'utf-8-validate')
return config
config.externals.push('pino-pretty', 'lokijs', 'encoding', 'bufferutil', 'utf-8-validate');
return config;
},
compiler: {
styledComponents: true,
},
})
});
10 changes: 5 additions & 5 deletions src/domain/profile/views/team-profile/TeamProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ import TabBarWidget from '../../widgets/tab-bar';
import CustomContent from './CustomContent';
import LatestActivityList from './LatestActivityList';

const resolveTabs = published => {
function resolveTabs(published) {
return [
{
text: 'Open Course',
node: (
<>
<span className="inline md:hidden">Courses</span>
<span className="hidden md:inline">Open Course({published?.['open_course_num'] ?? 0})</span>
<span className="hidden md:inline">Open Course ({published?.open_course_num ?? 0})</span>
</>
),
view: PublishedCourseListView,
Expand All @@ -50,7 +50,7 @@ const resolveTabs = published => {
node: (
<>
<span className="inline md:hidden">Challenge</span>
<span className="hidden md:inline">Challenges({published?.['challenge_num'] ?? 0})</span>
<span className="hidden md:inline">Challenges ({published?.challenge_num ?? 0})</span>
</>
),
view: PublishedChallengeListView,
Expand All @@ -60,7 +60,7 @@ const resolveTabs = published => {
node: (
<>
<span className="inline md:hidden">Bounty</span>
<span className="hidden md:inline">Bounty({published?.['bounty_num'] ?? 0})</span>
<span className="hidden md:inline">Bounty ({published?.bounty_num ?? 0})</span>
</>
),
view: PublishedBountyListView,
Expand All @@ -70,7 +70,7 @@ const resolveTabs = published => {
node: (
<>
<span className="inline md:hidden">Quiz</span>
<span className="hidden md:inline">Quiz({published?.['quiz_num'] ?? 0})</span>
<span className="hidden md:inline">Quiz ({published?.quiz_num ?? 0})</span>
</>
),
view: PublishedQuizListView,
Expand Down
45 changes: 45 additions & 0 deletions src/domain/profile/widgets/profile-card/IdentityInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright 2024 OpenBuild
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { usePathname } from 'next/navigation';

function IdentityInfo({ className, userName }) {
const pathname = usePathname();

const identityLinks = [
{ text: 'User', url: `/u/${userName}` },
{ text: 'Creator', url: `/u/${userName}/creator` },
].filter(({ url }) => url !== pathname);

return (
<div className={className}>
<p className="mt-6 uppercase text-xs opacity-60 font-bold">Identity Profiles</p>
<div className="border border-gray-600 rounded overflow-hidden mt-2">
{identityLinks.map(link => (
<a key={link.url} className="h-9 flex justify-between items-center px-4 border-b border-gray-600 last:border-0 hover:bg-gray-1000" href={link.url}>
<div className="flex justify-between items-center" style={{ flexGrow: 1, paddingRight: '8px' }}>
<div className="flex items-center">
<p className="pl-2 pr-1 text-sm font-semibold">{link.text}</p>
</div>
</div>
</a>
))}
</div>
</div>
);
}

export default IdentityInfo;
7 changes: 5 additions & 2 deletions src/domain/profile/widgets/profile-card/ProfileCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { post, fetcher } from '@/utils/request';
import { useUser } from '#/state/application/hooks';

import SocialInfoWidget from '../social-info';
import IdentityInfo from './IdentityInfo';

function ProfileCardWidget({ data }) {
const router = useRouter();
Expand All @@ -41,6 +42,7 @@ function ProfileCardWidget({ data }) {

const uid = data?.base.user_id;
const handle = data?.base.user_handle;
const creatorAvailable = data.base?.user_project_owner;

const follow = async () => {
if (status !== 'authenticated') {
Expand Down Expand Up @@ -85,7 +87,7 @@ function ProfileCardWidget({ data }) {
<h6 className="text-[24px] leading-none">
<a href={`/u/${handle}`}>{data?.base.user_nick_name}</a>
</h6>
{!data.base?.user_project_owner && <div className="flex items-center text-sm">
{!creatorAvailable && <div className="flex items-center text-sm">
<RepositioningIcon className="mr-1" />
<p className="text-sm opacity-60">
{data.base?.user_city}, {data.base?.user_country}
Expand Down Expand Up @@ -113,7 +115,7 @@ function ProfileCardWidget({ data }) {
<span className="!font-bold">Follow</span>
</Button>
)}
{/* {!data.base?.user_project_owner && <>
{/* {!creatorAvailable && <>
<p className="mt-6 uppercase text-xs opacity-60 font-bold">Community</p>
<div className="flex border border-gray-600 rounded gap-2 p-4 items-center">
<Image width={36} height={36} className="rounded-full object-fill" src={'https://s3.us-west-1.amazonaws.com/file.openbuild.xyz/config/avatar/04.svg'} alt="avatar" />
Expand All @@ -124,6 +126,7 @@ function ProfileCardWidget({ data }) {
<Link href="/" className="text-xs opacity-60">+ Follow</Link>
</div>
</>} */}
{creatorAvailable && <IdentityInfo userName={handle} />}
<SocialInfoWidget className="hidden md:block" data={data} />
</div>
);
Expand Down
14 changes: 12 additions & 2 deletions src/entry/components/RouteIntercept/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,25 @@ import { useSession } from 'next-auth/react';
import { usePathname, useRouter } from 'next/navigation';
import { useEffect } from 'react';

import { isFunction } from '@/utils';

const signedInRequired = [
'profile',
'dashboard',
pathname => pathname.includes('creator') && !pathname.startsWith('/u'),
'shilling-myself',
];

export function RouteIntercept() {
const { status } = useSession();
const pathname = usePathname();
const router = useRouter();

useEffect(() => {
if (
status === 'unauthenticated' &&
(pathname.includes('profile') || pathname.includes('dashboard') || pathname.includes('creator') || pathname.includes('shilling-myself'))
status === 'unauthenticated' &&
// FIXME: use a more precise way to judge instead of `includes`
signedInRequired.some(checker => isFunction(checker) ? checker(pathname) : pathname.includes(checker))
) {
router.push(`/signin?from=${pathname}`);
}
Expand Down

0 comments on commit 5521cc8

Please sign in to comment.