Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21 web handle currency #104

Merged
merged 66 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
953e8d5
add: currency/api lib
AlexandreG-tech Oct 2, 2023
3adeb8f
fix: writeToFile rates
AlexandreG-tech Oct 2, 2023
61db422
rebase
AlexandreG-tech Oct 2, 2023
cdec081
fix: writeToFile rates
AlexandreG-tech Oct 2, 2023
f3810d2
Merge branch '21-web-handle-currency' of github.com:Offline-Project/m…
AlexandreG-tech Oct 3, 2023
2346d42
add: next-currency-cache functions
AlexandreG-tech Oct 3, 2023
729540c
add: setRates cron job
AlexandreG-tech Oct 3, 2023
3861eb9
fix: next/currency-cache to ts config
AlexandreG-tech Oct 3, 2023
567f3c4
fix: linter unknow instead of any
AlexandreG-tech Oct 3, 2023
eebebef
fix: linter unknow instead of any
AlexandreG-tech Oct 3, 2023
be6f1cb
fix: uncomment important code
AlexandreG-tech Oct 3, 2023
a887e48
fix: tests for currency/api and currency-cache
AlexandreG-tech Oct 6, 2023
a6075f6
rebase
AlexandreG-tech Oct 2, 2023
94602c5
add env variables changes and @shared/server to get env info
sebpalluel Oct 6, 2023
598425f
fix: fix tests for currency-cache
AlexandreG-tech Oct 6, 2023
5eceb4e
fix: fix tests for currency-cache and merge
AlexandreG-tech Oct 6, 2023
bdb7a07
tsconfig add
AlexandreG-tech Oct 6, 2023
8aaea39
add: CurrencyProvider and provider settings
AlexandreG-tech Oct 9, 2023
365a111
fix: tsconfig.base.json
AlexandreG-tech Oct 9, 2023
cb101d8
add: currency-dropdown ui/components and icons
AlexandreG-tech Oct 9, 2023
d5f155e
fix: global settings props
AlexandreG-tech Oct 9, 2023
b866731
🔧 chore(sentry.client.config.ts): remove unused code and simplify SEN…
sebpalluel Oct 9, 2023
5d45d6e
fix: usecontext back in eventpasses
AlexandreG-tech Oct 9, 2023
6402d7e
fix: currency provider in preview
AlexandreG-tech Oct 9, 2023
3871fec
Merge branch '21-web-handle-currency' of github.com:Offline-Project/m…
AlexandreG-tech Oct 9, 2023
f7a2eac
🔧 chore(package.json): remove esbuild dependency to simplify the proj…
sebpalluel Oct 9, 2023
0f7c7f5
fix: currency settings and revalidateTag
AlexandreG-tech Oct 9, 2023
5226cae
Merge branch '21-web-handle-currency' of github.com:Offline-Project/m…
AlexandreG-tech Oct 9, 2023
c9dde8f
fix: isJestRunning for setRates tests
AlexandreG-tech Oct 9, 2023
4095ad2
test: without loading
AlexandreG-tech Oct 9, 2023
57b3f9e
correct old version
AlexandreG-tech Oct 9, 2023
762107f
fix: currencyProvider
AlexandreG-tech Oct 9, 2023
30aa52c
fix: comment test rates
AlexandreG-tech Oct 9, 2023
76aeb19
fix: test without eventpasses
AlexandreG-tech Oct 9, 2023
5d50bea
fix: remove all formatCurrency
AlexandreG-tech Oct 9, 2023
d4f546f
fix: remove all formatCurrency
AlexandreG-tech Oct 9, 2023
53ea199
fix: remove all formatCurrency in SinglePass
AlexandreG-tech Oct 9, 2023
91fafff
fix: remove getREates from currencyProvider
AlexandreG-tech Oct 9, 2023
bbe7c81
fix: put back tsconfig about storybook
AlexandreG-tech Oct 9, 2023
322f351
fix: getRates in currency provider with rfetch
AlexandreG-tech Oct 9, 2023
702f234
fix: PassTotal uncommented
AlexandreG-tech Oct 9, 2023
b5b8bbd
fix: PassTotal without loading
AlexandreG-tech Oct 9, 2023
6aeeefd
fix: check if it's a test and return false rates
AlexandreG-tech Oct 9, 2023
d07f94d
📦 chore(env-nextjs.mock.js): add mock file for @t3-oss/env-nextjs mod…
sebpalluel Oct 9, 2023
ee6c934
fix: check if fetchFromLocalFile is problem
AlexandreG-tech Oct 9, 2023
a0f70b0
fix: display args to check
AlexandreG-tech Oct 9, 2023
c833ef1
fix: display all key value of objects
AlexandreG-tech Oct 9, 2023
4a79762
fix: display all key values
AlexandreG-tech Oct 9, 2023
97d05d1
fix: send only the concerned rate to formatCurrency
AlexandreG-tech Oct 9, 2023
f2141c9
fix: toUserCurrency to take only the rate of the user currency
AlexandreG-tech Oct 9, 2023
dfb5eb5
🐛 fix(index.ts): fix file path to use __dirname instead of process.cw…
sebpalluel Oct 10, 2023
6e4b01c
fix: rates in lib and absolute path for __dirname
AlexandreG-tech Oct 11, 2023
81c53cf
fix: swcrc file for currency/types
AlexandreG-tech Oct 11, 2023
28cd15e
fix: storybook story
AlexandreG-tech Oct 11, 2023
7829444
🔧 chore(jest.preset.js): add support for import.meta in jest configur…
sebpalluel Oct 11, 2023
383a263
fix: fix tests with import.meta and new EUR.json
AlexandreG-tech Oct 11, 2023
6c24272
Merge remote-tracking branch 'origin/staging' into 21-web-handle-curr…
AlexandreG-tech Oct 11, 2023
7bd89b6
fix: no frozen lockfile
AlexandreG-tech Oct 11, 2023
f03b9bb
fix: no frozen lockfile
AlexandreG-tech Oct 11, 2023
c153c5c
🔥 refactor(server.ts): change port variable case from lowercase port …
sebpalluel Oct 11, 2023
37d17bb
🐛 fix(nft-thirdweb-api.ts): add error handling for undefined SDK to p…
sebpalluel Oct 11, 2023
044d28e
🔧 chore(.swcrc): remove unnecessary regex pattern from exclude list t…
sebpalluel Oct 11, 2023
9f34d56
🐛 fix(payment-admin.ts): throw an error if refund status is null to p…
sebpalluel Oct 11, 2023
958e22f
🔧 fix(layout.tsx): remove unused import and update import path for An…
sebpalluel Oct 11, 2023
f00b8fb
🔧 chore(tsconfig.base.json): optimize paths configuration for better …
sebpalluel Oct 11, 2023
1c4a86c
🔧 chore(preview-apps.yml): remove 'staging' branch from branches-igno…
sebpalluel Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ KV_REST_API_TOKEN="example_token"
## timezone
TZ=UTC


# NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=test
## currency
FIXER_CURRENCY_API_KEY='0f0ab52ebe369b4693f500cd98188313'
EXCHANGE_RATE_API_KEY='6c9a453dde30336217525dad'
1 change: 0 additions & 1 deletion .github/workflows/preview-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
types: [opened, reopened, synchronize]
branches-ignore:
- main
- staging

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
Expand Down
15 changes: 12 additions & 3 deletions apps/back-office/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { type AppNavLayoutProps } from '@features/appNav/ui';
import { AuthProvider, NextAuthProvider } from '@next/auth';
import { getMessages, locales } from '@next/i18n';
import { ReactQueryProviders } from '@next/react-query';
import { UploaderProvider } from '@next/uploader-provider';
import { Toaster } from '@ui/components';
import { cn } from '@ui/shared';
import { ThemeProvider } from '@ui/theme';
import { Analytics } from '@web/components/Analytics';
import { Analytics } from '@back-office/components/Analytics';
import { siteConfig } from '@back-office/config/site';
import { Metadata } from 'next';
import { createTranslator } from 'next-intl';
import { Inter as FontSans } from 'next/font/google';
import localFont from 'next/font/local';
Expand All @@ -24,16 +25,24 @@ const fontHeading = localFont({
variable: '--font-heading',
});

export const metadata: Metadata = {
title: {
default: siteConfig.name,
template: `%s - ${siteConfig.name}`,
},
};

// Error: Usage of next-intl APIs in Server Components is currently only available for dynamic rendering (i.e. no `generateStaticParams`).
// Support for static rendering is under consideration, please refer to the roadmap: https://next-intl-docs.vercel.app/docs/getting-started/app-router-server-components#roadmap
// export async function generateStaticParams() {
// return locales.map((locale) => ({ locale }));
// }

interface RootLayoutProps extends AppNavLayoutProps {
interface RootLayoutProps {
params: {
locale: string;
};
children: React.ReactNode;
}

// export async function generateStaticParams() {
Expand Down
1 change: 0 additions & 1 deletion apps/back-office/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ const nextConfig = {
// If use with serverActions is desired
serverActions: true,
useDeploymentIdServerActions: true,
appDir: true,
typedRoutes: false, // no solution found to get it working with nx monorepo (not accessible from external libs like feature)
},
sentry: {
Expand Down
3 changes: 3 additions & 0 deletions apps/web/.storybook/env-nextjs.mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
createEnv: (env) => env.runtimeEnv,
};
4 changes: 4 additions & 0 deletions apps/web/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ module.exports = {
test: /\.svg$/,
use: ['@svgr/webpack', 'url-loader'],
});
config.resolve.alias['@t3-oss/env-nextjs'] = path.resolve(
__dirname,
'./env-nextjs.mock.js'
);
//
// Add tsconfig-paths-webpack-plugin to the resolve.plugins array
config.resolve.plugins = [
Expand Down
16 changes: 11 additions & 5 deletions apps/web/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import '../styles/globals.css';
import { Preview, Decorator } from '@storybook/react';
import { useEffect, useState } from 'react';
import { parameters } from '../../../storybook.preview.base';
import { NextIntlClientProvider } from 'next-intl';
import { CurrencyProvider } from '@next/currency';
import { defaultLocale } from '@next/i18n';
import { Decorator, Preview } from '@storybook/react';
import { NextIntlClientProvider } from 'next-intl';
import { useEffect, useState } from 'react';
import messagesEn from '../../../libs/next/i18n/src/messages/en.json';
import messagesfr from '../../../libs/next/i18n/src/messages/fr.json';
import { parameters } from '../../../storybook.preview.base';
import '../styles/globals.css';

window.STORYBOOK_ENV = true;

Expand Down Expand Up @@ -68,6 +69,10 @@ const I18nextStoryDecorator: Decorator = (Story, context) => {
);
};

const CurrencyDecorator: Decorator = (Story, context) => {
return <CurrencyProvider>{Story(context)}</CurrencyProvider>;
};

document.body.classList.add('font-sans');

const preview: Preview = {
Expand All @@ -81,6 +86,7 @@ const preview: Preview = {
DarkModeDecorator,
I18nextStoryDecorator,
localStorageResetDecorator,
CurrencyDecorator,
],
};
export default preview;
7 changes: 5 additions & 2 deletions apps/web/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AuthProvider, NextAuthProvider } from '@next/auth';
import { CurrencyProvider } from '@next/currency';
import { getMessages, locales } from '@next/i18n';
import { ReactQueryProviders } from '@next/react-query';
import { Toaster } from '@ui/components';
Expand Down Expand Up @@ -129,8 +130,10 @@ export default async function RootLayout({
}}
>
<ReactQueryProviders>
<AppNavLayout {...appNavLayout}>{children}</AppNavLayout>
<Toaster />
<CurrencyProvider>
<AppNavLayout {...appNavLayout}>{children}</AppNavLayout>
<Toaster />
</CurrencyProvider>
</ReactQueryProviders>
</AuthProvider>
</NextAuthProvider>
Expand Down
27 changes: 27 additions & 0 deletions apps/web/app/api/currency/rates/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { getRates } from '@next/currency-cache';
import { NextRequest, NextResponse } from 'next/server';

export async function GET(req: NextRequest) {
try {
const rates = await getRates();

return new NextResponse(JSON.stringify(rates), {
status: 200,
headers: {
'content-type': 'application/json',
},
});
} catch (error) {
console.error(error);

return new NextResponse(
JSON.stringify({ error: 'Failed to fetch rates' }),
{
status: 500,
headers: {
'content-type': 'application/json',
},
}
);
}
}
6 changes: 1 addition & 5 deletions apps/web/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
import * as Sentry from '@sentry/nextjs';

import env from '@env/client';
import envServer from '@env/server';

//
const SENTRY_DSN = envServer.SENTRY_AUTH_TOKEN
? null
: envServer.SENTRY_DSN || env.NEXT_PUBLIC_SENTRY_DSN;
const SENTRY_DSN = env.NEXT_PUBLIC_SENTRY_DSN;

Sentry.init({
environment: process.env.NEXT_PUBLIC_VERCEL_ENV || 'development',
Expand Down
16 changes: 16 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ module.exports = {
},
},
],
// avoid issue with import.meta
'^.+\\.[tj]s$': [
'ts-jest',
{
diagnostics: {
ignoreCodes: [1343],
},
astTransformers: {
before: [
{
path: 'ts-jest-mock-import-meta', // or 'node_modules/ts-jest-mock-import-meta'
},
],
},
},
],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'mjs'],
coverageThreshold: {
Expand Down
18 changes: 18 additions & 0 deletions libs/currency/api/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
11 changes: 11 additions & 0 deletions libs/currency/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# currency-api

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build currency-api` to build the library.

## Running unit tests

Run `nx test currency-api` to execute the unit tests via [Jest](https://jestjs.io).
8 changes: 8 additions & 0 deletions libs/currency/api/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* eslint-disable */
export default {
displayName: 'currency-api',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../coverage/libs/currency/api',
};
10 changes: 10 additions & 0 deletions libs/currency/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@currency/api",
"version": "0.0.1",
"dependencies": {
"tslib": "^2.3.0"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}
43 changes: 43 additions & 0 deletions libs/currency/api/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "currency-api",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/currency/api/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/currency/api",
"main": "libs/currency/api/src/index.ts",
"tsConfig": "libs/currency/api/tsconfig.lib.json",
"assets": ["libs/currency/api/*.md"]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"libs/currency/api/**/*.ts",
"libs/currency/api/package.json"
]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/currency/api/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"tags": []
}
Loading
Loading