-
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.
- Loading branch information
Showing
28 changed files
with
182 additions
and
933 deletions.
There are no files selected for viewing
Empty file.
Empty file.
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 async function GET() { | ||
return Response.json({ health: true }) | ||
} |
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,10 @@ | ||
import { serializeCookie } from '@/lib/cookie' | ||
|
||
export async function POST() { | ||
const cookie = serializeCookie('auth', {}, { path: '/', expires: new Date(Date.now()) }) | ||
return Response.json({ logout: true }, { | ||
headers: { | ||
'Set-Cookie': cookie, | ||
}, | ||
}) | ||
} |
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,51 @@ | ||
import Head from "next/head"; | ||
import Header from "@components/header" | ||
import { useTranslation } from 'next-i18next'; | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations' | ||
import { usePathname } from 'next/navigation' | ||
import { useState } from 'react'; | ||
|
||
type LayoutType = { | ||
title?: string; | ||
children?: React.ReactNode; | ||
}; | ||
|
||
|
||
export default ({ children, title = "2ALL" }: LayoutType) => { | ||
const pathname = usePathname() | ||
const [onTop, setOnTop] = useState(false); | ||
|
||
if(pathname === "/landingpage") { | ||
} | ||
|
||
return ( | ||
<div className="app-main"> | ||
<Head> | ||
<title>{title}</title> | ||
<link rel="icon" href="/images/logo.ico" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&display=swap" | ||
/> | ||
<link | ||
href="https://fonts.cdnfonts.com/css/svn-gilroy" | ||
rel="stylesheet" | ||
/> | ||
|
||
<link | ||
rel="stylesheet" | ||
href="https://fonts.googleapis.com/css2?family=Inter:wght@600&display=swap" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap" | ||
/> | ||
</Head> | ||
{/* landing-page-option-3 */} | ||
<main className=" d-flex flex-column"> | ||
<Header /> | ||
{children} | ||
</main> | ||
</div> | ||
); | ||
}; |
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,64 @@ | ||
import useSWR from 'swr' | ||
import axios, { | ||
AxiosError, AxiosHeaders, | ||
AxiosRequestConfig, | ||
AxiosResponse, | ||
AxiosResponseTransformer, | ||
} from 'axios' | ||
|
||
type AtLeast<T, K extends keyof T> = & Pick<T, K> & Partial<T> | ||
|
||
type AxiosResponseWithFallbackData<T> = AtLeast<AxiosResponse<T>, 'data'> | ||
|
||
/** | ||
* `useSWR` wrapper with `axios` as fetcher. | ||
* Requires `fallbackData` for initial fetch. | ||
* | ||
* @param axiosRequest | ||
* @param axiosFallbackData | ||
*/ | ||
export default function useSWRAxios<T>( | ||
axiosRequest: AxiosRequestConfig, | ||
axiosFallbackData: AxiosResponseWithFallbackData<T>, | ||
) { | ||
const initFallbackData: AxiosResponse<T> = { | ||
data: axiosFallbackData.data, | ||
headers: {}, | ||
status: 200, | ||
statusText: 'Initial', | ||
config: { | ||
headers: new AxiosHeaders(), | ||
}, | ||
} | ||
|
||
const fallbackData: AxiosResponse<T> = { ...initFallbackData, ...axiosFallbackData } | ||
|
||
return useSWR( | ||
JSON.stringify(axiosRequest), | ||
() => axios.request<T>(axiosRequest), | ||
{ | ||
fallbackData, | ||
onErrorRetry: (error: AxiosError<T>, key, config, revalidate, { retryCount }) => { | ||
// Never retry on 404. | ||
if (error.response?.status === 404) return | ||
|
||
// Only retry up to `maxRetry` times. | ||
const maxRetry = parseInt(process.env.NEXT_PUBLIC_API_MAX_RETRY ?? '5', 10) | ||
if (retryCount >= maxRetry) return | ||
|
||
// Retry after `retryInterval` seconds. | ||
const retryInterval = parseInt(process.env.NEXT_PUBLIC_API_RETRY_INTERVAL_IN_SECONDS ?? '5', 10) | ||
setTimeout(() => revalidate({ retryCount }), retryInterval * 1000) | ||
}, | ||
}, | ||
) | ||
} | ||
|
||
// Disable style for better reading. | ||
// eslint-disable-next-line arrow-body-style | ||
export const transformResponseWrapper = (transformer: AxiosResponseTransformer) => { | ||
return ([] as AxiosResponseTransformer[]).concat( | ||
axios.defaults.transformResponse as AxiosResponseTransformer, | ||
transformer, | ||
) as AxiosResponseTransformer[] | ||
} |
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,44 @@ | ||
export interface Resource<T> { | ||
data: T[]; | ||
meta: { | ||
current_page: number; | ||
last_page: number; | ||
from: number; | ||
to: number; | ||
per_page: number; | ||
total: number; | ||
}; | ||
} | ||
|
||
const getTo = (total: number, page: number, perPage: number) => { | ||
if (page === 1) { | ||
return total < perPage ? total : perPage | ||
} | ||
|
||
return (page - 1) * perPage + perPage | ||
} | ||
|
||
const getLastPage = (total: number, perPage: number) => { | ||
if (total <= 1) { | ||
return 1 | ||
} | ||
|
||
return Math.ceil(total / perPage) | ||
} | ||
|
||
export const newResource = <T>( | ||
data: T[], | ||
total: number, | ||
page: number, | ||
perPage: number, | ||
): Resource<T> => ({ | ||
data, | ||
meta: { | ||
current_page: page, | ||
last_page: getLastPage(total, perPage), | ||
from: page === 1 ? 1 : (page - 1) * perPage + 1, | ||
to: getTo(total, page, perPage), | ||
per_page: perPage, | ||
total, | ||
}, | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.