Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Aar-if authored Oct 15, 2024
2 parents 5719b8a + f4389f3 commit e89e42d
Show file tree
Hide file tree
Showing 10 changed files with 4,783 additions and 2,173 deletions.
6,869 changes: 4,712 additions & 2,157 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"lint": "next lint"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5",
"@module-federation/nextjs-mf": "^8.5.5",
"@module-federation/utilities": "3.0.11",
"@mui/icons-material": "^5.15.20",
"@mui/material": "^5.16.0",
"@mui/icons-material": "5.15.20",
"@mui/material": "5.16.0",
"async": "^3.2.5",
"body-parser": "^1.20.2",
"dotenv": "^16.4.5",
Expand Down
2 changes: 1 addition & 1 deletion src/components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const CourseCard: React.FC<ContentCardProps> = ({
}}
/>
</Box>
<CardContent sx={{ flex: 1 }}>
<CardContent sx={{ flex: 1 }} onClick={openEditor}>
<Typography variant="h6">{title}</Typography>
<Typography variant="body2" color="text.secondary">
{description}
Expand Down
9 changes: 8 additions & 1 deletion src/components/GenericEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ const GenericEditor: React.FC = () => {

useEffect(() => {
if (typeof window !== 'undefined') {
// Attach jQuery to window and window.parent
window.$ = window.jQuery = $;
if (window.parent) {
window.parent.$ = window.$;
window.parent.jQuery = window.jQuery;
}

console.log('editorConfig ==>', editorConfig);
getContentDetails(identifier)
.then((data: any) => {
Expand Down Expand Up @@ -115,7 +122,7 @@ const GenericEditor: React.FC = () => {
if (editorElement) {
editorElement.remove();
}
router.push('/');
window.history.back();
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Loader: React.FC<{ showBackdrop: boolean; loadingText: string }> = ({
<>
<CircularProgress color="inherit" />
<br />
<Typography variant="h2">{loadingText}...</Typography>
<Typography variant="h4">{loadingText}...</Typography>
</>
);
};
Expand Down
2 changes: 2 additions & 0 deletions src/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ interface Window {
config: any;
context: any;
redirectUrl: any;
$: typeof import('jquery');
jQuery: typeof import('jquery');
}

declare module '*.json' {
Expand Down
51 changes: 45 additions & 6 deletions src/pages/workspace/content/allContents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import {
import DeleteIcon from "@mui/icons-material/Delete";
import UpReviewTinyImage from "@mui/icons-material/LibraryBooks";
import SearchBox from "../../../../components/SearchBox";
import { getContent } from "../../../../services/ContentService";
import { deleteContent, getContent } from "../../../../services/ContentService";
import { timeAgo } from "@/utils/Helper";
import Loader from "@/components/Loader";
import NoDataFound from "@/components/NoDataFound";
import { MIME_TYPE } from "@/utils/app.config";
import router from "next/router";

const AllContentsPage = () => {
const theme = useTheme<any>();
Expand All @@ -31,6 +33,7 @@ const AllContentsPage = () => {
const [sortBy, setSortBy] = useState("updated");
const [contentList, setContentList] = React.useState<content[]>([]);
const [loading, setLoading] = useState(false);
const [contentDeleted, setContentDeleted] = React.useState(false);
const [debouncedSearchTerm, setDebouncedSearchTerm] =
useState<string>(searchTerm);

Expand Down Expand Up @@ -67,6 +70,19 @@ const AllContentsPage = () => {
setSortBy(sortBy);
};

const openEditor = (content: any) => {
const identifier = content?.identifier;
const mode = content?.mode;
if (content?.mimeType === MIME_TYPE.QUESTIONSET_MIME_TYPE) {
router.push({ pathname: `/editor`, query: { identifier, mode } });
} else if (
content?.mimeType &&
MIME_TYPE.GENERIC_MIME_TYPE.includes(content?.mimeType)
) {
router.push({ pathname: `/upload-editor`, query: { identifier } });
}
};

useEffect(() => {
const getContentList = async () => {
try {
Expand All @@ -82,15 +98,31 @@ const AllContentsPage = () => {
];
const query = debouncedSearchTerm || "";
const response = await getContent(status, query);
const contentList = (response?.content || []).concat(response?.QuestionSet || []);
const contentList = (response?.content || []).concat(
response?.QuestionSet || []
);
setContentList(contentList);
setLoading(false);
} catch (error) {
console.log(error);
}
};
getContentList();
}, [debouncedSearchTerm]);
}, [debouncedSearchTerm, contentDeleted]);

const handleDeleteClick = async (content: any) => {
if (content?.identifier && content?.mimeType) {
try {
await deleteContent(content?.identifier, content?.mimeType);
console.log(`Deleted item with identifier - ${content?.identifier}`);
setTimeout(() => {
setContentDeleted((prev) => !prev);
}, 1000);
} catch (error) {
console.error("Failed to delete content:", error);
}
}
};

const filteredData = useMemo(
() =>
Expand Down Expand Up @@ -132,8 +164,12 @@ const AllContentsPage = () => {
<TableBody>
{contentList?.map((content, index) => (
<TableRow key={index}>
<TableCell>
<Box display="flex" alignItems="center">
<TableCell onClick={() => openEditor(content)}>
<Box
display="flex"
alignItems="center"
sx={{ cursor: "pointer" }}
>
{content?.appIcon ? (
<img src={content?.appIcon} height={"25px"} />
) : (
Expand All @@ -156,7 +192,10 @@ const AllContentsPage = () => {
<TableCell>{content?.status}</TableCell>
<TableCell>
{content?.status === "Draft" && (
<IconButton aria-label="delete">
<IconButton
aria-label="delete"
onClick={() => handleDeleteClick(content)}
>
<DeleteIcon />
</IconButton>
)}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/workspace/content/draft/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const DraftPage = () => {

const handleDelete = (index: number) => {
console.log(`Deleting item at index ${index}`);
setContentDeleted((prev) => !prev);
setTimeout(() => {
setContentDeleted((prev) => !prev);
}, 1000);
};

useEffect(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/pages/workspace/content/publish/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const PublishPage = () => {

const handleDelete = (index: number) => {
console.log(`Deleting item at index ${index}`);
setContentDeleted((prev) => !prev);
setTimeout(() => {
setContentDeleted((prev) => !prev);
}, 1000);
};

useEffect(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/content/submitted/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SearchBox from "../../../../components/SearchBox";
import { getContent } from "@/services/ContentService";
import Loader from "@/components/Loader";
import NoDataFound from "@/components/NoDataFound";
import { setTimeout } from "timers";

const SubmittedForReviewPage = () => {
const [selectedKey, setSelectedKey] = useState("submitted");
Expand Down Expand Up @@ -55,7 +56,9 @@ const SubmittedForReviewPage = () => {

const handleDelete = (index: number) => {
console.log(`Deleting item at index ${index}`);
setContentDeleted((prev) => !prev);
setTimeout(() => {
setContentDeleted((prev) => !prev);
}, 1000);
};

useEffect(() => {
Expand Down

0 comments on commit e89e42d

Please sign in to comment.