Skip to content

Commit

Permalink
Merge pull request #851 from ita-social-projects/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MementoMorj authored Sep 27, 2023
2 parents dc5b2d5 + 896aef0 commit f6f901f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
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

0 comments on commit f6f901f

Please sign in to comment.