Skip to content

Commit

Permalink
feat: add control btns
Browse files Browse the repository at this point in the history
  • Loading branch information
LinaYahya committed Jul 4, 2024
1 parent 048333c commit d90e1cf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/langs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export const APP = {
REPLACE_IMAGE: 'REPLACE_IMAGE',
ADD: 'ADD',
DRAG_DROP_EXERCISE_TITLE: 'DRAG_DROP_EXERCISE_TITLE',
SAVE: 'SAVE',
};
3 changes: 2 additions & 1 deletion src/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"BACK": "Back",
"REPLACE_IMAGE": "Replace the image",
"ADD": "Add",
"DRAG_DROP_EXERCISE_TITLE": "Drag and drop these labels into the correct frame of the image"
"DRAG_DROP_EXERCISE_TITLE": "Drag and drop these labels into the correct frame of the image",
"SAVE": "Save"
}
2 changes: 1 addition & 1 deletion src/modules/builder/configuration/AddImageStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const AddImageStep = ({ moveToNextStep }: Props): JSX.Element => {
const [description, setDescription] = useState<string>('');

const saveData = (): void => {
const newData = { description };
const newData = { ...(settings && settings.data), description };

saveSettings(SettingsKeys.SettingsData, newData);
moveToNextStep();
Expand Down
18 changes: 16 additions & 2 deletions src/modules/builder/configuration/PreviewStep/PreviewStep.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { DragDropContext, DropResult } from 'react-beautiful-dnd';

import { Box, Stack, Typography } from '@mui/material';
import { Box, Button, Stack, Typography } from '@mui/material';

import { DraggableLabel, Settings, SettingsKeys } from '@/@types';
import {
Expand Down Expand Up @@ -139,13 +139,19 @@ const PreviewImage = (): JSX.Element => {
</Box>
);
};
const PreviewStep = (): JSX.Element => {

const PreviewStep = ({
moveToPrevStep,
}: {
moveToPrevStep: () => void;
}): JSX.Element => {
const { data: appContext } = hooks.useAppContext();

const { data: appSettings } = hooks.useAppSettings<Settings>({
name: SettingsKeys.SettingsData,
});

const { t } = useAppTranslation();
return (
<Stack spacing={2} padding={2}>
<Box>
Expand All @@ -157,6 +163,14 @@ const PreviewStep = (): JSX.Element => {
</Typography>
</Box>
<PreviewImage />
<Stack direction="row" gap={1} width="100%" justifyContent="flex-end">
<Button size="large" onClick={moveToPrevStep}>
{t(APP.BACK)}
</Button>
<Button variant="contained" size="large">
{t(APP.SAVE)}
</Button>
</Stack>
</Stack>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/modules/builder/configuration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Configurations = (): JSX.Element => {
},
{
label: t(APP.PREVIEW_STEP_LABEL),
component: <PreviewStep />,
component: <PreviewStep moveToPrevStep={() => setActiveStep(1)} />,
disabled: !settingsData?.data.labels || !image?.id,
},
];
Expand Down

0 comments on commit d90e1cf

Please sign in to comment.