This repository has been archived by the owner on Nov 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:erxes/erxes-community into dev
- Loading branch information
Showing
182 changed files
with
5,650 additions
and
1,485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import RightSideBar from "@/modules/chat/component/RightSideBar" | ||
import Messages from "@/modules/chat/component/messages/Messages" | ||
|
||
export default function Detail() { | ||
return ( | ||
<div className="w-full "> | ||
<Messages /> | ||
</div> | ||
<> | ||
<div className="w-9/12 border-r"> | ||
<Messages /> | ||
</div> | ||
<div className="flex h-full w-1/4 flex-col"> | ||
<RightSideBar /> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use client" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
import { FilePreview } from "./FilePreview" | ||
|
||
export const AttachmentWithChatPreview = ({ | ||
attachments, | ||
className, | ||
deleteImage, | ||
isDownload, | ||
}: { | ||
attachments: any[] | ||
className?: string | ||
deleteImage?: (index: number) => void | ||
isDownload?: boolean | ||
}) => { | ||
const renderAttachmentPreview = () => { | ||
if (attachments && attachments.length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div id="gallery" className={cn("relative w-full", className)}> | ||
<div className="flex w-full"> | ||
{attachments.map((image: any, i: number) => ( | ||
<FilePreview | ||
key={i} | ||
fileUrl={image.url} | ||
fileName={image.name} | ||
deleteImage={deleteImage} | ||
fileIndex={i} | ||
isDownload={isDownload} | ||
attachments={attachments} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
return <>{renderAttachmentPreview()}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
import React from "react" | ||
import { ExternalLinkIcon, XCircle } from "lucide-react" | ||
|
||
import { readFile } from "@/lib/utils" | ||
|
||
import { AttachmentWithPreview } from "./AttachmentWithPreview" | ||
import { Dialog, DialogContent, DialogHeader, DialogTrigger } from "./ui/dialog" | ||
import Image from "./ui/image" | ||
|
||
export const FilePreview = ({ | ||
fileUrl, | ||
fileName, | ||
deleteImage, | ||
fileIndex, | ||
isDownload, | ||
attachments, | ||
}: { | ||
fileUrl: string | ||
fileName?: string | ||
fileIndex: number | ||
deleteImage?: (index: number) => void | ||
isDownload?: boolean | ||
attachments?: any[] | ||
}) => { | ||
if (!fileUrl || !fileUrl.split) { | ||
return null | ||
} | ||
|
||
const onDelete = (index: number) => { | ||
if (deleteImage) { | ||
deleteImage(index) | ||
} | ||
|
||
return | ||
} | ||
|
||
const renderImageForm = () => { | ||
return ( | ||
<DialogContent> | ||
<DialogHeader /> | ||
<AttachmentWithPreview images={attachments || []} /> | ||
</DialogContent> | ||
) | ||
} | ||
|
||
const renderFile = () => { | ||
return ( | ||
<div className="relative"> | ||
{deleteImage && ( | ||
<button | ||
type="button" | ||
className="absolute top-0 bg-white p-1 rounded-full" | ||
onClick={() => onDelete(fileIndex)} | ||
> | ||
<XCircle size={18} /> | ||
</button> | ||
)} | ||
|
||
{isDownload ? ( | ||
<a href={readFile(fileUrl)}> | ||
<div className="mr-1 p-2 rounded-lg bg-[#F0F0F0]"> | ||
<div className="flex items-center text-sm font-semibold text-[#444] break-words"> | ||
<ExternalLinkIcon size={18} /> {fileName} | ||
</div>{" "} | ||
</div> | ||
</a> | ||
) : ( | ||
<div className="mr-1 p-2 rounded-lg bg-[#F0F0F0]"> | ||
<div className="flex items-center text-sm font-semibold text-[#444] break-words"> | ||
<ExternalLinkIcon size={18} /> {fileName} | ||
</div>{" "} | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
const renderImagePreview = () => { | ||
if (deleteImage) { | ||
return ( | ||
<div className="mr-1 w-[80px] h-[80px] shrink-0"> | ||
<button | ||
type="button" | ||
className="absolute top-0 bg-white p-1 rounded-full" | ||
onClick={() => onDelete(fileIndex)} | ||
> | ||
<XCircle size={18} /> | ||
</button> | ||
|
||
<Image | ||
alt="image" | ||
src={fileUrl || ""} | ||
width={500} | ||
height={500} | ||
className="object-contain w-[80px] h-[80px]" | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<> | ||
<Dialog> | ||
<DialogTrigger asChild={true}> | ||
<div className="mr-1 w-[80px] h-[80px] shrink-0 cursor-pointer"> | ||
<Image | ||
alt="image" | ||
src={fileUrl || ""} | ||
width={500} | ||
height={500} | ||
className="object-contain w-[80px] h-[80px]" | ||
/> | ||
</div> | ||
</DialogTrigger> | ||
|
||
{renderImageForm()} | ||
</Dialog> | ||
</> | ||
) | ||
} | ||
|
||
const fileExtension = fileUrl.split(".").pop() | ||
|
||
let filePreview | ||
|
||
switch (fileExtension) { | ||
case "docx": | ||
filePreview = renderFile() | ||
break | ||
case "pptx": | ||
filePreview = renderFile() | ||
break | ||
case "xlsx": | ||
filePreview = renderFile() | ||
break | ||
// case "mp4": | ||
// filePreview = renderVideo() | ||
// break | ||
// case "m3u8": | ||
// filePreview = renderCloudflareStreamVideoFile() | ||
// break | ||
case "jpeg": | ||
case "jpg": | ||
case "gif": | ||
case "png": | ||
filePreview = renderImagePreview() | ||
break | ||
case "zip": | ||
case "csv": | ||
case "doc": | ||
case "ppt": | ||
case "psd": | ||
case "avi": | ||
case "txt": | ||
case "rar": | ||
case "mp3": | ||
case "pdf": | ||
default: | ||
filePreview = renderFile() | ||
} | ||
|
||
return filePreview | ||
} |
Oops, something went wrong.