Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ import { AppRoutes } from '@/routes/AppRoutes';
import { ThemeProvider } from '@/contexts/ThemeContext';
import QueryClientProviders from '@/config/QueryClientProvider';
import { GlobalLoader } from './components/Loader/GlobalLoader';
import { InfoDialog } from './components/Dialog/InfoDialog';
import { useSelector } from 'react-redux';
import { RootState } from './app/store';
const App: React.FC = () => {
const { loading, message } = useSelector((state: RootState) => state.loader);
const { isOpen, title, message: infoMessage } = useSelector((state: RootState) => state.infoDialog);
return (
<ThemeProvider>
<QueryClientProviders>
<BrowserRouter>
<AppRoutes />
</BrowserRouter>
<GlobalLoader loading={loading} message={message} />
<InfoDialog isOpen={isOpen} title={title} message={infoMessage} />
</QueryClientProviders>
</ThemeProvider>
);
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/app/store.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { configureStore } from '@reduxjs/toolkit';
import loaderReducer from '@/features/loaderSlice';
import onboardingReducer from '@/features/onboardingSlice';
import infoDialogReducer from '@/features/infoDialogSlice';

export const store = configureStore({
reducer: {
loader: loaderReducer,
onboarding: onboardingReducer,
infoDialog: infoDialogReducer,
},
});

Expand Down
49 changes: 49 additions & 0 deletions frontend/src/components/Dialog/InfoDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { Info } from 'lucide-react';
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogFooter
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { InfoDialogProps } from '@/types/infoDialog';
import { useDispatch } from 'react-redux';
import { hideInfoDialog } from '@/features/infoDialogSlice';

export const InfoDialog: React.FC<InfoDialogProps> = ({
isOpen,
title,
message
}) => {
const dispatch = useDispatch();

const handleClose = () => {
dispatch(hideInfoDialog());
};

return (
<Dialog open={isOpen} onOpenChange={(open) => {
if (!open) handleClose();
}}>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<Info className="h-5 w-5 text-primary" />
{title}
</DialogTitle>
<DialogDescription>
{message}
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button onClick={handleClose}>
Close
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
};
33 changes: 33 additions & 0 deletions frontend/src/features/infoDialogSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface InfoDialogState {
isOpen: boolean;
title: string;
message: string;
}

const initialState: InfoDialogState = {
isOpen: false,
title: '',
message: '',
};

const infoDialogSlice = createSlice({
name: 'infoDialog',
initialState,
reducers: {
showInfoDialog(state, action: PayloadAction<{ title: string; message: string }>) {
state.isOpen = true;
state.title = action.payload.title;
state.message = action.payload.message;
},
hideInfoDialog(state) {
state.isOpen = false;
state.title = '';
state.message = '';
},
},
});

export const { showInfoDialog, hideInfoDialog } = infoDialogSlice.actions;
export default infoDialogSlice.reducer;
7 changes: 7 additions & 0 deletions frontend/src/pages/SettingsPage/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { usePictoMutation } from '@/hooks/useQueryExtensio';

import { useDispatch } from 'react-redux';
import { showLoader, hideLoader } from '@/features/loaderSlice';
import { showInfoDialog } from '@/features/infoDialogSlice';

import {
deleteFolder,
Expand Down Expand Up @@ -84,6 +85,12 @@ const Settings: React.FC = () => {
const hasUpdate = await checkForUpdates();
if (hasUpdate) {
setUpdateDialogOpen(true);
} else {
// Show info dialog when no updates are available
dispatch(showInfoDialog({
title: 'No Updates Available',
message: 'Your application is already up to date with the latest version.'
}));
}
dispatch(hideLoader());
};
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/types/infoDialog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface InfoDialogProps {
isOpen: boolean;
title: string;
message: string;
}
Loading