Skip to content

Commit

Permalink
chore: [locale] page working 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-logan committed May 30, 2024
1 parent a2fce77 commit 1a51b29
Show file tree
Hide file tree
Showing 60 changed files with 4,964 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ console.log(result6);`}
<h2 className="subtitle">{t("Notes")}</h2>
<p>
{t(
"agora esse The function first checks if the input value is either a string or a number. If the value is a string, it is converted to an integer using",
"The function first checks if the input value is either a string or a number. If the value is a string, it is converted to an integer using",
)}{" "}
<code>parseInt(value, 10)</code>.{" "}
{t(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import "@/css/functions.css";

import { setStaticParamsLocale } from "next-international/server";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism";

import { LocaleParams } from "@/app/[locale]/types/locale";
import DrawerComponent from "@/components/Drawer";
import { getScopedI18n } from "@/locales/server";

export default async function CnpjIsValid({
params: { locale },
}: LocaleParams) {
setStaticParamsLocale(locale);

const t = await getScopedI18n("DocumentationJsFunctions");
return (
<div id="page-content-wrapper">
<div className="relative mr-10 flex justify-end p-4">
<DrawerComponent locale={locale} />
</div>
<div className="container-fluid container">
<h1 className="title">cnpjIsValid {t("Function Documentation")}</h1>
<p>
{t("The")} <code>cnpjIsValid</code>{" "}
{t(
"function is used to validate a Brazilian CNPJ (National Registry of Legal Entities) number. It returns an object containing the",
)}{" "}
<code>isValid</code> (boolean) {t("and")} <code>errorMsg</code>{" "}
(string){" "}
{t(
"properties, indicating whether the CNPJ is valid and, in case of an error, the corresponding error message.",
)}
</p>

<h2 className="subtitle">Import</h2>
<p>
{t(
'The function can be imported using ES6 syntax from the "multiform-validator" package:',
)}
</p>

<SyntaxHighlighter language="javascript" style={a11yDark}>
{`import { cnpjIsValid } from 'multiform-validator';`}
</SyntaxHighlighter>

<h2 className="subtitle">{t("Parameters")}</h2>
<p>{t("The function takes two parameters:")}</p>
<ul>
<li>
<code>cnpj</code> (string) - {t("The CNPJ number to be validate.")}
</li>
<li>
<code>errorMsg</code> ({t("optional array")}) -{" "}
{t(
"A list of custom error messages. If not provided, it uses a default list of error messages.",
)}
</li>
</ul>

<h2 className="subtitle">{t("Examples")}</h2>

<SyntaxHighlighter language="javascript" style={a11yDark}>
{`// Example 1 - Using the CNPJ number '72.501.263/0001-40' const
result1 = cnpjIsValid('72.501.263/0001-40');
console.log(result1.isValid); // true
console.log(result1.errorMsg); // null
// Example 2 - Using the CNPJ number '73.506.263/0001-45' and custom error messages
const result2 = cnpjIsValid('73.506.263/0001-45', ['CNPJ is wrong']);
console.log(result2.isValid); // false
console.log(result2.errorMsg); // 'CNPJ is wrong'`}
</SyntaxHighlighter>

<h2 className="subtitle">{t("Notes")}</h2>
<p>
{t("If the function is called with an invalid value for the")}{" "}
<code>errorMsg</code>{" "}
{t(
"parameter (non-array), or if an error occurs during the validation process, the function will return an object with",
)}{" "}
<code>isValid</code> {t("set to")} <code>false</code> {t("and")}{" "}
<code>errorMsg</code>{" "}
{t("containing the default error message 'Unknown error'.")}
</p>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import "@/css/functions.css";

import { setStaticParamsLocale } from "next-international/server";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism";

import { LocaleParams } from "@/app/[locale]/types/locale";
import DrawerComponent from "@/components/Drawer";
import { getScopedI18n } from "@/locales/server";

export default async function CpfIsValid({ params: { locale } }: LocaleParams) {
setStaticParamsLocale(locale);

const t = await getScopedI18n("DocumentationJsFunctions");

return (
<div id="page-content-wrapper">
<div className="relative mr-10 flex justify-end p-4">
<DrawerComponent locale={locale} />
</div>
<div className="container-fluid container">
<h1 className="title">cpfIsValid {t("Function Documentation")}</h1>
<p>
{t("The")} <code>cpfIsValid</code>{" "}
{t(
"function is used to validate a Brazilian CPF (Individual Taxpayer Identification) number. It returns an object containing the",
)}{" "}
<code>isValid</code> (boolean) {t("and")} <code>errorMsg</code>{" "}
(string){" "}
{t(
"properties, indicating whether the CPF is valid and, in case of an error, the corresponding error message.",
)}
</p>

<h2 className="subtitle">Import</h2>
<p>{t("There are two ways to import the function:")}</p>
<ul>
<li>
<strong>
{t("Using")} <code>require</code> (Node.js):
</strong>
</li>
<SyntaxHighlighter language="javascript" style={a11yDark}>
{`const { cpfIsValid } = require('multiform-validator');`}
</SyntaxHighlighter>
<li>
<strong>
{t("Using")} <code>Import</code> (ES6):
</strong>
</li>
<SyntaxHighlighter language="javascript" style={a11yDark}>
{`import { cpfIsValid } from 'multiform-validator';`}
</SyntaxHighlighter>
</ul>

<h2 className="subtitle">{t("Parameters")}</h2>
<p>{t("The function takes two parameters:")}</p>
<ul>
<li>
<code>cpf</code> (string) - {t("The CPF number to be validated.")}
</li>
<li>
<code>errorMsg</code> ({t("optional array")}) -{" "}
{t(
"A list of custom error messages. If not provided, it uses a default list of error messages.",
)}
</li>
</ul>

<h2 className="subtitle">{t("Examples")}</h2>

<SyntaxHighlighter language="javascript" style={a11yDark}>
{`// Example 1 - Using the CPF number '123.456.789.10'
const result1 = cpfIsValid('123.456.789.10');
console.log(result1.isValid); // false
console.log(result1.errorMsg); // 'CPF invalid'
// Example 2 - Using the CPF number '12345678910' and custom error messages
const result2 = cpfIsValid("12345678910", [
"CPF is wrong",
"Must have at least 11 digits",
]);
console.log(result2.isValid); // false
console.log(result2.errorMsg); // 'CPF is wrong'
// Example 3 - Using a valid CPF number '52998224725'
const result3 = cpfIsValid('52998224725');
console.log(result3.isValid); // true
console.log(result3.errorMsg); // null`}
</SyntaxHighlighter>

<h2 className="subtitle">{t("Notes")}</h2>
<p>
{t("If the function is called with an invalid value for the")}{" "}
<code>errorMsg</code>{" "}
{t(
"parameter (non-array), or if an error occurs during the validation process, the function will return an object with",
)}{" "}
<code>isValid</code> {t("set to")} <code>false</code> {t("and")}{" "}
<code>errorMsg</code>{" "}
{t("containing the default error message 'Unknown error'.")}
</p>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import "@/css/functions.css";

import { setStaticParamsLocale } from "next-international/server";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism";

import { LocaleParams } from "@/app/[locale]/types/locale";
import DrawerComponent from "@/components/Drawer";
import { getScopedI18n } from "@/locales/server";

export default async function GetOnlyEmail({
params: { locale },
}: LocaleParams) {
setStaticParamsLocale(locale);

const t = await getScopedI18n("DocumentationJsFunctions");

return (
<div id="page-content-wrapper">
<div className="relative mr-10 flex justify-end p-4">
<DrawerComponent locale={locale} />
</div>
<div className="container-fluid container">
<h1 className="title">getOnlyEmail {t("Function Documentation")}</h1>
<p>
{t("The")} <code>getOnlyEmail</code>{" "}
{t(
"function extracts email addresses from a given text. If the optional",
)}{" "}
<code>multiple</code> {t("parameter is set to")} <code>true</code>,{" "}
{t(
"it returns an array with all the email addresses found. Otherwise, it returns only the first email address found as a string.",
)}
</p>

<h2 className="subtitle">Import</h2>
<p>
{t(
'The function can be imported using ES6 syntax from the "multiform-validator" package:',
)}
</p>

<SyntaxHighlighter language="javascript" style={a11yDark}>
{`import { getOnlyEmail } from 'multiform-validator';`}
</SyntaxHighlighter>

<p>
{t(
"Alternatively, you can import the function using CommonJS syntax with",
)}{" "}
<code>require</code> (Node.js):
</p>

<SyntaxHighlighter language="javascript" style={a11yDark}>
{`const { getOnlyEmail } = require('multiform-validator');`}
</SyntaxHighlighter>

<h2 className="subtitle">{t("Parameters")}</h2>
<p>{t("The function takes two parameters:")}</p>
<ul>
<li>
<code>text</code> (string) -{" "}
{t("The input text from which emails will be extracted.")}
</li>
<li>
<code>multiple</code> {t("(optional boolean) - If set to")}{" "}
<code>true</code>,{" "}
{t(
"the function will return an array with all the email addresses found. If set to",
)}{" "}
<code>false</code>{" "}
{t(
"or not provided, it will return only the first email address found as a string.",
)}
</li>
<li>
<code>cleanDomain</code>{" "}
{t(
"(optional boolean | string[]) - Either a boolean value indicating whether to clean after default domains or an array of custom domains to clean after. Default is",
)}{" "}
<code>false</code>{" "}
{t(
"which means it won't clean the email addresses after default domains ['.br', '.io', '.pt', '.us', '.org', '.com'];. If set to",
)}{" "}
<code>true</code>,{" "}
{t(
"it will clean after default domains. If set to an array of strings, it will clean after the specified custom domains.",
)}
</li>
<li>
<code>repeatEmail</code> {t("(optional boolean) - If set to")}{" "}
<code>false</code>,{" "}
{t(
"the function will remove duplicate emails from the output list. If set to",
)}{" "}
<code>true</code>{" "}
{t(
"or not provided, it will keep the duplicate emails in the output list.",
)}
</li>
</ul>

<h2 className="subtitle">{t("Examples")}</h2>

<SyntaxHighlighter language="javascript" style={a11yDark}>
{`// Example 1 - Extracting multiple emails from the text
const result1 = getOnlyEmail(
"Entre em contato com a equipe: joao@empresa.com, maria@empresa.com, contato@empresa.com",
{ multiple: true },
);
console.log(result1);
// Output: ["joao@empresa.com", "maria@empresa.com", "contato@empresa.com"]
// Example 2 - Extracting the first email from the text
const result2 = getOnlyEmail(
"Vaga na asdlaod Mande seu email para fiawn@rdwah.com Sim aqui mesmo",
);
console.log(result2);
// Output: "fiawn@rdwah.com"
const result3 = getOnlyEmail(
"Vaga na asdlaod Mande seu email para fiawn@rdwah.comSim aqui asdasd@gmail.commesmo",
{ multiple: true, cleanDomain: true },
);
console.log(result3);
// Output: [ 'fiawn@rdwah.com', 'asdasd@gmail.com' ]
const result4 = getOnlyEmail(
"Vaga na asdlaod Mande seu email para fiawn@rdwah.comSim aqui asdasd@gmail.commesmo asdasd asd as fiawn@rdwah.com",
{ multiple: true, cleanDomain: true, repeatEmail: true },
);
console.log(result4);
// Output: [ 'fiawn@rdwah.com', 'asdasd@gmail.com', 'fiawn@rdwah.com' ]`}
</SyntaxHighlighter>

<h2 className="subtitle">{t("Notes")}</h2>
<p>
{t(
"If no email address is found in the input text, the function will return the string 'No email found'.",
)}
</p>
</div>
</div>
);
}
Loading

0 comments on commit 1a51b29

Please sign in to comment.