Skip to content

Commit

Permalink
fix: move bool/select value translations to labels (#1609)
Browse files Browse the repository at this point in the history
* fix: move bool/select value translations to labels

* chore: update form link
  • Loading branch information
dziraf authored Jan 23, 2024
1 parent 1800d2d commit 8f4e2f2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/frontend/components/app/default-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export const Dashboard: React.FC = () => {
<Button
as="a"
variant="contained"
href="https://share.hsforms.com/1IedvmEz6RH2orhcL6g2UHA8oc5a"
href="https://forms.adminjs.co/"
target="_blank"
>
{translateButton('contactUs')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import allowOverride from '../../../hoc/allow-override.js'
const BooleanPropertyValue: React.FC<ShowPropertyProps> = (props) => {
const { record, property, resource } = props

const { translateProperty } = useTranslation()
const { tl } = useTranslation()

const rawValue = record?.params[property.path]

if (typeof rawValue === 'undefined' || rawValue === '') {
return null
}
const base = mapValue(rawValue)
const translation = translateProperty(`${property.path}.${rawValue}`, resource.id, {
const translation = tl(`${property.path}.${rawValue}`, resource.id, {
defaultValue: base,
})

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/components/property-type/boolean/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const boolValue = (s: string): boolean => {

const Filter: React.FC<FilterPropertyProps> = (props) => {
const { property, filter = {}, onChange } = props
const { tp } = useTranslation()
const { tl } = useTranslation()
const value = typeof filter[property.path] === 'undefined' ? '' : boolValue(filter[property.path])
const options = [
{ value: true, label: tp(`${property.path}.true`, property.resourceId, { defaultValue: mapValue(true) }) },
{ value: false, label: tp(`${property.path}.false`, property.resourceId, { defaultValue: mapValue(false) }) },
{ value: true, label: tl(`${property.path}.true`, property.resourceId, { defaultValue: mapValue(true) }) },
{ value: false, label: tl(`${property.path}.false`, property.resourceId, { defaultValue: mapValue(false) }) },
]
const selected = options.find((o) => o.value === value)
const handleChange = (s) => {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/property-type/default-type/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Edit: FC<CombinedProps> = (props) => {

const SelectEdit: FC<CombinedProps> = (props) => {
const { record, property, onChange } = props
const { tp } = useTranslation()
const { tl } = useTranslation()
if (!property.availableValues) {
return null
}
Expand All @@ -34,7 +34,7 @@ const SelectEdit: FC<CombinedProps> = (props) => {
// eslint-disable-next-line max-len
const availableValues = property.availableValues.map((v) => ({
...v,
label: tp(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }),
label: tl(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }),
}))
// eslint-disable-next-line eqeqeq
const selected = availableValues.find((av) => av.value == propValue)
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/property-type/default-type/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useTranslation } from '../../../hooks/use-translation.js'

const Filter: React.FC<FilterPropertyProps> = (props) => {
const { property, onChange, filter } = props
const { tp } = useTranslation()
const { tl } = useTranslation()

const handleInputChange = (event) => {
onChange(property.path, event.target.value)
Expand All @@ -25,7 +25,7 @@ const Filter: React.FC<FilterPropertyProps> = (props) => {
if (property.availableValues) {
const availableValues = property.availableValues.map((v) => ({
...v,
label: tp(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }),
label: tl(`${property.path}.${v.value}`, property.resourceId, { defaultValue: v.label ?? v.value }),
}))
const selected = property.availableValues.find((av) => av.value === value)
return (
Expand Down

0 comments on commit 8f4e2f2

Please sign in to comment.