Skip to content

Commit

Permalink
feat(#14): Adjusted items
Browse files Browse the repository at this point in the history
  • Loading branch information
clovisantunes committed Aug 29, 2023
2 parents 3fbe852 + f57b6d6 commit 2e13a98
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 14 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ 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
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("../en.json").then((r) => r.default),
pt: () => import("../pt.json").then((r) => r.default)
};

export const getTranslation = (lang: string): Promise<TranslationData> => {
Expand Down
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"next-i18next": "^14.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.45.4",
"react-i18next": "^13.0.2",
"typescript": "5.1.6"
},
Expand Down
19 changes: 12 additions & 7 deletions src/app/[lang]/home/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import React from 'react';
import { getTranslation } from '../../../utils/getTranslation';
import React, { FormEvent } from 'react';
import { getTranslation } from '../../../../locales/utils/getTranslation';
import styles from './styles.module.scss';
import { Input } from '@/components/UI/Input';

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

export default Home;
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 '../../../locales/utils/getTranslation'

interface pageProps {
params: any
Expand Down
10 changes: 7 additions & 3 deletions src/components/UI/Input/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from "react";
import styles from './styles.module.scss';
import { InputHTMLAttributes } from "react";
import { useFormContext } from "react-hook-form";

interface InputProps extends InputHTMLAttributes<HTMLInputElement>{}
interface InputProps extends InputHTMLAttributes<HTMLInputElement>{
name: string;
}

export function Input({...rest}: InputProps){
export function Input({name,...rest}: InputProps){
const {register}= useFormContext();
return(
<input className={styles.input} {...rest}/>
<input className={styles.input} id={name} {...register(name)}{...rest}/>
)
}

0 comments on commit 2e13a98

Please sign in to comment.