Skip to content

Commit

Permalink
Merge pull request #791 from ita-social-projects/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MementoMorj authored Sep 18, 2023
2 parents de88d61 + 5b7f55b commit 41a2a5d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/app/api/streetcode/streetcodes.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const StreetcodesApi = {
.post<StreetcodeCreate>(`${API_ROUTES.STREETCODES.CREATE}`, streetcode),

update: (streetcode: StreetcodeUpdate) => Agent
.put<StreetcodeCreate>(`${API_ROUTES.STREETCODES.UPDATE}`, streetcode),
.put<StreetcodeUpdate>(`${API_ROUTES.STREETCODES.UPDATE}`, streetcode),

updateState: (id: number, stateId: number) => Agent.put<void>(
`${API_ROUTES.STREETCODES.UPDATE_STATE}/${id}/${stateId}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ 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 { parse } from 'path';

import { FormInstance, Modal, UploadFile } from 'antd';
import FormItem from 'antd/es/form/FormItem';
Expand All @@ -35,7 +34,7 @@ const convertFileToUploadFile = (file: Image | Audio) => {
interface FileInputsPartProps {
form: FormInstance<unknown>; // Explicitly define the type for the 'form' prop
onChange: (propertyName: string, value: any) => void;
}
}

const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
const { createUpdateMediaStore } = useMobx();
Expand Down Expand Up @@ -166,7 +165,20 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
});
await AudiosApi.getByStreetcodeId(parseId).then((result) => {
setAudio(result ? [convertFileToUploadFile(result)] : []);
form.setFieldsValue({
audio: result ? [convertFileToUploadFile(result)] : [],
});
createUpdateMediaStore.audioId = result?.id;
if (result) {
const audioUpdate : AudioUpdate = {
id: result.id,
streetcodeId: parseId,
modelState: ModelState.Updated,
};
createUpdateMediaStore.audioUpdate = [audioUpdate];
} else {
createUpdateMediaStore.audioUpdate = [];
}
});
} catch (error) { /* empty */ } finally { /* empty */ }
};
Expand Down Expand Up @@ -249,7 +261,7 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
name = file.name.toLowerCase();
}
if (name.endsWith('.jpeg') || name.endsWith('.png') || name.endsWith('.webp')
|| name.endsWith('.jpg') || name === '') {
|| name.endsWith('.jpg') || name === '') {
return Promise.resolve();
}

Expand All @@ -270,7 +282,7 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
uploadTo="image"
beforeUpload={(file) => {
const isValid = (file.type === 'image/jpeg') || (file.type === 'image/webp')
|| (file.type === 'image/png') || (file.type === 'image/jpg');
|| (file.type === 'image/png') || (file.type === 'image/jpg');
if (!isValid) {
return Promise.reject();
}
Expand Down Expand Up @@ -303,7 +315,7 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
name = file.name.toLowerCase();
}
if (name.endsWith('.jpeg') || name.endsWith('.png') || name.endsWith('.webp')
|| name.endsWith('.jpg') || name === '') {
|| name.endsWith('.jpg') || name === '') {
setVisibleErrorRelatedFigure(false);
return Promise.resolve();
}
Expand All @@ -325,7 +337,7 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
uploadTo="image"
beforeUpload={(file) => {
const isValid = (file.type === 'image/jpeg')
|| (file.type === 'image/png') || (file.type === 'image/jpg' || (file.type === 'image/webp'));
|| (file.type === 'image/png') || (file.type === 'image/jpg' || (file.type === 'image/webp'));
if (!isValid) {
return Promise.reject();
}
Expand All @@ -344,7 +356,7 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
</FileUploader>
{visibleErrorRelatedFigure && (
<p className="error-text">
Тільки файли з розширенням webp, jpeg, png, jpg дозволені!
Тільки файли з розширенням webp, jpeg, png, jpg дозволені!
</p>
)}
</FormItem>
Expand Down Expand Up @@ -376,10 +388,11 @@ const FileInputsPart = ({ form, onChange }: FileInputsPartProps) => {
]}
>
<FileUploader
multiple={false}
accept=".mp3"
maxCount={1}
listType="picture-card"
{...(audio ? { fileList: audio } : null)}
fileList={audio}
uploadTo="audio"
onSuccessUpload={(file: Audio) => {
handleFileUpload(file.id, 'audioId', 'audioUpdate');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ import FRONTEND_ROUTES from '@/app/common/constants/frontend-routes.constants';
import Subtitle, { SubtitleCreate } from '@/models/additional-content/subtitles.model';
import { StreetcodeTag, StreetcodeTagUpdate } from '@/models/additional-content/tag.model';
import StatisticRecord from '@/models/analytics/statisticrecord.model';
import Image, { ImageAssigment, ImageCreateUpdate, ImageDetails } from '@/models/media/image.model';
import { AudioUpdate } from '@/models/media/audio.model';
import { ImageCreateUpdate, ImageDetails } from '@/models/media/image.model';
import { StreetcodeArtCreateUpdate } from '@/models/media/streetcode-art.model';
import Video, { VideoCreate } from '@/models/media/video.model';
import { PartnerCreateUpdateShort, PartnerUpdate } from '@/models/partners/partners.model';
import { StreetcodeCategoryContent, StreetcodeCategoryContentUpdate } from '@/models/sources/sources.model';
import { StreetcodeCreate, StreetcodeType, StreetcodeUpdate } from '@/models/streetcode/streetcode-types.model';
import { Fact, FactCreate, Text, TextCreateUpdate } from '@/models/streetcode/text-contents.model';
import { Fact, Text, TextCreateUpdate } from '@/models/streetcode/text-contents.model';
import TransactionLink from '@/models/transactions/transaction-link.model';

import ARBlock from './ARBlock/ARBlock.component';
Expand All @@ -50,6 +51,7 @@ import PartnerBlockAdmin from './PartnerBlock/PartnerBlockAdmin.components';
import SubtitleBlock from './SubtitileBlock/SubtitleBlock.component';
import TextBlock from './TextBlock/TextBlock.component';
import TimelineBlockAdmin from './TimelineBlock/TimelineBlockAdmin.component';
import { AudioUpdate } from '@/models/media/audio.model';

const NewStreetcode = () => {
const publish = 'Опублікувати';
Expand Down Expand Up @@ -331,10 +333,10 @@ const NewStreetcode = () => {
status: tempStatus,
toponyms: newStreetcodeInfoStore.selectedToponyms,
streetcodeCategoryContents:
JSON.parse(JSON.stringify(sourceCreateUpdateStreetcode.streetcodeCategoryContents))
.map((streetcodeCategoryContent: StreetcodeCategoryContent) => (
{ ...streetcodeCategoryContent, id: 0 }
)),
JSON.parse(JSON.stringify(sourceCreateUpdateStreetcode.streetcodeCategoryContents))
.map((streetcodeCategoryContent: StreetcodeCategoryContent) => (
{ ...streetcodeCategoryContent, id: 0 }
)),
statisticRecords: JSON.parse(JSON.stringify(statisticRecordStore.getStatisticRecordArray))
.map((statisticRecord: StatisticRecord) => (
{
Expand Down Expand Up @@ -370,7 +372,7 @@ const NewStreetcode = () => {
const videosUpdate: Video[] = [{ ...video, url: inputInfo?.link ?? '' } as Video];

const subtitleUpdate: Subtitle[] = [
{ ...subTitle, subtitleText: subTitle?.subtitleText ?? '' } as Subtitle];
{ ...subTitle, subtitleText: subTitle?.subtitleText ?? '' } as Subtitle];

const tags = [...(selectedTags as StreetcodeTagUpdate[])
.map((tag) => ({ ...tag, streetcodeId: parseId })),
Expand Down Expand Up @@ -423,16 +425,17 @@ const NewStreetcode = () => {
statisticRecords: statisticRecordStore.getStatisticRecordArrayToUpdate
.map((record) => ({ ...record, streetcodeId: parseId })),
toponyms: newStreetcodeInfoStore.selectedToponyms,
images: createUpdateMediaStore.imagesUpdate.map((img):ImageCreateUpdate => ({ id: img.id, modelState: img.modelState, streetcodeId: img.streetcodeId })),
audios: createUpdateMediaStore.audioUpdate,
images: createUpdateMediaStore.imagesUpdate.map((img): ImageCreateUpdate => ({ id: img.id, modelState: img.modelState, streetcodeId: img.streetcodeId })),
audioId: createUpdateMediaStore.audioId,
audios: createUpdateMediaStore.audioUpdate.map((a): AudioUpdate => ({ id: a.id, modelState: a.modelState, streetcodeId: a.streetcodeId })),
transactionLink: {
id: arLink?.id ?? 0,
streetcodeId: parseId,
url: form.getFieldValue('arlink') ?? '',
qrCodeUrl: arLink?.urlTitle ?? '',
modelState: 0,
},
imagesDetails: (Array.from(factsStore.factImageDetailsMap.values()) as ImageDetails []).concat(createUpdateMediaStore.getImageDetailsUpdate()),
imagesDetails: (Array.from(factsStore.factImageDetailsMap.values()) as ImageDetails[]).concat(createUpdateMediaStore.getImageDetailsUpdate()),
};

if (streetcodeType.current === StreetcodeType.Person) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface Props {
}

const NewsSliderItem = ({ news, image }: Props) => {

const isMobile = useMediaQuery({
query: '(max-width: 480px)',
});
Expand Down Expand Up @@ -55,7 +54,7 @@ const NewsSliderItem = ({ news, image }: Props) => {
</div>
<div className="newsSlideText">
<div className="newsContainer">
<div>
<div className="subContainer">
<h2 className="newsTitle">
{news?.title}
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
.newsContainer {
box-sizing: border-box;
width: 100%;
word-break: break-all;
word-break: break-word;
height: 193px;
@include mut.flexed(column, start, space-between, nowrap);
@include mut.rem-padded($top: 25px, $right: 30px, $bottom: 25px, $left: 30px);
Expand All @@ -97,6 +97,10 @@
@include mut.rem-padded($top: 15px, $right: 15px, $bottom: 15px, $left: 15px);
height: 300px;
}

.subContainer{
max-width: 100%;
}
}

.newsTitle {
Expand Down Expand Up @@ -154,7 +158,7 @@
@include mut.rem-margined(5px, 0px, 0px, 0px);
@include mut.rem-padded(0px, 5px, 0px, 0px);
color: c.$lighter-black-color;
word-break: break-all;
word-break: break-word;
@include mut.with-font(ft.$roboto-light, $font-weight: 300, $font-size: 15px);
line-height: 18px;
@media (min-width: 768px) and (max-width: 1024px) {
Expand All @@ -166,4 +170,4 @@
-webkit-line-clamp: 11;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@media (min-width: 768px) and (max-width: 1024px) {
@include mut.sized(250px, 338px);
}

@media screen and (max-width: 767px) {
@include mut.sized(294px, 398px);
}
Expand All @@ -58,25 +58,24 @@
@include mut.sized(100%, 338px);
margin: 0px;
}

@media screen and (max-width: 767px) {
@include mut.sized(100%, 398px);
margin: f.pxToRem(8px);
}
}

.teamImg {
@include mut.sized(100%, 100%);
overflow: visible !important;

object-fit: cover;

@media (min-width: 768px) and (max-width: 1024px) {
@include mut.sized(100%, 100%);
object-fit: cover;
}

@media screen and (max-width: 767px) {
@include mut.sized(100%, 100%);
object-fit: cover;
}
}

Expand Down Expand Up @@ -104,7 +103,7 @@
.teamLinkItem {
@include mut.rem-margined(0px, 17px, 0px, 0px);
}

@media screen and (max-width: 1024px) {
margin-top: f.pxToRem(4px);
@include mut.with-font(ft.$roboto-font, $font-weight: 500, $font-size: 20px);
Expand Down Expand Up @@ -138,7 +137,7 @@
height: 100%;
text-align: center;
}

@include mut.rem-padded(0px, 0px, 0px, 0px);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/media/audio.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export interface AudioCreate {

export interface AudioUpdate extends IModelState {
id: number;
streetcode?: number | null;
streetcodeId?: number | null;
}
1 change: 1 addition & 0 deletions src/models/streetcode/streetcode-types.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export interface StreetcodeUpdate {
statisticRecords: StatisticRecordUpdate[],
toponyms: ToponymCreateUpdate[],
images: ImageCreateUpdate[],
audioId: number | null,
audios: AudioUpdate[],
imagesDetails: ImageDetails[],
transactionLink: TransactionLinkUpdate;
Expand Down

0 comments on commit 41a2a5d

Please sign in to comment.