Skip to content

Commit

Permalink
chore: after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
r1skz3ro committed Jul 12, 2024
2 parents aab7fbf + baff627 commit fe0733e
Show file tree
Hide file tree
Showing 94 changed files with 723 additions and 299 deletions.
44 changes: 38 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ goal-oriented work environment with a cutting-edge platform.
- Usage
- Wiki
- Contributing
- Development
- Frontend
- Backend
- License
- Contact

Expand Down Expand Up @@ -51,12 +54,6 @@ Instructions on how to use the project.

For more information, check out the project's wiki under the link: https://github.com/Tivix/cpf/wiki

# swagger/redoc

Swagger and redoc can be accessed using following urls:
- http://0.0.0.0:8000/docs
- http://0.0.0.0:8000/redoc

# Contributing

Guidelines for contributing to the project.
Expand All @@ -68,6 +65,41 @@ Guidelines for contributing to the project.
- Push to the branch.
- Open a pull request.

# Development

## Frontend

### Folder structure

- `api` - Contains api calls.
- `app`- The App Router by Next.js.
- `components` - Contains all components used in the app.
- `common` - In the common folder, we keep all essential components like Button, Card, or Input.
- `modules` - Here we keep more complex components that are still reusable or are part of layouts.
- `pages` - Here we compose view together to create a page. If you want to extract some module of the page, create `modules` folder there and put it in it.
- `constants` - Contains all the constant values used in the app.
- `static`- Contains assets like icons.
- `store` - Contains all stores for state management.
- `types` - Contains all reusable types and interfaces that are shared between many pages and modules.
- `utils` - Contains all utility functions like data transformations or calculations.

### Component structure

Component folder should contain:

- `index.ts` - importing and exporting the component.
- `ComponentName.tsx` - view part of a component.
- `ComponentName.interface.ts` - types related to that component.
- `ComponentName.hooks.tsx` - the logic of our component

## Backend

### swagger/redoc

Swagger and redoc can be accessed using following urls:
- http://0.0.0.0:8000/docs
- http://0.0.0.0:8000/redoc

# License

Specify the license under which the project is distributed.
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/ladder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mapKeysToCamelCase } from '@app/utils';
import { API_URLS } from '.';
import { LadderCardInterface } from '@app/components/common/LadderCard';
import { LadderCardInterface } from '@app/components/pages/Library/modules/LadderCard';
import { LadderBand } from '@app/types/library';

async function getLadders() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { PersonalDetails } from '@app/components/views/PersonalDetails/PersonalDetails';
import { PersonalDetails } from '@app/components/pages/PersonalDetails/PersonalDetails';

export default PersonalDetails;
6 changes: 2 additions & 4 deletions frontend/src/app/(app)/(root)/documentation/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Typography } from '@app/components/common/Typography';
import { PageTitle } from '@app/components/common/PageTitle';

export default function Documentation() {
return (
<div>
<Typography className="mb-10" variant="body-l/semibold" as="h1">
Documentation
</Typography>
<PageTitle title="Documentation" />
</div>
);
}
17 changes: 2 additions & 15 deletions frontend/src/app/(app)/(root)/library/[ladder]/[bucket]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
import { Breadcrumbs } from '@app/components/modules/Breadcrumbs';
import { BucketDetails } from '@app/components/modules/BucketDetails';
import { BucketDetails } from '@app/components/pages/BucketDetails';
import { getLadderName } from '@app/api/ladder';
import { getBucketDetails } from '@app/api/bucket';
import { routes } from '@app/constants';

export default async function BucketDetailed({ params }: { params: { bucket: string; ladder: string } }) {
const { bucket, ladder } = params;
const data = await getBucketDetails(bucket);
const ladderName = await getLadderName(ladder);

return (
<div>
<Breadcrumbs
breadcrumbs={[
{ label: 'CPF Library', href: routes.library.index, current: false },
{ label: ladderName, href: `${routes.library.index}/${ladder}`, current: false },
{ label: data.bucketName, href: `${routes.library.index}/${ladder}/${bucket}`, current: true },
]}
/>
{data && <BucketDetails data={data} />}
</div>
);
return <BucketDetails data={data} ladderName={ladderName} ladderSlug={ladder} bucketSlug={bucket} />;
}

export const dynamic = 'force-dynamic';
16 changes: 2 additions & 14 deletions frontend/src/app/(app)/(root)/library/[ladder]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { Breadcrumbs } from '@app/components/modules/Breadcrumbs';
import { LibraryDetailed } from '@app/components/modules/LibraryDetailed';
import { getLadderDetails } from '@app/api/ladder';
import { routes } from '@app/constants';
import { LadderDetails } from '@app/components/pages/LadderDetails';

export default async function LadderDetailed({ params }: { params: { ladder: string } }) {
const data = await getLadderDetails(params.ladder);

return (
<div>
<Breadcrumbs
breadcrumbs={[
{ label: 'CPF Library', href: routes.library.index, current: false },
{ label: data.ladderName, href: `${routes.library.index}/${params.ladder}`, current: true },
]}
/>
{data && <LibraryDetailed ladderSlug={params.ladder} data={data} />}
</div>
);
return <LadderDetails ladderSlug={params.ladder} data={data} />;
}

export const dynamic = 'force-dynamic';
19 changes: 2 additions & 17 deletions frontend/src/app/(app)/(root)/library/page.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
import { LadderCard } from '@app/components/common/LadderCard';
import { getLadders } from '@app/api/ladder';
import { Typography } from '@app/components/common/Typography';
import { Library } from '@app/components/pages/Library';

export default async function LibraryPage() {
const data = await getLadders();

return (
<div>
<Typography className="mb-10" variant="body-l/semibold" as="h1">
CPF Library
</Typography>
<Typography className="mb-6 text-navy-600" variant="body-m/regular">
Select a career path to view the details.
</Typography>
<div className="grid grid-cols-3 gap-6">
{data.map((ladder) => (
<LadderCard key={ladder.ladderSlug} {...ladder} />
))}
</div>
</div>
);
return <Library data={data} />;
}

export const dynamic = 'force-dynamic';
31 changes: 22 additions & 9 deletions frontend/src/app/(app)/(root)/my-space/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { Typography } from '@app/components/common/Typography';
import { MySpace } from '@app/components/pages/MySpace';

export default function MySpace() {
return (
<div>
<Typography className="mb-10" variant="body-l/semibold" as="h1">
My Space
</Typography>
</div>
);
// TODO: get data from api
const data = {
user: {
firstName: 'Jane',
lastName: 'Edge',
position: 'Front End Developer, Junior',
},
currentLevel: {
band: 2,
score: 10,
},
nextLevel: {
band: 3,
threshold: 11,
},
};

export default function MySpacePage() {
return <MySpace data={data} />;
}

export const dynamic = 'force-dynamic';
16 changes: 2 additions & 14 deletions frontend/src/app/(app)/(root)/people/my-profile/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Breadcrumbs } from '@app/components/modules/Breadcrumbs';
import { ProfileSettings } from '@app/components/modules/ProfileSetting';
import { routes } from '@app/constants';
import { ProfileSettings } from '@app/components/pages/ProfileSetting';

// TODO: get data from api
const data = {
Expand All @@ -21,15 +19,5 @@ const data = {
};

export default async function LibraryPage() {
return (
<div>
<Breadcrumbs
breadcrumbs={[
{ label: 'People', href: routes.people.index, current: false },
{ label: 'Profile settings', href: routes.people.myProfile, current: true },
]}
/>
<ProfileSettings data={data} />
</div>
);
return <ProfileSettings data={data} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const AccordionCard = ({
className={generateClassNames(
'group flex w-full items-center justify-between rounded-2xl border border-navy-200 p-6',
{
'hover:bg-transparent rounded-b-none border-b-0 pb-0': isOpen,
'rounded-b-none border-b-0 pb-0 hover:bg-transparent': isOpen,
'cursor-auto': !children,
},
)}
Expand Down
27 changes: 14 additions & 13 deletions frontend/src/components/common/AccordionList/AccordionListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ export const AccordionListItem = ({

return (
<div className="border-b border-b-navy-200 px-2 py-4">
<Tooltip tooltipText={noContentTooltipText}>
<button
className={generateClassNames('flex w-full items-center justify-between border', {
'cursor-pointer': children,
})}
onClick={handleClick}
disabled={disableExpand}
>
<Typography variant="body-m/medium" className="text-left text-navy-600">
{title}
</Typography>
<button
className={generateClassNames('flex w-full items-center justify-between', {
'cursor-pointer': children,
})}
onClick={handleClick}
disabled={disableExpand}
>
<Typography variant="body-m/medium" className="text-left text-navy-600">
{title}
</Typography>
<Tooltip tooltipText={noContentTooltipText}>
<div
className={`flex min-h-10 min-w-10 items-center justify-center ${disableExpand ? 'text-navy-300' : 'text-navy-500'}`}
>
<ChevronRightIcon className={generateClassNames('rotate-90', { '-rotate-90': isOpen })} />
</div>
</button>
</Tooltip>
</Tooltip>
</button>

{children ? (
<div className={`font-normal text-navy-600 duration-300 ${isOpen ? 'mt-4 h-auto text-sm' : 'h-0 text-[0px]'}`}>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface PageTitleProps {
title: string;
}
10 changes: 10 additions & 0 deletions frontend/src/components/common/PageTitle/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Typography } from '@app/components/common/Typography';
import { PageTitleProps } from './PageTitle.interface';

export const PageTitle: React.FC<PageTitleProps> = ({ title }) => {
return (
<Typography className="mb-10" variant="body-l/semibold" as="h1">
{title}
</Typography>
);
};
1 change: 1 addition & 0 deletions frontend/src/components/common/PageTitle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PageTitle } from './PageTitle';
9 changes: 9 additions & 0 deletions frontend/src/components/common/Tabs/Tabs.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface TabsProps {
tabs: {
key: string;
label: string;
href: string;
}[];
currentTab: string;
onTabChange: (tab: string) => void;
}
47 changes: 47 additions & 0 deletions frontend/src/components/common/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { FC } from 'react';
import { TabsProps } from './Tabs.interface';
import { generateClassNames } from '@app/utils';

export const Tabs: FC<TabsProps> = ({ tabs, currentTab, onTabChange }) => {
return (
<div>
<div className="sm:hidden">
<label htmlFor="tabs" className="sr-only">
Select a tab
</label>
<select
id="tabs"
name="tabs"
onChange={(e) => onTabChange(e.target.value)}
defaultValue={tabs.find((tab) => tab.key === currentTab)?.label}
className="block w-full rounded-md border-navy-300 py-2 pl-3 pr-10 text-base focus:border-blue-500 focus:outline-none focus:ring-blue-500 sm:text-sm"
>
{tabs.map((tab) => (
<option key={tab.key}>{tab.label}</option>
))}
</select>
</div>
<div className="hidden sm:block">
<div className="border-b border-navy-200">
<nav aria-label="Tabs" className="flex justify-center space-x-8">
{tabs.map((tab) => (
<a
key={tab.key}
href={tab.href}
aria-current={tab.key === currentTab ? 'page' : undefined}
className={generateClassNames(
tab.key === currentTab
? 'border-blue-800 text-blue-800'
: 'border-transparent text-navy-500 hover:border-navy-300 hover:text-navy-700',
'whitespace-nowrap border-b-2 px-1 py-4 text-sm font-medium',
)}
>
{tab.label}
</a>
))}
</nav>
</div>
</div>
</div>
);
};
1 change: 1 addition & 0 deletions frontend/src/components/common/Tabs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Tabs } from './Tabs';
2 changes: 1 addition & 1 deletion frontend/src/components/common/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const TooltipPopover: FC<PropsWithChildren<TooltipProps>> = ({ tooltipTex
const [open, setOpen] = useState(false);

return (
<Popover className="relative flex flex-1">
<Popover className="relative">
<PopoverButton
onMouseEnter={() => setOpen(true)}
onMouseLeave={() => setOpen(false)}
Expand Down
Loading

0 comments on commit fe0733e

Please sign in to comment.