Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Godefroy committed Jul 10, 2024
1 parent 060dd39 commit edbd793
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 18 deletions.
4 changes: 4 additions & 0 deletions nhost/metadata/databases/default/tables/public_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ update_permissions:
event_triggers:
- name: index-role
definition:
delete:
columns: '*'
enable_manual: false
insert:
columns: '*'
update:
columns: '*'
retry_conf:
Expand Down
2 changes: 1 addition & 1 deletion nhost/nhost.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ memory = 1536
version = 18

[auth]
version = '0.32.0'
version = '0.32.1'

[auth.resources]
replicas = 1
Expand Down
21 changes: 16 additions & 5 deletions packages/webapp/src/features/common/atoms/NumberInput.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import {
NumberInput as NbInput,
NumberInputProps as NbInputProps,
NumberDecrementStepper,
NumberIncrementStepper,
NumberInputField,
NumberInputProps,
NumberInputStepper,
} from '@chakra-ui/react'
import React, { useEffect, useState } from 'react'
import { ChevronDownIcon, ChevronUpIcon } from 'src/icons'

interface Props extends Omit<NumberInputProps, 'onChange'> {
export interface NumberInputProps extends Omit<NbInputProps, 'onChange'> {
onChange(value: number): void
}

export default function NumberInput({ onChange, value, ...inputProps }: Props) {
export default function NumberInput({
onChange,
value,
...inputProps
}: NumberInputProps) {
const [tmpValue, setTmpValue] = useState<string | number | undefined>(value)

useEffect(() => {
Expand All @@ -26,12 +31,18 @@ export default function NumberInput({ onChange, value, ...inputProps }: Props) {
}
}

const iconSize = inputProps.size === 'sm' ? 12 : 16

return (
<NbInput value={tmpValue} onChange={handleChange} {...inputProps}>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
<NumberIncrementStepper>
<ChevronUpIcon size={iconSize} />
</NumberIncrementStepper>
<NumberDecrementStepper>
<ChevronDownIcon size={iconSize} />
</NumberDecrementStepper>
</NumberInputStepper>
</NbInput>
)
Expand Down
19 changes: 9 additions & 10 deletions packages/webapp/src/features/user/components/LangSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useChangeLocaleMutation } from '@gql'
import { useUserId } from '@nhost/react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { langs, locales } from 'src/i18n'
import { getLocale, langs, locales } from 'src/i18n'
import { ChevronDownIcon } from 'src/icons'
import { nhost } from 'src/nhost'

Expand All @@ -21,22 +21,21 @@ export default function LangSelect(styleProps: StyleProps) {
i18n: { language, changeLanguage },
} = useTranslation()
const userId = useUserId()
const currentLocale = locales[language as keyof typeof locales] || {
emoji: '❓',
name: 'Language',
}
const currentLocale = getLocale(language)

// Mutations
const [changeLocale] = useChangeLocaleMutation()

const handleClick = async (locale: string) => {
if (!userId) return
// Change i18n locale
changeLanguage(locale)
// Change user locale in DB
await changeLocale({ variables: { userId, locale } })
// Refresh user data
await nhost.auth.refreshSession()

if (userId) {
// Change user locale in DB
await changeLocale({ variables: { userId, locale } })
// Refresh user data
await nhost.auth.refreshSession()
}
}

return (
Expand Down
6 changes: 4 additions & 2 deletions packages/webapp/src/features/user/modals/CurrentUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export default function CurrentUserModal(modalProps: UseModalProps) {
{...register('name')}
autoFocus
autoComplete="off"
data-lpignore="true"
data-lpignore
data-1p-ignore
/>
</FormControl>

Expand All @@ -134,7 +135,8 @@ export default function CurrentUserModal(modalProps: UseModalProps) {
type="email"
placeholder={t('CurrentUserModal.emailPlaceholder')}
autoComplete="off"
data-lpignore="true"
data-lpignore
data-1p-ignore
/>
</FormControl>

Expand Down
14 changes: 14 additions & 0 deletions packages/webapp/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ i18n
export default i18n
export const locales = resources
export const langs = Object.keys(locales) as Array<keyof typeof locales>

export function getLocale(lang: string) {
if (lang in locales) {
return locales[lang as keyof typeof locales]
}
const shortLang = lang.split('-')[0]
if (shortLang in locales) {
return locales[shortLang as keyof typeof locales]
}
return {
emoji: '',
name: 'Language',
}
}

0 comments on commit edbd793

Please sign in to comment.