@@ -2,6 +2,7 @@ import { useCallback } from "react";
22import { useTheme } from "next-themes" ;
33import { Calendar , Earth , Languages , Palette } from "lucide-react" ;
44// plane imports
5+ import { useTranslation } from "@plane/i18n" ;
56import { setToast , TOAST_TYPE } from "@plane/propel/toast" ;
67import type { EStartOfTheWeek , TUserProfile } from "@plane/types" ;
78// components
@@ -17,17 +18,29 @@ export const usePowerKPreferencesCommands = (): TPowerKCommandConfig[] => {
1718 const { setTheme } = useTheme ( ) ;
1819 const { updateCurrentUser } = useUser ( ) ;
1920 const { updateUserProfile, updateUserTheme } = useUserProfile ( ) ;
21+ // translation
22+ const { t } = useTranslation ( ) ;
2023
2124 const handleUpdateTheme = useCallback (
2225 async ( newTheme : string ) => {
2326 setTheme ( newTheme ) ;
24- return updateUserTheme ( { theme : newTheme } ) . catch ( ( ) => {
25- setToast ( {
26- type : TOAST_TYPE . ERROR ,
27- title : "Failed to save user theme settings!" ,
27+ return updateUserTheme ( { theme : newTheme } )
28+ . then ( ( ) => {
29+ setToast ( {
30+ type : TOAST_TYPE . SUCCESS ,
31+ title : t ( "toast.success" ) ,
32+ message : t ( "power_k.preferences_actions.toast.theme.success" ) ,
33+ } ) ;
34+ } )
35+ . catch ( ( ) => {
36+ setToast ( {
37+ type : TOAST_TYPE . ERROR ,
38+ title : t ( "toast.error" ) ,
39+ message : t ( "power_k.preferences_actions.toast.theme.error" ) ,
40+ } ) ;
2841 } ) ;
29- } ) ;
3042 } ,
43+ // eslint-disable-next-line react-hooks/exhaustive-deps
3144 [ setTheme , updateUserTheme ]
3245 ) ;
3346
@@ -36,19 +49,20 @@ export const usePowerKPreferencesCommands = (): TPowerKCommandConfig[] => {
3649 updateCurrentUser ( { user_timezone : value } )
3750 . then ( ( ) => {
3851 setToast ( {
39- title : "Success!" ,
40- message : "Timezone updated successfully" ,
4152 type : TOAST_TYPE . SUCCESS ,
53+ title : t ( "toast.success" ) ,
54+ message : t ( "power_k.preferences_actions.toast.timezone.success" ) ,
4255 } ) ;
4356 } )
4457 . catch ( ( ) => {
4558 setToast ( {
46- title : "Error!" ,
47- message : "Failed to update timezone" ,
4859 type : TOAST_TYPE . ERROR ,
60+ title : t ( "toast.error" ) ,
61+ message : t ( "power_k.preferences_actions.toast.timezone.error" ) ,
4962 } ) ;
5063 } ) ;
5164 } ,
65+ // eslint-disable-next-line react-hooks/exhaustive-deps
5266 [ updateCurrentUser ]
5367 ) ;
5468
@@ -57,19 +71,20 @@ export const usePowerKPreferencesCommands = (): TPowerKCommandConfig[] => {
5771 updateUserProfile ( payload )
5872 . then ( ( ) => {
5973 setToast ( {
60- title : "Success!" ,
61- message : "Language updated successfully" ,
6274 type : TOAST_TYPE . SUCCESS ,
75+ title : t ( "toast.success" ) ,
76+ message : t ( "power_k.preferences_actions.toast.generic.success" ) ,
6377 } ) ;
6478 } )
6579 . catch ( ( ) => {
6680 setToast ( {
67- title : "Error!" ,
68- message : "Failed to update language" ,
6981 type : TOAST_TYPE . ERROR ,
82+ title : t ( "toast.error" ) ,
83+ message : t ( "power_k.preferences_actions.toast.generic.error" ) ,
7084 } ) ;
7185 } ) ;
7286 } ,
87+ // eslint-disable-next-line react-hooks/exhaustive-deps
7388 [ updateUserProfile ]
7489 ) ;
7590
0 commit comments