Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit published and non-published activities #1020

Merged
merged 12 commits into from
Dec 18, 2024
62 changes: 35 additions & 27 deletions docker-compose-windows.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# services:
# mysql:
# image: mysql:8
# environment:
# - MYSQL_ROOT_PASSWORD=my-secret-pw
# healthcheck:
# test: [ 'CMD', 'mysqladmin', 'ping', '-h', 'localhost' ]
# timeout: 20s
# retries: 10
# ports:
# - '3306:3306'
# - '33060:33060'
# volumes:
# - ./.mysql-data:/var/lib/mysql
# minio:
# image: minio/minio
# ports:
# - '9000:9000'
# - '9090:9090'
# environment:
# - MINIO_ROOT_USER=minioadmin
# - MINIO_ROOT_PASSWORD=minioadmin
# - MINIO_ACCESS_KEY=minio
# - MINIO_SECRET_KEY=minio123
# volumes:
# - ./.minio-data:/data
# command: server --console-address ":9090" /data
services:
mysql:
image: mysql:8
environment:
- MYSQL_ROOT_PASSWORD=my-secret-pw
healthcheck:
test: ['CMD', 'mysqladmin', 'ping', '-h', 'localhost']
timeout: 20s
retries: 10
ports:
- '3306:3306'
- '33060:33060'
volumes:
- ./.mysql-data:/var/lib/mysql
minio:
image: minio/minio
ports:
- '9000:9000'
- '9090:9090'
environment:
- MINIO_ROOT_USER=minioadmin
- MINIO_ROOT_PASSWORD=minioadmin
- MINIO_ACCESS_KEY=minio
- MINIO_SECRET_KEY=minio123
volumes:
- ./.minio-data:/data
command: server --console-address ":9090" /data
dynamodb:
command: '-jar DynamoDBLocal.jar -sharedDb -dbPath ./data'
image: 'amazon/dynamodb-local:latest'
ports:
- '8000:8000'
volumes:
- './.dynamodb:/home/dynamodblocal/data'
working_dir: /home/dynamodblocal
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
timeout: 20s
retries: 10
ports:
- '3307:3306'
- '3306:3306'
- '33060:33060'
volumes:
- ./.mysql-data:/var/lib/mysql
Expand Down
5 changes: 4 additions & 1 deletion src/components/activities/content/views/DocumentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import React from 'react';

import type { ViewProps } from '../content.types';
import PdfDisplay from '../editors/DocumentEditor/PdfDisplay';
import { LightBox } from 'src/components/lightbox/Lightbox';

export const DocumentView = ({ value = '' }: ViewProps) => {
return (
<div style={{ width: '100%', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignContent: 'center', alignItems: 'center' }}>
<PdfDisplay url={value} />
<LightBox url={value} isPDF>
<PdfDisplay url={value} />
</LightBox>
</div>
);
};
32 changes: 29 additions & 3 deletions src/components/lightbox/Lightbox.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import Image from 'next/image';
import * as React from 'react';
import React, { useState } from 'react';
import { Document, Page, pdfjs } from 'react-pdf';

import { Modal } from '../Modal';

type LightBoxProps = {
url: string;
children: JSX.Element;
isPDF?: boolean;
};

export const LightBox = ({ url, children }: LightBoxProps) => {
export const LightBox = ({ url, children, isPDF }: LightBoxProps) => {
const [isModalOpen, setIsModalOpen] = React.useState(false);

const options = {
cMapUrl: `https://unpkg.com/pdfjs-dist@${pdfjs.version}/cmaps/`,
};

const [numPages, setNumPages] = useState<number>(1);
function onDocumentLoadSuccess({ numPages }: { numPages: number }): void {
setNumPages(numPages);
}
return (
<>
<div onClick={() => setIsModalOpen(true)} style={{ cursor: 'pointer' }}>
Expand All @@ -27,7 +37,23 @@ export const LightBox = ({ url, children }: LightBoxProps) => {
ariaLabelledBy="lightBox-modal-title"
ariaDescribedBy="lightBox-modal-description"
>
<Image layout="responsive" objectFit="contain" width="100%" height="70%" alt="" unoptimized src={url} />
{isPDF ? (
<Document options={options} file={url} onLoadSuccess={onDocumentLoadSuccess}>
{Array.from(Array(numPages).keys()).map((v) => (
<div
key={v}
style={{
marginTop: 10,
marginBottom: 10,
}}
>
<Page width={430} scale={2.0} pageNumber={v + 1} />
</div>
))}
</Document>
) : (
<Image layout="responsive" objectFit="contain" width="100%" height="70%" alt="" unoptimized src={url} />
)}
</Modal>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/contenu-libre/2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ContenuLibre = () => {

const data = (activity?.data as FreeContentData) || null;
const errorSteps = React.useMemo(() => {
if (activity !== null && activity.content.filter((c) => c.value.length > 0 && c.value !== '<p></p>\n').length === 0) {
if (activity !== null && activity.content.filter((c) => c.value && c.value.length > 0 && c.value !== '<p></p>\n').length === 0) {
return [0];
}
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/pages/contenu-libre/3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ContenuLibre = () => {
const errorSteps = React.useMemo(() => {
const errors: number[] = [];
const data = (activity?.data as FreeContentData) || null;
if (activity !== null && activity.content.filter((c) => c.value.length > 0 && c.value !== '<p></p>\n').length === 0) {
if (activity !== null && activity.content.filter((c) => c.value && c.value.length > 0 && c.value !== '<p></p>\n').length === 0) {
errors.push(0);
}
if (data !== null && (!data.title || !data.resume)) {
Expand Down
Loading