-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new career feature implementation (#682)
- Loading branch information
Showing
41 changed files
with
457 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
a { | ||
color: $purpleColor; | ||
cursor: pointer; | ||
text-decoration: none; | ||
|
||
&:hover { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
$footerHeight: 2vh; | ||
$headerHeight: 5vh; | ||
$padding-lg: 5em; | ||
$padding-md: 2.5em; | ||
$padding-lg: 10em; | ||
$padding-md: 5em; | ||
$padding-sm: 1em; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import httpClient from 'src/client/app/http-client'; | ||
import type { IBlog, IBlogDTO } from 'src/common/types/common-blog-types'; | ||
import type { BlogDTO, BlogModel } from 'src/common/types/common-blog-types'; | ||
|
||
export const blogListRequest = async (): Promise<IBlog[]> => { | ||
const blogListDTO = await httpClient.get('blog').json<IBlogDTO[]>(); | ||
return blogListDTO.map((item) => ({ | ||
...item, | ||
date: new Date(item.date), | ||
})); | ||
const blogItemAdapter = (dto: BlogDTO): BlogModel => ({ | ||
...dto, | ||
date: new Date(dto.date), | ||
}); | ||
|
||
export const blogListRequest = async (): Promise<BlogModel[]> => { | ||
const dto = await httpClient.get('blog').json<BlogDTO[]>(); | ||
return dto.map(blogItemAdapter); | ||
}; | ||
|
||
export const blogRequest = async (id: string): Promise<IBlog> => { | ||
const blogDTO = await httpClient.get(`blog/${id}`).json<IBlogDTO>(); | ||
return { | ||
...blogDTO, | ||
date: new Date(blogDTO.date), | ||
}; | ||
export const blogItemRequest = async (id: string): Promise<BlogModel> => { | ||
const dto = await httpClient.get(`blog/${id}`).json<BlogDTO>(); | ||
return blogItemAdapter(dto); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { IBlog } from 'src/common/types/common-blog-types'; | ||
import { BlogModel } from 'src/common/types/common-blog-types'; | ||
|
||
export interface BlogListItemProps { | ||
item: IBlog; | ||
item: BlogModel; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { JSX } from 'react'; | ||
|
||
import CareerListItem from './CareerListItem'; | ||
import { useCareerListQuery } from './hooks/use-career-list-query'; | ||
|
||
const CareerList = (): JSX.Element => { | ||
const { data: careerList = [], error, isFetching } = useCareerListQuery(); | ||
return ( | ||
<div className='ag-flexbox ag-flexColumn'> | ||
{error && <div>Failed to load</div>} | ||
{isFetching ? <div>Loading...</div> : careerList.map((item) => <CareerListItem key={item._id} item={item} />)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default CareerList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import 'src/assets/variables'; | ||
|
||
.container { | ||
padding: $padding-sm 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { JSX } from 'react'; | ||
|
||
import { Button } from '@mui/base'; | ||
import Link from 'next/link'; | ||
import { CAREER_PAGE_URL } from 'src/common/common-constants'; | ||
import { dayjs } from 'src/common/common-date'; | ||
|
||
import { CareerListItemProps } from './career-types'; | ||
import styles from './CareerListItem.module.scss'; | ||
|
||
const CareerListItem = ({ item }: CareerListItemProps): JSX.Element => { | ||
const { _id: itemId, endDate, description, post, site, startDate, title, tools } = item; | ||
return ( | ||
<div className={`ag-flexbox ag-justifyContent-between ${styles.container}`} key={itemId}> | ||
<div>{title}</div> | ||
<div> | ||
<span>{dayjs(startDate).utc().format('MMMM DD, YYYY')}</span> | ||
{endDate ? <span> - {dayjs(endDate).utc().format('MMMM DD, YYYY')}</span> : null} | ||
</div> | ||
<div>{post}</div> | ||
<div>{site}</div> | ||
<div>{description}</div> | ||
<div>{tools}</div> | ||
<Link href={`${CAREER_PAGE_URL}/${itemId}`}> | ||
<Button>Open</Button> | ||
</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CareerListItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import httpClient from 'src/client/app/http-client'; | ||
import { CareerDTO, CareerModel } from 'src/common/types/common-career-types'; | ||
|
||
const careerItemAdapter = (dto: CareerDTO): CareerModel => ({ | ||
...dto, | ||
endDate: dto.endDate && new Date(dto.endDate), | ||
startDate: new Date(dto.startDate), | ||
}); | ||
|
||
export const careerListRequest = async (): Promise<CareerModel[]> => { | ||
const dto = await httpClient.get('career').json<CareerDTO[]>(); | ||
return dto.map(careerItemAdapter); | ||
}; | ||
|
||
export const careerItemRequest = async (id: string): Promise<CareerModel> => { | ||
const dto = await httpClient.get(`career/${id}`).json<CareerDTO>(); | ||
return careerItemAdapter(dto); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const CAREER_LIST_QUERY_KEY = 'CAREER_LIST_QUERY_KEY'; | ||
|
||
export const CAREER_ITEM_QUERY_KEY = 'CAREER_ITEM_QUERY_KEY'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { CareerModel } from 'src/common/types/common-career-types'; | ||
|
||
export interface CareerListItemProps { | ||
item: CareerModel; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { CareerModel } from 'src/common/types/common-career-types'; | ||
|
||
import { careerListRequest } from '../career-api'; | ||
import { CAREER_LIST_QUERY_KEY } from '../career-constants'; | ||
|
||
export const useCareerListQuery = ( | ||
{ | ||
refetchOnMount = false, | ||
enabled = false, | ||
...restProps | ||
}: Omit<UseQueryOptions<CareerModel[]>, 'queryKey' | 'queryFn'> = { | ||
enabled: false, | ||
refetchOnMount: false, | ||
} | ||
): UseQueryResult<CareerModel[]> => | ||
useQuery<CareerModel[]>({ | ||
...restProps, | ||
enabled: enabled, | ||
queryFn: careerListRequest, | ||
queryKey: [CAREER_LIST_QUERY_KEY], | ||
refetchOnMount: refetchOnMount, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import 'src/assets/variables'; | ||
|
||
.link { | ||
padding: $padding-sm 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { JSX } from 'react'; | ||
|
||
import Link from 'next/link'; | ||
import { BLOG_PAGE_URL, CAREER_PAGE_URL } from 'src/common/common-constants'; | ||
import ApiLink from 'src/common/components/ApiLink'; | ||
|
||
import styles from './Summary.module.scss'; | ||
|
||
const Summary = (): JSX.Element => ( | ||
<ul className='ag-flexbox ag-flexColumn'> | ||
<li className={styles.link}> | ||
<Link href={BLOG_PAGE_URL}>Blog page</Link> | ||
</li> | ||
<li className={styles.link}> | ||
<Link href={CAREER_PAGE_URL}>Career page</Link> | ||
</li> | ||
<li className={styles.link}> | ||
<ApiLink>API documentation page</ApiLink> | ||
</li> | ||
</ul> | ||
); | ||
|
||
export default Summary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
export const isServer = typeof window === 'undefined'; | ||
|
||
export const isDev = process.env.NODE_ENV === 'development'; | ||
|
||
export const PROTOCOL = (isServer ? global.location?.protocol : window.location?.protocol) ?? 'http'; | ||
export const HOST = (isServer ? global.location?.hostname : window.location?.hostname) ?? 'localhost'; | ||
export const PORT = process.env.PORT || 3000; | ||
// protocol comes with ":" on client side | ||
export const API_URL = isServer ? `${PROTOCOL}://${HOST}:${PORT}/api` : `${PROTOCOL}//${HOST}:${PORT}/api`; | ||
// routes | ||
export const BLOG_PAGE_ID = 'blog'; | ||
export const BLOG_PAGE_URL = `/${BLOG_PAGE_ID}`; | ||
export const CAREER_PAGE_ID = 'career'; | ||
export const CAREER_PAGE_URL = `/${CAREER_PAGE_ID}`; | ||
|
||
if (isDev) { | ||
console.log('isServer', isServer); | ||
console.log('isDev', isDev); | ||
console.log('PROTOCOL', PROTOCOL); | ||
console.log('HOST', HOST); | ||
console.log('PORT', PORT); | ||
console.log('API_URL', API_URL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { PropsWithChildren, ReactElement } from 'react'; | ||
|
||
import { API_URL } from 'src/common/common-constants'; | ||
import { WithClass } from 'src/common/types/common-types'; | ||
|
||
const ApiLink = ({ children, className = '' }: PropsWithChildren<WithClass>): ReactElement => ( | ||
<a className={className} href={API_URL} target='_blank' rel='noopener noreferrer'> | ||
{children} | ||
</a> | ||
); | ||
|
||
export default ApiLink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
.nav { | ||
height: $headerHeight; | ||
|
||
&Link { | ||
padding: $padding-sm; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { IBaseEntity } from './common-types'; | ||
import { BaseEntity } from './common-types'; | ||
|
||
export interface IBlogBase extends IBaseEntity { | ||
export interface BlogModelBase extends BaseEntity { | ||
link: string; | ||
linkCaption: string; | ||
title: string; | ||
} | ||
|
||
export interface IBlogDTO extends IBlogBase { | ||
export interface BlogDTO extends BlogModelBase { | ||
date: string; | ||
} | ||
|
||
export interface IBlog extends IBlogBase { | ||
export interface BlogModel extends BlogModelBase { | ||
date: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { BaseEntity } from './common-types'; | ||
|
||
export interface CareerModelBase extends BaseEntity { | ||
description: string; | ||
post: string; | ||
site: string; | ||
title: string; | ||
tools: string; | ||
} | ||
|
||
export interface CareerDTO extends CareerModelBase { | ||
endDate?: string; | ||
startDate: string; | ||
} | ||
|
||
export interface CareerModel extends CareerModelBase { | ||
endDate?: Date; | ||
startDate: Date; | ||
} |
Oops, something went wrong.