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

fix: update

Desc : update project
parent 93fc9979
...@@ -16,7 +16,7 @@ const commonFields = { ...@@ -16,7 +16,7 @@ const commonFields = {
const taskItemSchema = new mongoose.Schema({ const taskItemSchema = new mongoose.Schema({
title: String, title: String,
description: String, description: String,
howToDo: String, howToDo: [String],
referenceImage: String, referenceImage: String,
referenceVideo: String, referenceVideo: String,
taskItemMark : { taskItemMark : {
......
...@@ -183,18 +183,21 @@ export const tutorials: tutorialType[] = [ ...@@ -183,18 +183,21 @@ export const tutorials: tutorialType[] = [
] ]
export const tutorialReqOb: Tutorial = { export const tutorialReqOb: Tutorial = {
"tutorialCode": "Tutorial Code -12312", "tutorialCode": "01-SAMPLE",
"tutorialTitle": "Tutorial Title", "tutorialTitle": "Numbers and Counting in Sign Language",
"tutorialImage": "Tutorial Image", "tutorialImage": "https://drive.google.com/uc?export=view&id=1GeFzoy3xt8UnfCQE3IPVjPXoAg7GAWgf",
"tutorialDescription": "Tutorial Description", "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": [ "taskItems": [
{ {
"title": "Task Title -213123", "title": "Learn Number One",
"description": "Task Reference Image", "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.",
//@ts-ignore "howToDo": [
"howToDo": "Task How To Do", "- Extend your index finger straight up.",
"referenceImage": "Task Reference Image", "- Keep the rest of your fingers closed.",
"referenceVideo": "Task Reference Image", "- Hold your hand in front of your chest."
],
"referenceImage": "https://drive.google.com/uc?export=view&id=17sHGfW9zip8xAwbRtUihzxkseKq-Qn7q",
"referenceVideo": "",
"taskItemMark": 10 "taskItemMark": 10
} }
], ],
......
...@@ -278,7 +278,7 @@ const List = () => { ...@@ -278,7 +278,7 @@ const List = () => {
[ [
{ {
Header: '#', Header: '#',
accessor: 'id', accessor: '_id',
className: 'cell-center', className: 'cell-center',
Cell: ({ row }: { row: Row }) => { Cell: ({ row }: { row: Row }) => {
if (row.id === undefined || row.id === null || row.id === '') { if (row.id === undefined || row.id === null || row.id === '') {
...@@ -378,6 +378,7 @@ const List = () => { ...@@ -378,6 +378,7 @@ const List = () => {
color="error" color="error"
onClick={(e: MouseEvent<HTMLButtonElement>) => { onClick={(e: MouseEvent<HTMLButtonElement>) => {
e.stopPropagation(); e.stopPropagation();
setTutorialTitle(row.values.tutorialTitle)
setTutorialId(row.values._id) setTutorialId(row.values._id)
setOpenAlert(true) setOpenAlert(true)
}} }}
...@@ -405,7 +406,8 @@ const List = () => { ...@@ -405,7 +406,8 @@ const List = () => {
//alert model //alert model
const [openAlert, setOpenAlert] = useState(false); 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 = () => { const handleAlertClose = () => {
setOpenAlert(!openAlert); setOpenAlert(!openAlert);
...@@ -420,6 +422,8 @@ const List = () => { ...@@ -420,6 +422,8 @@ const List = () => {
}, [dispatch]); }, [dispatch]);
useEffect(() => { useEffect(() => {
console.log(tutorials);
setData(tutorials); setData(tutorials);
}, [tutorials]) }, [tutorials])
...@@ -484,7 +488,7 @@ const List = () => { ...@@ -484,7 +488,7 @@ const List = () => {
<AddEditTutorial tutorial={tutorial!} onCancel={handleAddEdit} /> <AddEditTutorial tutorial={tutorial!} onCancel={handleAddEdit} />
</Dialog> </Dialog>
{/* alert model */} {/* alert model */}
{!tutorial && <AlertTutorialDelete title={""} open={openAlert} handleClose={handleAlertClose} deleteId={tutorialId} />} {!tutorial && <AlertTutorialDelete title={tutorialTitle!} open={openAlert} handleClose={handleAlertClose} deleteId={tutorialId} />}
</MainCard> </MainCard>
</> </>
) )
......
...@@ -32,7 +32,7 @@ import IconButton from 'components/@extended/IconButton'; ...@@ -32,7 +32,7 @@ import IconButton from 'components/@extended/IconButton';
import { DeleteFilled } from '@ant-design/icons'; import { DeleteFilled } from '@ant-design/icons';
import { AccordionSummary, InputLabel, TextField } from '@mui/material'; import { AccordionSummary, InputLabel, TextField } from '@mui/material';
import MainCard from 'components/MainCard'; import MainCard from 'components/MainCard';
import { tutorialReqOb } from 'data/tutorials'; import useAuth from 'hooks/useAuth';
import { dispatch } from 'store'; import { dispatch } from 'store';
import { addTutorial } from 'store/reducers/tutorial'; import { addTutorial } from 'store/reducers/tutorial';
import { Tutorial } from 'types/tutorial'; import { Tutorial } from 'types/tutorial';
...@@ -78,29 +78,30 @@ export interface Props { ...@@ -78,29 +78,30 @@ export interface Props {
const AddEditTutorial = ({ tutorial, onCancel }: Props) => { const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
const theme = useTheme(); const theme = useTheme();
const { user } = useAuth();
const isCreating = !tutorial; const isCreating = !tutorial;
const TutorialSchema = Yup.object().shape({ const TutorialSchema = Yup.object().shape({
// tutorialCode: Yup.string().required(`Tutorial Code is required`), tutorialCode: Yup.string().required(`Tutorial Code is required`),
// tutorialTitle: Yup.string().required(`Tutorial Title is required`), tutorialTitle: Yup.string().required(`Tutorial Title is required`),
// tutorialDescription: Yup.string().required(`Tutorial Description is required`), tutorialDescription: Yup.string().required(`Tutorial Description is required`),
// tutorialImage: Yup.string().required(`Tutorial Image Ref is required`), tutorialImage: Yup.string().required(`Tutorial Image Ref is required`),
// taskItems: Yup.array().of( taskItems: Yup.array().of(
// Yup.object().shape({ Yup.object().shape({
// title: Yup.string().required(`Task Title is required`), title: Yup.string().required(`Task Title is required`),
// description: Yup.string().required(`Task Description is required`), description: Yup.string().required(`Task Description is required`),
// howToDo: Yup.string().required(`Task How To Do is required`), howToDo: Yup.string().required(`Task How To Do is required`),
// referenceImage: Yup.string().required(`Task Reference Image is required`), referenceImage: Yup.string().required(`Task Reference Image is required`),
// referenceVideo: Yup.string(), referenceVideo: Yup.string(),
// taskItemMark: Yup.number().required(`Task Mark is required`).min(1, 'Task Mark must be greater than 0'), taskItemMark: Yup.number().required(`Task Mark is required`).min(1, 'Task Mark must be greater than 0'),
// }) })
// ).required(`Tutorial Task Item is required`), ).required(`Tutorial Task Item is required`),
// status: Yup.number(), status: Yup.number(),
// createdBy: Yup.string(), createdBy: Yup.string(),
// createdAt: Yup.date(), createdAt: Yup.date(),
// updatedBy: Yup.string(), updatedBy: Yup.string(),
// updatedAt: Yup.date(), updatedAt: Yup.date(),
}); });
const [openAlert, setOpenAlert] = useState(false); const [openAlert, setOpenAlert] = useState(false);
...@@ -120,12 +121,22 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => { ...@@ -120,12 +121,22 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
// PUT API // PUT API
} else { } else {
// POST API // POST API
//@ts-ignore // const dummyObject: Tutorial = tutorialReqOb
// const req: Tutorial = { ...values } // dispatch(addTutorial(dummyObject))
const sampleReq: Tutorial = tutorialReqOb
//@ts-ignore const req: Tutorial = {
dispatch(addTutorial(sampleReq)) 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() resetForm()
setSubmitting(false); setSubmitting(false);
......
...@@ -7,20 +7,22 @@ import { PopupTransition } from 'components/@extended/Transitions'; ...@@ -7,20 +7,22 @@ import { PopupTransition } from 'components/@extended/Transitions';
// assets // assets
import { DeleteFilled } from '@ant-design/icons'; import { DeleteFilled } from '@ant-design/icons';
import { useDispatch } from 'store';
import { deleteTutorial } from 'store/reducers/tutorial';
// types // types
interface Props { interface Props {
title: string; title: string;
open: boolean; open: boolean;
handleClose: (status: boolean) => void; handleClose: (status: boolean) => void;
deleteId: number | string | undefined; deleteId: string | undefined;
} }
// ==============================|| Tutorial - DELETE ||============================== // // ==============================|| Tutorial - DELETE ||============================== //
export default function AlertTutorialDelete({ title, open, handleClose, deleteId }: Props) { export default function AlertTutorialDelete({ title, open, handleClose, deleteId }: Props) {
// const dispatch = useDispatch(); const dispatch = useDispatch();
return ( return (
<Dialog <Dialog
...@@ -41,6 +43,14 @@ export default function AlertTutorialDelete({ title, open, handleClose, deleteId ...@@ -41,6 +43,14 @@ export default function AlertTutorialDelete({ title, open, handleClose, deleteId
<Typography variant="h4" align="center"> <Typography variant="h4" align="center">
Are you sure you want to delete? Are you sure you want to delete?
</Typography> </Typography>
<Typography align="center">
By deleting
<Typography variant="subtitle1" component="span">
{' '}
"{title}"{' '}
</Typography>
tutorial, Its details & tasks will also be deleted.
</Typography>
</Stack> </Stack>
<Stack direction="row" spacing={2} sx={{ width: 1 }}> <Stack direction="row" spacing={2} sx={{ width: 1 }}>
...@@ -48,7 +58,7 @@ export default function AlertTutorialDelete({ title, open, handleClose, deleteId ...@@ -48,7 +58,7 @@ export default function AlertTutorialDelete({ title, open, handleClose, deleteId
Cancel Cancel
</Button> </Button>
<Button fullWidth color="error" variant="contained" onClick={() => { <Button fullWidth color="error" variant="contained" onClick={() => {
// dispatch(deleteNutrition(deleteId!)) dispatch(deleteTutorial(deleteId!))
handleClose(true) handleClose(true)
}} autoFocus> }} autoFocus>
Delete Delete
......
...@@ -71,7 +71,7 @@ const slice = createSlice({ ...@@ -71,7 +71,7 @@ const slice = createSlice({
// DELETE TUTORIAL // DELETE TUTORIAL
deleteTutorialSuccess(state, action) { deleteTutorialSuccess(state, action) {
state.tutorials = state.tutorials.filter(tutorial => tutorial._id !== action.payload._id); state.tutorials = state.tutorials.filter(tutorial => tutorial._id !== action.payload);
state.success = "Tutorial deleted successfully." state.success = "Tutorial deleted successfully."
}, },
...@@ -177,7 +177,7 @@ export function updateTutorial(updatedTutorial: Tutorial) { ...@@ -177,7 +177,7 @@ export function updateTutorial(updatedTutorial: Tutorial) {
* @param tutorialId * @param tutorialId
* @returns * @returns
*/ */
export function deleteTutorial(tutorialId: number) { export function deleteTutorial(tutorialId: string) {
return async () => { return async () => {
dispatch(slice.actions.startLoading()); 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