Skip to content

Commit

Permalink
feat(#14): Created username choice
Browse files Browse the repository at this point in the history
  • Loading branch information
clovisantunes committed Aug 28, 2023
1 parent 080fb35 commit 3fbe852
Show file tree
Hide file tree
Showing 15 changed files with 479 additions and 615 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Created support for multiple languages [MBU-11](https://memebattle.atlassian.net/browse/MBU-11)
- Default theme and style settings [MBU-12](https://memebattle.atlassian.net/browse/MBU-12)
- Created the LICENSE [MBU-13](https://memebattle.atlassian.net/browse/MBU-13)
- Created username choice [#14](https://github.com/Meme-Battle/web/issues/14)

### Fixed

Expand Down
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"hello": "Hello word!"
"hello": "Hello word!",
"nameInput": "Insert your name"
}
3 changes: 2 additions & 1 deletion locales/pt.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"hello": "Ola mundo!"
"hello": "Ola mundo!",
"nameInput": "Insira seu nome"
}
1,019 changes: 438 additions & 581 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/app/[lang]/home/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { getTranslation } from '../../../utils/getTranslation';
import styles from './styles.module.scss';
import { Input } from '@/components/UI/Input';

interface HomeProps {
params: any
}
async function Home({params}: HomeProps) {
const lang = await getTranslation(params.lang)
return (
<Input
type='text'
placeholder={lang.nameInput}
/>
)
}

export default Home;
Empty file.
2 changes: 1 addition & 1 deletion src/app/[lang]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import {getTranslation } from '../../../utils/getTranslation'
import {getTranslation } from '../../utils/getTranslation'

interface pageProps {
params: any
Expand Down
21 changes: 0 additions & 21 deletions src/app/layout.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/app/page.tsx

This file was deleted.

11 changes: 11 additions & 0 deletions src/components/UI/Input/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import styles from './styles.module.scss';
import { InputHTMLAttributes } from "react";

interface InputProps extends InputHTMLAttributes<HTMLInputElement>{}

export function Input({...rest}: InputProps){
return(
<input className={styles.input} {...rest}/>
)
}
Empty file.
4 changes: 2 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { i18n } from "../i18n";
import { getLocale } from "../utils/getLocale";
import pageError from "../utils/pageError";
import { getLocale } from "./utils/getLocale";
import pageError from "./utils/pageError";

export async function middleware(request: NextRequest) {
const pathname = request.nextUrl.pathname;
Expand Down
2 changes: 1 addition & 1 deletion utils/getLocale.ts → src/utils/getLocale.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NextRequest } from "next/server";
import { i18n } from "../i18n";
import { i18n } from "../../i18n";
import Negotiator from "negotiator";
import { match as matchLocale } from "@formatjs/intl-localematcher";

Expand Down
4 changes: 2 additions & 2 deletions utils/getTranslation.ts → src/utils/getTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ interface TranslationData {
}

const locales: { [key: string]: () => Promise<TranslationData> } = {
en: () => import("../locales/en.json").then((r) => r.default),
pt: () => import("../locales/pt.json").then((r) => r.default)
en: () => import("../../locales/en.json").then((r) => r.default),
pt: () => import("../../locales/pt.json").then((r) => r.default)
};

export const getTranslation = (lang: string): Promise<TranslationData> => {
Expand Down
File renamed without changes.

0 comments on commit 3fbe852

Please sign in to comment.