-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from ZACHSTRIVES/dev
feat: add new generators
- Loading branch information
Showing
20 changed files
with
445 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,19 @@ | ||
import {SelectOption} from "@/components/Utils"; | ||
import {FormattedMessage} from "@/locale"; | ||
import {Sex} from "@/constants/enums"; | ||
import React from "react"; | ||
|
||
export const SexSelectOptions: SelectOption[] = [ | ||
{ | ||
label: <FormattedMessage id={"dataType.fullName.sex.selectOptions.all"}/>, | ||
value: Sex.ALL | ||
}, | ||
{ | ||
label: <FormattedMessage id={"dataType.fullName.sex.selectOptions.male"}/>, | ||
value: Sex.MALE, | ||
}, | ||
{ | ||
label: <FormattedMessage id={"dataType.fullName.sex.selectOptions.female"}/>, | ||
value: Sex.FEMALE | ||
} | ||
] |
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,58 @@ | ||
import React from "react"; | ||
import {GenerateResult, GeneratorOptionsComponentInterface} from "@/types/generator"; | ||
import {ExportValueType, Sex} from "@/constants/enums"; | ||
import {faker} from "@faker-js/faker"; | ||
import {FormattedMessage} from "@/locale"; | ||
import {OptionsSelect} from "@/components/Utils"; | ||
import {SexSelectOptions} from "@/core/common/selectOptions/SexSelectOptions"; | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// types | ||
export interface FirstNameGeneratorOptions { | ||
sex: Sex; | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// default options | ||
export const FirstNameGeneratorDefaultOptions:FirstNameGeneratorOptions = { | ||
sex: Sex.ALL | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// generate method | ||
export const generate = (options: any): GenerateResult => { | ||
let config = null; | ||
if(options.sex !== Sex.ALL ){ | ||
config = options.sex; | ||
} | ||
|
||
const value = faker.person.firstName(config); | ||
|
||
return { | ||
value: value, | ||
stringValue: value, | ||
type: ExportValueType.STRING | ||
}; | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// options component | ||
export const FirstNameGeneratorOptionsComponent: React.FunctionComponent<GeneratorOptionsComponentInterface> = ({...props}) => { | ||
const {options, onOptionsChange} = props; | ||
|
||
const handleOptionsChange = (changedFieldName: string, value: any) => { | ||
let newOptions = {...options, [changedFieldName]: value}; | ||
onOptionsChange(newOptions); | ||
}; | ||
|
||
return ( | ||
<> | ||
<OptionsSelect | ||
label={<FormattedMessage id={"dataType.fullName.sex.label"}/>} | ||
selectOptions={SexSelectOptions} | ||
value={options.sex} | ||
style={{width: '150px'}} | ||
onChange={(v) => handleOptionsChange("sex", v)}/> | ||
</> | ||
); | ||
} |
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,13 @@ | ||
import {Generator} from "@/types/generator"; | ||
import {DataType, DataTypeCategory} from "@/constants/enums"; | ||
import {FirstNameGeneratorDefaultOptions, FirstNameGeneratorOptionsComponent, generate} from "./FirstName"; | ||
|
||
export const FirstNameGenerator: Generator = { | ||
type: DataType.FIRSTNAME, | ||
category: DataTypeCategory.PERSON, | ||
generate: generate, | ||
optionsComponent: FirstNameGeneratorOptionsComponent, | ||
defaultOptions: FirstNameGeneratorDefaultOptions, | ||
exampleLines: ["Javier", "Luis", "Tom"] | ||
} | ||
|
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,58 @@ | ||
import React from "react"; | ||
import {GenerateResult, GeneratorOptionsComponentInterface} from "@/types/generator"; | ||
import {ExportValueType, Sex} from "@/constants/enums"; | ||
import {faker} from "@faker-js/faker"; | ||
import {OptionsSelect} from "@/components/Utils"; | ||
import {FormattedMessage} from "@/locale"; | ||
import {SexSelectOptions} from "@/core/common/selectOptions/SexSelectOptions"; | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// types | ||
export interface LastNameGeneratorOptions { | ||
sex: Sex; | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// default options | ||
export const LastNameGeneratorDefaultOptions:LastNameGeneratorOptions = { | ||
sex: Sex.ALL | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// generate method | ||
export const generate = (options: any): GenerateResult => { | ||
let config = null; | ||
if(options.sex !== Sex.ALL ){ | ||
config = options.sex; | ||
} | ||
|
||
const value = faker.person.lastName(config); | ||
|
||
return { | ||
value: value, | ||
stringValue: value, | ||
type: ExportValueType.STRING | ||
}; | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// options component | ||
export const LastNameGeneratorOptionsComponent: React.FunctionComponent<GeneratorOptionsComponentInterface> = ({...props}) => { | ||
const {options, onOptionsChange} = props; | ||
|
||
const handleOptionsChange = (changedFieldName: string, value: any) => { | ||
let newOptions = {...options, [changedFieldName]: value}; | ||
onOptionsChange(newOptions); | ||
} | ||
|
||
return ( | ||
<> | ||
<OptionsSelect | ||
label={<FormattedMessage id={"dataType.fullName.sex.label"}/>} | ||
selectOptions={SexSelectOptions} | ||
value={options.sex} | ||
style={{width: '150px'}} | ||
onChange={(v) => handleOptionsChange("sex", v)}/> | ||
</> | ||
); | ||
} |
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,13 @@ | ||
import {Generator} from "@/types/generator"; | ||
import {DataType, DataTypeCategory} from "@/constants/enums"; | ||
import {LastNameGeneratorDefaultOptions, LastNameGeneratorOptionsComponent, generate} from "./LastName"; | ||
|
||
export const LastNameGenerator: Generator = { | ||
type: DataType.LASTNAME, | ||
category: DataTypeCategory.PERSON, | ||
generate: generate, | ||
optionsComponent: LastNameGeneratorOptionsComponent, | ||
defaultOptions: LastNameGeneratorDefaultOptions, | ||
exampleLines: ["Hegmann", "Parker", "Wang"] | ||
} | ||
|
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,58 @@ | ||
import React from "react"; | ||
import {GenerateResult, GeneratorOptionsComponentInterface} from "@/types/generator"; | ||
import {ExportValueType, Sex} from "@/constants/enums"; | ||
import {faker} from "@faker-js/faker"; | ||
import {OptionsSelect} from "@/components/Utils"; | ||
import {FormattedMessage} from "@/locale"; | ||
import {SexSelectOptions} from "@/core/common/selectOptions/SexSelectOptions"; | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// types | ||
export interface MiddleNameGeneratorOptions { | ||
sex: Sex; | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// default options | ||
export const MiddleNameGeneratorDefaultOptions:MiddleNameGeneratorOptions = { | ||
sex: Sex.ALL | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// generate method | ||
export const generate = (options: any): GenerateResult => { | ||
let config = null; | ||
if(options.sex !== Sex.ALL ){ | ||
config = options.sex; | ||
} | ||
|
||
const value = faker.person.middleName(config); | ||
|
||
return { | ||
value: value, | ||
stringValue: value, | ||
type: ExportValueType.STRING | ||
}; | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------------------- | ||
// options component | ||
export const MiddleNameGeneratorOptionsComponent: React.FunctionComponent<GeneratorOptionsComponentInterface> = ({...props}) => { | ||
const {options, onOptionsChange} = props; | ||
|
||
const handleOptionsChange = (changedFieldName: string, value: any) => { | ||
let newOptions = {...options, [changedFieldName]: value}; | ||
onOptionsChange(newOptions); | ||
}; | ||
|
||
return ( | ||
<> | ||
<OptionsSelect | ||
label={<FormattedMessage id={"dataType.fullName.sex.label"}/>} | ||
selectOptions={SexSelectOptions} | ||
value={options.sex} | ||
style={{width: '150px'}} | ||
onChange={(v) => handleOptionsChange("sex", v)}/> | ||
</> | ||
); | ||
} |
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,13 @@ | ||
import {Generator} from "@/types/generator"; | ||
import {DataType, DataTypeCategory} from "@/constants/enums"; | ||
import {MiddleNameGeneratorDefaultOptions, MiddleNameGeneratorOptionsComponent, generate} from "./MiddleName"; | ||
|
||
export const MiddleNameGenerator: Generator = { | ||
type: DataType.MIDDLENAME, | ||
category: DataTypeCategory.PERSON, | ||
generate: generate, | ||
optionsComponent: MiddleNameGeneratorOptionsComponent, | ||
defaultOptions: MiddleNameGeneratorDefaultOptions, | ||
exampleLines: ["Elliott", "Taylor", "Bailey"] | ||
} | ||
|
Oops, something went wrong.
69fae02
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
dummyi – ./
dummyi.vercel.app
www.dummyi.com
dummyi-git-master-zachstrives.vercel.app
dummyi-zachstrives.vercel.app
dummyi.com