simplify star prompt translations and state

This commit is contained in:
mohadeseh safari committed 2025-03-10 14:23:09 -04:00
1 parent c185979479
commit 0f2832b728
4 files changed
+14 -15

No files matched your search

+6 -6
View File
@@ -4,7 +4,7 @@ import CloseIcon from '@mui/icons-material/Close';
import { useTheme } from '@emotion/react';
import { useSelector, useDispatch } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { setStarPromptClosed } from '../../Features/UI/uiSlice';
import { setStarPromptOpen } from '../../Features/UI/uiSlice';
const StarPrompt = ({
repoUrl = 'https://github.com/bluewave-labs/checkmate'
@@ -12,18 +12,18 @@ const StarPrompt = ({
const theme = useTheme();
const dispatch = useDispatch();
const { t } = useTranslation();
const isClosed = useSelector((state) => state.ui?.starPrompt?.closed ?? false);
const isOpen = useSelector((state) => state.ui?.starPromptOpen ?? true);
const mode = useSelector((state) => state.ui.mode);
const handleClose = () => {
dispatch(setStarPromptClosed(true));
dispatch(setStarPromptOpen(false));
};
const handleStarClick = () => {
window.open(repoUrl, '_blank');
};
if (isClosed) return null;
if (!isOpen) return null;
return (
<Stack
@@ -46,7 +46,7 @@ const StarPrompt = ({
mt: theme.spacing(3)
}}
>
{t('starPrompt.title')}
{t('starPromptTitle')}
</Typography>
<IconButton
onClick={handleClose}
@@ -75,7 +75,7 @@ const StarPrompt = ({
px: theme.spacing(4)
}}
>
{t('starPrompt.description')}
{t('starPromptDescription')}
</Typography>
<Box
+4 -9
View File
@@ -24,9 +24,7 @@ const initialState = {
timezone: "America/Toronto",
distributedUptimeEnabled: false,
language: "gb",
starPrompt: {
closed: false
},
starPromptOpen: true,
};
const uiSlice = createSlice({
@@ -58,11 +56,8 @@ const uiSlice = createSlice({
setLanguage(state, action) {
state.language = action.payload;
},
setStarPromptClosed(state, action) {
if (!state.starPrompt) {
state.starPrompt = {};
}
state.starPrompt.closed = action.payload;
setStarPromptOpen: (state, action) => {
state.starPromptOpen = action.payload;
},
},
});
@@ -76,5 +71,5 @@ export const {
setTimezone,
setDistributedUptimeEnabled,
setLanguage,
setStarPromptClosed,
setStarPromptOpen,
} = uiSlice.actions;
+2
View File
@@ -108,6 +108,8 @@
"settingsFailedToAddDemoMonitors": "Failed to add demo monitors",
"settingsMonitorsDeleted": "Successfully deleted all monitors",
"settingsFailedToDeleteMonitors": "Failed to delete all monitors",
"starPromptTitle": "Star Checkmate",
"starPromptDescription": "See the latest releases and help grow the community on GitHub",
"starPrompt": {
"title": "Star Checkmate",
"description": "See the latest releases and help grow the community on GitHub"
+2
View File
@@ -102,6 +102,8 @@
"settingsFailedToAddDemoMonitors": "Demo monitörler eklenemedi",
"settingsMonitorsDeleted": "Tüm monitörler başarıyla silindi",
"settingsFailedToDeleteMonitors": "Monitörler silinemedi",
"starPromptTitle": "Checkmate yıldızla değerlendirin",
"starPromptDescription": "En son sürümleri görün ve GitHub'daki topluluğun büyümesine yardımcı olun",
"starPrompt": {
"title": "Checkmate yıldızla değerlendirin",
"description": "En son sürümleri görün ve GitHub'daki topluluğun büyümesine yardımcı olun"