-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): translation package migration (#504)
- Loading branch information
1 parent
8c3deb4
commit 51877a8
Showing
253 changed files
with
16,099 additions
and
1,320 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Build Docker Images | ||
|
||
on: | ||
push: | ||
branches: ['beta'] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v3.0.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push (APP) | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: apps/app/Dockerfile | ||
platforms: linux/amd64 | ||
push: true | ||
tags: ghcr.io/nearblocks/app:beta | ||
cache-from: type=registry,ref=ghcr.io/nearblocks/app:beta | ||
cache-to: type=inline |
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
/// <reference types="next/navigation-types/compat/navigation" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { appUrl } from '@/utils/app/config'; | ||
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server'; | ||
|
||
const network = process.env.NEXT_PUBLIC_NETWORK_ID; | ||
const ogUrl = process.env.NEXT_PUBLIC_OG_URL; | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}: { | ||
params: { hash: string; locale: string }; | ||
}) { | ||
unstable_setRequestLocale(params?.locale); | ||
|
||
const t = await getTranslations({ locale: params.locale }); | ||
|
||
const thumbnail = `${ogUrl}/thumbnail/basic?title=${encodeURIComponent( | ||
t('heading') || 'Latest Near Protocol Blocks', | ||
)}&brand=near`; | ||
|
||
const metaTitle = | ||
t('block.metaTitle', { block: params.hash }) || | ||
'All Near Latest Protocol Blocks | NearBlocks'; | ||
const metaDescription = | ||
t('block.metaDescription', { block: params.hash }) || | ||
'All Near (Ⓝ Blocks that are included in Near blockchain. The timestamp, author, gas used, gas price and included transactions are shown.'; | ||
|
||
return { | ||
title: `${network === 'testnet' ? 'TESTNET' : ''} ${metaTitle}`, | ||
description: metaDescription, | ||
openGraph: { | ||
title: metaTitle, | ||
description: metaDescription, | ||
images: [thumbnail], | ||
}, | ||
twitter: { | ||
title: metaTitle, | ||
description: metaDescription, | ||
images: [thumbnail], | ||
}, | ||
alternates: { | ||
canonical: `${appUrl}/blocks/${params.hash}`, | ||
}, | ||
}; | ||
} | ||
|
||
export default async function HaseLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
params: any; | ||
}) { | ||
return <>{children}</>; | ||
} |
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 HashLoading from '@/components/app/skeleton/blocks/hash'; | ||
|
||
export default function Loading() { | ||
return ( | ||
<> | ||
<div className="relative container mx-auto px-3"> | ||
<HashLoading /> | ||
</div> | ||
<div className="py-8"></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,60 @@ | ||
import Details from '@/components/app/Blocks/Details'; | ||
import { nanoToMilli } from '@/utils/app/libs'; | ||
import { Suspense } from 'react'; | ||
import HashLoading from '@/components/app/skeleton/blocks/hash'; | ||
import { getRequest } from '@/utils/app/api'; | ||
import { unstable_setRequestLocale } from 'next-intl/server'; | ||
|
||
export default async function Hash({ | ||
params, | ||
}: { | ||
params: { hash: string; locale: string }; | ||
}) { | ||
unstable_setRequestLocale(params?.locale); | ||
|
||
const [hashData, priceData] = await fetchHashAndPriceData(params.hash); | ||
|
||
return ( | ||
<> | ||
<div className="relative container mx-auto px-3"> | ||
<Suspense fallback={<HashLoading />}> | ||
<Details | ||
hash={params.hash} | ||
data={hashData} | ||
loading={!hashData} | ||
price={priceData} | ||
/> | ||
</Suspense> | ||
</div> | ||
<div className="py-8"></div> | ||
</> | ||
); | ||
} | ||
|
||
async function fetchHashAndPriceData(hash: string) { | ||
const hashDataPromise = fetchHashData(hash); | ||
|
||
const priceDataPromise = hashDataPromise.then(async (data) => { | ||
const timestamp = data?.blocks?.[0]?.block_timestamp; | ||
return timestamp ? fetchPriceData(timestamp) : null; | ||
}); | ||
|
||
const [hashData, priceData] = await Promise.all([ | ||
hashDataPromise, | ||
priceDataPromise, | ||
]); | ||
return [hashData, priceData]; | ||
} | ||
|
||
async function fetchHashData(hash: string) { | ||
return getRequest(`blocks/${hash}`); | ||
} | ||
|
||
async function fetchPriceData(timestamp: any) { | ||
const formattedTimestamp = formatTimestamp(timestamp); | ||
return getRequest(`stats/price?date=${formattedTimestamp}`); | ||
} | ||
|
||
function formatTimestamp(timestamp: any) { | ||
return new Date(nanoToMilli(timestamp)).toISOString().split('T')[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,91 @@ | ||
import { NextIntlClientProvider } from 'next-intl'; | ||
import Layout from '@/components/app/Layouts'; | ||
import { getRequest } from '@/utils/app/api'; | ||
import { | ||
getLocale, | ||
getMessages, | ||
unstable_setRequestLocale, | ||
} from 'next-intl/server'; | ||
|
||
export default async function ProviderLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
params: any; | ||
}) { | ||
const locale = await getLocale(); | ||
const messages = await getMessages({ locale }); | ||
unstable_setRequestLocale(locale); | ||
|
||
const [stats, blocks] = await Promise.all([ | ||
getRequest(`stats`), | ||
getRequest(`blocks/latest?limit=1`), | ||
]); | ||
|
||
const handleFilterAndKeyword = async ( | ||
keyword: string, | ||
filter: string, | ||
returnPath: any, | ||
) => { | ||
'use server'; | ||
|
||
if (keyword.includes('.')) { | ||
keyword = keyword.toLowerCase(); | ||
} | ||
|
||
const res = await getRequest(`search${filter}?keyword=${keyword}`); | ||
|
||
const data = { | ||
blocks: [], | ||
txns: [], | ||
accounts: [], | ||
receipts: [], | ||
}; | ||
|
||
if (res?.blocks?.length) { | ||
if (returnPath) { | ||
return { type: 'block', path: res.blocks[0].block_hash }; | ||
} | ||
data.blocks = res.blocks; | ||
} | ||
|
||
if (res?.txns?.length) { | ||
if (returnPath) { | ||
return { type: 'txn', path: res.txns[0].transaction_hash }; | ||
} | ||
data.txns = res.txns; | ||
} | ||
|
||
if (res?.receipts?.length) { | ||
if (returnPath) { | ||
return { | ||
type: 'txn', | ||
path: res.receipts[0].originated_from_transaction_hash, | ||
}; | ||
} | ||
data.receipts = res.receipts; | ||
} | ||
|
||
if (res?.accounts?.length) { | ||
if (returnPath) { | ||
return { type: 'address', path: res.accounts[0].account_id }; | ||
} | ||
data.accounts = res.accounts; | ||
} | ||
|
||
return returnPath ? null : data; | ||
}; | ||
return ( | ||
<> | ||
<NextIntlClientProvider messages={messages}> | ||
<Layout | ||
stats={stats} | ||
blocks={blocks} | ||
handleFilterAndKeyword={handleFilterAndKeyword} | ||
> | ||
{children} | ||
</Layout> | ||
</NextIntlClientProvider> | ||
</> | ||
); | ||
} |
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,11 @@ | ||
'use client'; | ||
import Error from 'next/error'; | ||
export default function NotFound() { | ||
return ( | ||
<html> | ||
<body> | ||
<Error statusCode={404} /> | ||
</body> | ||
</html> | ||
); | ||
} |
Oops, something went wrong.