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

Develop #851

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/features/AdminPage/Analytics/Analytics.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useRouteUrl } from '@/app/common/hooks/stateful/useRouter.hook';
import base64ToUrl from '@/app/common/utils/base64ToUrl.utility';
import PageBar from '@/features/AdminPage/PageBar/PageBar.component';
import StatisticRecord from '@/models/analytics/analytics/statisticrecord.model';
import Image from '@/models/media/image.model';
import Image, { ImageAssigment } from '@/models/media/image.model';
import Streetcode from '@/models/streetcode/streetcode-types.model';

interface TableData {
Expand Down Expand Up @@ -79,7 +79,7 @@ const Analytics = () => {

const setImages = async (streetcodeId: number) => {
await ImagesApi.getByStreetcodeId(streetcodeId ?? 1).then((imgs) => {
setImage(imgs.at(0));
setImage(imgs.find((image) => image.imageDetails?.alt === ImageAssigment.blackandwhite.toString()));
}).catch((e) => {
console.log(e);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { InboxOutlined } from '@ant-design/icons';
import CreateUpdateMediaStore from '@app/stores/create-update-media-store';
import useMobx from '@app/stores/root-store';
import { ModelState } from '@models/enums/model-state';
import Image, { ImageUpdate } from '@models/media/image.model';
import Image, { ImageAssigment, ImageUpdate } from '@models/media/image.model';

import { FormInstance, Modal, UploadFile } from 'antd';
import FormItem from 'antd/es/form/FormItem';
Expand Down Expand Up @@ -144,18 +144,25 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
const fetchData = async () => {
try {
await ImagesApi.getByStreetcodeId(parseId).then((result) => {
setAnimation([convertFileToUploadFile(result[0])]);
setBlackAndWhite([convertFileToUploadFile(result[1])]);
setRelatedFigure(result[2] ? [convertFileToUploadFile(result[2])] : []);
form.setFieldsValue({
animations: [convertFileToUploadFile(result[0])],
pictureBlackWhite: [convertFileToUploadFile(result[1])],
pictureRelations: result[2] ? [convertFileToUploadFile(result[2])] : [],
});
result.forEach((image) => {
if (image.imageDetails?.alt === ImageAssigment.animation.toString()) {
setAnimation([convertFileToUploadFile(image)]);
form.setFieldsValue({ animations: [convertFileToUploadFile(image)] });
createUpdateMediaStore.animationId = image.id;
}

createUpdateMediaStore.animationId = result[0].id;
createUpdateMediaStore.blackAndWhiteId = result[1].id;
createUpdateMediaStore.relatedFigureId = result[2]?.id;
if (image.imageDetails?.alt === ImageAssigment.blackandwhite.toString()) {
setBlackAndWhite([convertFileToUploadFile(image)]);
form.setFieldsValue({ pictureBlackWhite: [convertFileToUploadFile(image)] });
createUpdateMediaStore.blackAndWhiteId = image.id;
}

if (image.imageDetails?.alt === ImageAssigment.relatedfigure.toString()) {
setRelatedFigure([convertFileToUploadFile(image)]);
form.setFieldsValue({ pictureRelations: [convertFileToUploadFile(image)] });
createUpdateMediaStore.relatedFigureId = image.id;
}
});

createUpdateMediaStore.imagesUpdate = result.map((img) => ({
...img,
Expand Down Expand Up @@ -193,10 +200,6 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
name="animations"
label="Анімація"
rules={[
{
required: true,
message: 'Завантажте анімацію',
},
{
validator: (_, file) => {
if (file) {
Expand All @@ -211,7 +214,7 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
}
return Promise.reject(Error('Тільки файли з розширенням .gif та .webp дозволені!'));
}
return Promise.reject();
return Promise.resolve();
},
},
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ImagesApi from '@/app/api/media/images.api';
import TransactionLinksApi from '@/app/api/transactions/transactLinks.api';
import base64ToUrl from '@/app/common/utils/base64ToUrl.utility';
import { audioClickEvent, personLiveEvent } from '@/app/common/utils/googleAnalytics.unility';
import Image from '@/models/media/image.model';
import Image, { ImageAssigment } from '@/models/media/image.model';

const fullMonthNumericYearDateFmtr = new Intl.DateTimeFormat('uk-UA', {
day: 'numeric',
Expand Down Expand Up @@ -87,7 +87,8 @@ const StreetcodeCard = ({ streetcode, setActiveTagId, setActiveBlock }: Props) =
swipeOnClick
infinite
>
{images.slice(0, 2).map((im) => (
{images.filter((image) => (image.imageDetails?.alt === ImageAssigment.animation.toString()
|| image.imageDetails?.alt === ImageAssigment.blackandwhite.toString())).map((im) => (
<img
key={im.id}
src={base64ToUrl(im.base64, im.mimeType)}
Expand Down
Loading