Skip to content

Commit

Permalink
Merge pull request #89 from AkshataKatwal16/page-issue
Browse files Browse the repository at this point in the history
Issue feat:Fix onedit player issue and  disallow edit issue
  • Loading branch information
itsvick authored Nov 13, 2024
2 parents 49e1c68 + bf883a8 commit ea55ac2
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 21 deletions.
59 changes: 55 additions & 4 deletions src/components/KaTableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Typography, useTheme, IconButton , Box} from '@mui/material';
import UpReviewTinyImage from '@mui/icons-material/LibraryBooks';
import "ka-table/style.css";
import DeleteIcon from "@mui/icons-material/Delete";
import router from "next/router";
import { MIME_TYPE } from "@/utils/app.config";

interface CustomTableProps {
data: any[]; // Define a more specific type for your data if needed
Expand All @@ -13,25 +15,74 @@ interface CustomTableProps {
title: string;
dataType: DataType;
}>;
handleDelete?:any
handleDelete?:any;
tableTitle?:string
}

const KaTableComponent: React.FC<CustomTableProps> = ({ data, columns , handleDelete}) => {
const KaTableComponent: React.FC<CustomTableProps> = ({ data, columns , handleDelete, tableTitle}) => {
const theme = useTheme<any>();


const openEditor = (content: any) => {
const identifier = content?.identifier;
let mode = content?.mode; // default mode from content, can be overwritten by tableTitle

switch (tableTitle) {
case 'draft':
// Use draft-specific routing
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 } });
} else if (
content?.mimeType &&
MIME_TYPE.COLLECTION_MIME_TYPE.includes(content?.mimeType)
) {
router.push({ pathname: `/collection`, query: { identifier, mode } });
}
return; // Exit early since draft has specific routing logic

case 'publish':
mode = "read";
break;
case 'submitted':
mode = "review";
break;
// Default case for "all-content" or any other values if mode is already defined in content
default:
mode = mode || content?.mode;
break;
}

// Generic routing for cases other than 'draft'
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)) {
const pathname = tableTitle === 'submitted' ? `/workspace/content/review` : `/upload-editor`;
router.push({ pathname, query: { identifier, mode } });
} else if (content?.mimeType && MIME_TYPE.COLLECTION_MIME_TYPE.includes(content?.mimeType)) {
router.push({ pathname: `/collection`, query: { identifier, mode } });
}
};



return (
<KaTable
columns={columns}
data={data}
editingMode={EditingMode.Cell}
// editingMode={EditingMode.Cell}
rowKeyField={'id'}
sortingMode={SortingMode.Single}
childComponents={{
cellText: {
content: (props) => {
if (props.column.key === 'name' || props.column.key==="title_and_description") {
return (
<div style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ display: 'flex', alignItems: 'center', cursor:"pointer" }} onClick={() => openEditor(props.rowData)} >
{props.rowData.image ? (
<img
src={props.rowData.image || '/logo.png'}
Expand Down
18 changes: 7 additions & 11 deletions src/pages/workspace/content/allContents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ const AllContentsPage = () => {
name: item.name,
primaryCategory: item.primaryCategory,
lastUpdatedOn: timeAgo(item.lastUpdatedOn),
status: item.status
status: item.status,
identifier: item.identifier,
mimeType: item.mimeType,
mode: item.mode

}));
setData(filteredArray)
console.log(filteredArray)
Expand Down Expand Up @@ -196,6 +200,7 @@ console.log("contentList",contentList)
onFilterChange={handleFilterChange}
onSortChange={handleSortChange}
/>
</Box>


{loading ? (
Expand All @@ -204,23 +209,14 @@ console.log("contentList",contentList)
contentList &&
contentList.length > 0 && (
<>
<KaTableComponent columns={columns} data={data}/>
<KaTableComponent columns={columns} tableTitle="all-content" data={data}/>
</>
)
) : (
<NoDataFound />
)}



{totalCount > LIMIT && (
<PaginationComponent
count={Math.ceil(totalCount / LIMIT)}
page={page}
onPageChange={handleChangePage}
/>
)}
</Box>
</Box>

</Layout>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/workspace/content/draft/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { MIME_TYPE } from "@/utils/app.config";
import WorkspaceText from "@/components/WorkspaceText";
import { DataType } from 'ka-table/enums';
import KaTableComponent from "@/components/KaTableComponent";
import Paper from '@mui/material/Paper';
const columns = [
{ key: 'title_and_description', title: 'Title & Description', dataType: DataType.String },
{ key: 'contentType', title: 'Content Type', dataType: DataType.String },
Expand Down Expand Up @@ -66,7 +67,10 @@ const DraftPage = () => {

contentType: item.primaryCategory,
lastUpdatedOn:new Date(item.lastUpdatedOn).toLocaleString(),
status: item.status
status: item.status,
identifier: item.identifier,
mimeType: item.mimeType,
mode: item.mode
}));
setData(filteredArray)
console.log(filteredArray)
Expand Down Expand Up @@ -170,7 +174,7 @@ const DraftPage = () => {
<CircularProgress />
</Box>
) : contentList && contentList.length > 0 ? (
<KaTableComponent columns={columns} data={data} handleDelete={handleDelete}/>
<KaTableComponent columns={columns} data={data} tableTitle="draft" handleDelete={handleDelete}/>
) : (
<NoDataFound />
)}
Expand Down
7 changes: 5 additions & 2 deletions src/pages/workspace/content/publish/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ const PublishPage = () => {

contentType: item.primaryCategory,
lastUpdatedOn:new Date(item.lastUpdatedOn).toLocaleString(),
status: item.status
status: item.status,
identifier: item.identifier,
mimeType: item.mimeType,
mode: item.mode
}));
setData(filteredArray)
console.log(filteredArray)
Expand Down Expand Up @@ -161,7 +164,7 @@ const PublishPage = () => {
<CircularProgress />
</Box>
) : contentList && contentList.length > 0 ? (
<KaTableComponent columns={columns} data={data} handleDelete={handleDelete}/>
<KaTableComponent columns={columns} data={data} tableTitle="publish" handleDelete={handleDelete}/>
) : (
<NoDataFound />
)}
Expand Down
7 changes: 5 additions & 2 deletions src/pages/workspace/content/submitted/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ const SubmittedForReviewPage = () => {

contentType: item.primaryCategory,
lastUpdatedOn:new Date(item.lastUpdatedOn).toLocaleString(),
status: item.status
status: item.status,
identifier: item.identifier,
mimeType: item.mimeType,
mode: item.mode
}));
setData(filteredArray)
console.log(filteredArray)
Expand Down Expand Up @@ -169,7 +172,7 @@ const SubmittedForReviewPage = () => {
<CircularProgress />
</Box>
) : contentList && contentList.length > 0 ? (
<KaTableComponent columns={columns} data={data} handleDelete={handleDelete}/>
<KaTableComponent columns={columns} data={data} tableTitle="submitted" handleDelete={handleDelete}/>
) : (
<NoDataFound />
)}
Expand Down
1 change: 1 addition & 0 deletions src/utils/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ interface content {
identifier?: string;
mimeType?: string;
primaryCategory: string;
mode?: string;
}

0 comments on commit ea55ac2

Please sign in to comment.