Commit 1e0eff13 authored by janithgamage1.ed's avatar janithgamage1.ed

fix: update

Desc : update project
parent 93fc9979
......@@ -16,7 +16,7 @@ const commonFields = {
const taskItemSchema = new mongoose.Schema({
title: String,
description: String,
howToDo: String,
howToDo: [String],
referenceImage: String,
referenceVideo: String,
taskItemMark : {
......
......@@ -183,18 +183,21 @@ export const tutorials: tutorialType[] = [
]
export const tutorialReqOb: Tutorial = {
"tutorialCode": "Tutorial Code -12312",
"tutorialTitle": "Tutorial Title",
"tutorialImage": "Tutorial Image",
"tutorialDescription": "Tutorial Description",
"tutorialCode": "01-SAMPLE",
"tutorialTitle": "Numbers and Counting in Sign Language",
"tutorialImage": "https://drive.google.com/uc?export=view&id=1GeFzoy3xt8UnfCQE3IPVjPXoAg7GAWgf",
"tutorialDescription": "In this tutorial, you'll discover how to express numbers visually using simple hand gestures. Each number has a unique sign that involves specific finger placements and hand movements. We'll break down each number step by step, providing you with clear instructions, images, and videos to help you learn effectively.",
"taskItems": [
{
"title": "Task Title -213123",
"description": "Task Reference Image",
//@ts-ignore
"howToDo": "Task How To Do",
"referenceImage": "Task Reference Image",
"referenceVideo": "Task Reference Image",
"title": "Learn Number One",
"description": "In this lesson, you will learn how to sign the number one. Understanding this basic sign is crucial for counting and expressing singular items or concepts in sign language. Practice the hand shape, movement, and facial expression associated with the sign to improve your fluency.",
"howToDo": [
"- Extend your index finger straight up.",
"- Keep the rest of your fingers closed.",
"- Hold your hand in front of your chest."
],
"referenceImage": "https://drive.google.com/uc?export=view&id=17sHGfW9zip8xAwbRtUihzxkseKq-Qn7q",
"referenceVideo": "",
"taskItemMark": 10
}
],
......
......@@ -278,7 +278,7 @@ const List = () => {
[
{
Header: '#',
accessor: 'id',
accessor: '_id',
className: 'cell-center',
Cell: ({ row }: { row: Row }) => {
if (row.id === undefined || row.id === null || row.id === '') {
......@@ -378,6 +378,7 @@ const List = () => {
color="error"
onClick={(e: MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
setTutorialTitle(row.values.tutorialTitle)
setTutorialId(row.values._id)
setOpenAlert(true)
}}
......@@ -405,7 +406,8 @@ const List = () => {
//alert model
const [openAlert, setOpenAlert] = useState(false);
const [tutorialId, setTutorialId] = useState<number | string | undefined>(undefined)
const [tutorialId, setTutorialId] = useState<string | undefined>(undefined)
const [tutorialTitle, setTutorialTitle] = useState<string | undefined>(undefined)
const handleAlertClose = () => {
setOpenAlert(!openAlert);
......@@ -420,6 +422,8 @@ const List = () => {
}, [dispatch]);
useEffect(() => {
console.log(tutorials);
setData(tutorials);
}, [tutorials])
......@@ -484,7 +488,7 @@ const List = () => {
<AddEditTutorial tutorial={tutorial!} onCancel={handleAddEdit} />
</Dialog>
{/* alert model */}
{!tutorial && <AlertTutorialDelete title={""} open={openAlert} handleClose={handleAlertClose} deleteId={tutorialId} />}
{!tutorial && <AlertTutorialDelete title={tutorialTitle!} open={openAlert} handleClose={handleAlertClose} deleteId={tutorialId} />}
</MainCard>
</>
)
......
......@@ -32,7 +32,7 @@ import IconButton from 'components/@extended/IconButton';
import { DeleteFilled } from '@ant-design/icons';
import { AccordionSummary, InputLabel, TextField } from '@mui/material';
import MainCard from 'components/MainCard';
import { tutorialReqOb } from 'data/tutorials';
import useAuth from 'hooks/useAuth';
import { dispatch } from 'store';
import { addTutorial } from 'store/reducers/tutorial';
import { Tutorial } from 'types/tutorial';
......@@ -78,29 +78,30 @@ export interface Props {
const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
const theme = useTheme();
const { user } = useAuth();
const isCreating = !tutorial;
const TutorialSchema = Yup.object().shape({
// tutorialCode: Yup.string().required(`Tutorial Code is required`),
// tutorialTitle: Yup.string().required(`Tutorial Title is required`),
// tutorialDescription: Yup.string().required(`Tutorial Description is required`),
// tutorialImage: Yup.string().required(`Tutorial Image Ref is required`),
// taskItems: Yup.array().of(
// Yup.object().shape({
// title: Yup.string().required(`Task Title is required`),
// description: Yup.string().required(`Task Description is required`),
// howToDo: Yup.string().required(`Task How To Do is required`),
// referenceImage: Yup.string().required(`Task Reference Image is required`),
// referenceVideo: Yup.string(),
// taskItemMark: Yup.number().required(`Task Mark is required`).min(1, 'Task Mark must be greater than 0'),
// })
// ).required(`Tutorial Task Item is required`),
// status: Yup.number(),
// createdBy: Yup.string(),
// createdAt: Yup.date(),
// updatedBy: Yup.string(),
// updatedAt: Yup.date(),
tutorialCode: Yup.string().required(`Tutorial Code is required`),
tutorialTitle: Yup.string().required(`Tutorial Title is required`),
tutorialDescription: Yup.string().required(`Tutorial Description is required`),
tutorialImage: Yup.string().required(`Tutorial Image Ref is required`),
taskItems: Yup.array().of(
Yup.object().shape({
title: Yup.string().required(`Task Title is required`),
description: Yup.string().required(`Task Description is required`),
howToDo: Yup.string().required(`Task How To Do is required`),
referenceImage: Yup.string().required(`Task Reference Image is required`),
referenceVideo: Yup.string(),
taskItemMark: Yup.number().required(`Task Mark is required`).min(1, 'Task Mark must be greater than 0'),
})
).required(`Tutorial Task Item is required`),
status: Yup.number(),
createdBy: Yup.string(),
createdAt: Yup.date(),
updatedBy: Yup.string(),
updatedAt: Yup.date(),
});
const [openAlert, setOpenAlert] = useState(false);
......@@ -119,13 +120,23 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
if (tutorial) {
// PUT API
} else {
// POST API
//@ts-ignore
// const req: Tutorial = { ...values }
const sampleReq: Tutorial = tutorialReqOb
// POST API
// const dummyObject: Tutorial = tutorialReqOb
// dispatch(addTutorial(dummyObject))
//@ts-ignore
dispatch(addTutorial(sampleReq))
const req: Tutorial = {
tutorialCode: values.tutorialCode,
tutorialTitle: values.tutorialTitle,
tutorialImage: values.tutorialImage,
tutorialDescription: values.tutorialDescription,
taskItems: values.taskItems.map((item) => ({
...item,
howToDo: item.howToDo.split(','), // Split the comma-separated string into an array
})),
createdBy: user?.name!,
};
dispatch(addTutorial(req))
}
resetForm()
setSubmitting(false);
......
......@@ -7,20 +7,22 @@ import { PopupTransition } from 'components/@extended/Transitions';
// assets
import { DeleteFilled } from '@ant-design/icons';
import { useDispatch } from 'store';
import { deleteTutorial } from 'store/reducers/tutorial';
// types
interface Props {
title: string;
open: boolean;
handleClose: (status: boolean) => void;
deleteId: number | string | undefined;
deleteId: string | undefined;
}
// ==============================|| Tutorial - DELETE ||============================== //
export default function AlertTutorialDelete({ title, open, handleClose, deleteId }: Props) {
// const dispatch = useDispatch();
const dispatch = useDispatch();
return (
<Dialog
......@@ -41,6 +43,14 @@ export default function AlertTutorialDelete({ title, open, handleClose, deleteId
<Typography variant="h4" align="center">
Are you sure you want to delete?
</Typography>
<Typography align="center">
By deleting
<Typography variant="subtitle1" component="span">
{' '}
"{title}"{' '}
</Typography>
tutorial, Its details & tasks will also be deleted.
</Typography>
</Stack>
<Stack direction="row" spacing={2} sx={{ width: 1 }}>
......@@ -48,7 +58,7 @@ export default function AlertTutorialDelete({ title, open, handleClose, deleteId
Cancel
</Button>
<Button fullWidth color="error" variant="contained" onClick={() => {
// dispatch(deleteNutrition(deleteId!))
dispatch(deleteTutorial(deleteId!))
handleClose(true)
}} autoFocus>
Delete
......
......@@ -70,8 +70,8 @@ const slice = createSlice({
},
// DELETE TUTORIAL
deleteTutorialSuccess(state, action) {
state.tutorials = state.tutorials.filter(tutorial => tutorial._id !== action.payload._id);
deleteTutorialSuccess(state, action) {
state.tutorials = state.tutorials.filter(tutorial => tutorial._id !== action.payload);
state.success = "Tutorial deleted successfully."
},
......@@ -177,7 +177,7 @@ export function updateTutorial(updatedTutorial: Tutorial) {
* @param tutorialId
* @returns
*/
export function deleteTutorial(tutorialId: number) {
export function deleteTutorial(tutorialId: string) {
return async () => {
dispatch(slice.actions.startLoading());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment