2019-10-16 15:18:29 +00:00
import Card from "@material-ui/core/Card" ;
import CardContent from "@material-ui/core/CardContent" ;
2019-10-21 12:05:36 +00:00
import Typography from "@material-ui/core/Typography" ;
2019-10-16 15:18:29 +00:00
import React from "react" ;
2019-10-21 12:05:36 +00:00
import { FormattedMessage , useIntl } from "react-intl" ;
2019-10-16 15:18:29 +00:00
import CardTitle from "@saleor/components/CardTitle" ;
2019-10-21 12:05:36 +00:00
import FormSpacer from "@saleor/components/FormSpacer" ;
2019-10-16 15:18:29 +00:00
import { Locale , localeNames } from "@saleor/components/Locale" ;
import SingleAutocompleteSelectField from "@saleor/components/SingleAutocompleteSelectField" ;
2019-10-18 12:29:01 +00:00
import { capitalize } from "@saleor/misc" ;
2019-10-16 15:18:29 +00:00
interface StaffPreferencesProps {
locale : Locale ;
onLocaleChange : ( locale : Locale ) = > void ;
}
2019-10-21 12:05:55 +00:00
const StaffPreferences : React.FC < StaffPreferencesProps > = ( {
2019-10-16 15:18:29 +00:00
locale ,
onLocaleChange
} ) = > {
const intl = useIntl ( ) ;
return (
< Card >
< CardTitle
title = { intl . formatMessage ( {
defaultMessage : "Preferences" ,
description : "section header"
} ) }
/ >
< CardContent >
< SingleAutocompleteSelectField
choices = { Object . values ( Locale ) . map ( locale = > ( {
2019-10-18 12:29:01 +00:00
label : capitalize ( localeNames [ locale ] ) ,
2019-10-16 15:18:29 +00:00
value : locale
} ) ) }
displayValue = { localeNames [ locale ] }
helperText = { intl . formatMessage ( {
defaultMessage :
"Selecting this will change the language of your dashboard"
} ) }
label = { intl . formatMessage ( {
defaultMessage : "Preferred Language"
} ) }
name = "locale"
value = { locale }
onChange = { event = > onLocaleChange ( event . target . value ) }
/ >
2019-10-21 12:05:36 +00:00
< FormSpacer / >
< Typography >
< FormattedMessage defaultMessage = "Please note, while all currency and date adjustments are complete, language translations are at varying degrees of completion." / >
< / Typography >
2019-10-16 15:18:29 +00:00
< / CardContent >
< / Card >
) ;
} ;
StaffPreferences . displayName = "StaffPreferences" ;
export default StaffPreferences ;