Skip to content

Commit

Permalink
Merge pull request #146 from 0101oak/oak/orders-media-product-fix
Browse files Browse the repository at this point in the history
fix orders, product media(thumbnail), hero
  • Loading branch information
ijustseeblood authored Oct 16, 2024
2 parents 03758ae + 63fdc65 commit 2601c78
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 34 deletions.
24 changes: 14 additions & 10 deletions src/components/common/singleMediaViewAndSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import styles from 'styles/product-id-media.scss';
interface SingleMediaView {
link: string | undefined;
isEditMode?: boolean;
isAddingProduct?: boolean;
aspectRatio?: string[];
hideVideos?: boolean;
saveSelectedMedia: (newSelectedMedia: common_MediaFull[]) => void;
Expand All @@ -16,6 +17,7 @@ interface SingleMediaView {
export const SingleMediaViewAndSelect: FC<SingleMediaView> = ({
link,
isEditMode,
isAddingProduct,
aspectRatio,
hideVideos,
saveSelectedMedia,
Expand All @@ -29,16 +31,18 @@ export const SingleMediaViewAndSelect: FC<SingleMediaView> = ({
) : (
<img src={link} alt='thumbnail' />
))}
<Grid item className={link ? styles.media_selector : styles.empty_media_selector}>
<MediaSelectorLayout
label={link ? 'edit' : 'select media'}
isEditMode={isEditMode}
allowMultiple={false}
aspectRatio={aspectRatio}
hideVideos={hideVideos}
saveSelectedMedia={saveSelectedMedia}
/>
</Grid>
{(isEditMode === undefined || isEditMode || isAddingProduct) && (
<Grid item className={link ? styles.media_selector : styles.empty_media_selector}>
<MediaSelectorLayout
label={link ? 'edit' : 'select media'}
isEditMode={isEditMode}
allowMultiple={false}
aspectRatio={aspectRatio}
hideVideos={hideVideos}
saveSelectedMedia={saveSelectedMedia}
/>
</Grid>
)}
</Grid>
</Grid>
);
Expand Down
6 changes: 5 additions & 1 deletion src/components/managers/hero/selectHeroType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ export const SelectHeroType: FC<SelectHeroType> = ({ arrayHelpers, entityRefs })
const isOtherEntitiesExist = values.entities?.some(
(entity) => entity.type !== 'HERO_TYPE_MAIN_ADD',
);
const isMainAddExists = values.entities?.some((entity) => entity.type === 'HERO_TYPE_MAIN_ADD');
const [addedEntityIndex, setAddedEntityIndex] = useState<number | null>(null);

const isMainAddExists = values.entities?.some((entity) => entity.type === 'HERO_TYPE_MAIN_ADD');

const isEntityIncomplete = values.entities?.some((entity) => {
const validateEntity = validationForSelectHeroType[entity.type as common_HeroType];
return validateEntity ? validateEntity(entity) : false;
});
const handleAddEntity = () => {
if (entityType === 'HERO_TYPE_MAIN_ADD' && isMainAddExists) {
return;
}
const newEntity = { ...emptyHeroForm.entities?.[0] };
newEntity.type = entityType as common_HeroType;
arrayHelpers.push(newEntity);
Expand Down
26 changes: 21 additions & 5 deletions src/components/managers/hero/utility/heroValidationShema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isValidUrl } from 'components/managers/archive/utility/isValidUrl';
import * as Yup from 'yup';

export const heroValidationSchema = Yup.object().shape({
Expand All @@ -10,7 +11,10 @@ export const heroValidationSchema = Yup.object().shape({
mainAdd: Yup.object().shape({
singleAdd: Yup.object().shape({
mediaId: Yup.number().min(1, 'Main Add Media is required'),
exploreLink: Yup.string().nullable(),
exploreLink: Yup.string().nullable().test(
'is-valid-url',
(value) => !value || isValidUrl(value),
),
exploreText: Yup.string().nullable(),
}),
}),
Expand All @@ -21,7 +25,10 @@ export const heroValidationSchema = Yup.object().shape({
type: Yup.string().required('Hero type is required'),
singleAdd: Yup.object().shape({
mediaId: Yup.number().min(1, 'Single Add Media is required'),
exploreLink: Yup.string().nullable(),
exploreLink: Yup.string().nullable().test(
'is-valid-url',
(value) => !value || isValidUrl(value),
),
exploreText: Yup.string().nullable(),
}),
});
Expand All @@ -32,12 +39,18 @@ export const heroValidationSchema = Yup.object().shape({
doubleAdd: Yup.object().shape({
left: Yup.object().shape({
mediaId: Yup.number().min(1, 'Left media is required'),
exploreLink: Yup.string().nullable(),
exploreLink: Yup.string().nullable().test(
'is-valid-url',
(value) => !value || isValidUrl(value),
),
exploreText: Yup.string().nullable(),
}),
right: Yup.object().shape({
mediaId: Yup.number().min(1, 'Right media is required'),
exploreLink: Yup.string().nullable(),
exploreLink: Yup.string().nullable().test(
'is-valid-url',
(value) => !value || isValidUrl(value),
),
exploreText: Yup.string().nullable(),
}),
}),
Expand All @@ -51,7 +64,10 @@ export const heroValidationSchema = Yup.object().shape({
.of(Yup.number().min(1))
.min(1, 'At least one product is required'),
title: Yup.string().nullable(),
exploreLink: Yup.string().nullable(),
exploreLink: Yup.string().nullable().test(
'is-valid-url',
(value) => !value || isValidUrl(value),
),
exploreText: Yup.string().nullable(),
}),
});
Expand Down
46 changes: 34 additions & 12 deletions src/components/managers/orders/orderDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,14 @@ export const OrderDetails = () => {
</div>
)}
{payment.paymentInsert?.transactionAmount && (
<div>
AMOUNT: {payment.paymentInsert?.transactionAmount.value}{' '}
{payment.paymentInsert?.transactionAmountPaymentCurrency?.value}
<div style={{ display: 'flex' }}>
AMOUNT:&nbsp;
{payment.paymentInsert.paymentMethod === 'PAYMENT_METHOD_NAME_ENUM_CARD' ||
payment.paymentInsert.paymentMethod === 'PAYMENT_METHOD_NAME_ENUM_CARD_TEST' ? (
<p>{payment.paymentInsert?.transactionAmountPaymentCurrency?.value}</p>
) : (
<p>{payment.paymentInsert?.transactionAmount.value}</p>
)}
</div>
)}
{payment.paymentInsert?.payer && (
Expand All @@ -293,15 +298,32 @@ export const OrderDetails = () => {
)}
{payment.paymentInsert?.isTransactionDone && (
<div style={{ display: 'flex', alignItems: 'center' }}>
TXID:&nbsp;
<CopyToClipboard
text={payment?.paymentInsert?.transactionId || ''}
displayText={
payment?.paymentInsert?.transactionId
? `${payment?.paymentInsert?.transactionId.slice(0, 4)}...${payment?.paymentInsert?.transactionId.slice(-4)}`
: ''
}
/>
{payment.paymentInsert?.paymentMethod === 'PAYMENT_METHOD_NAME_ENUM_CARD_TEST' ||
payment.paymentInsert?.paymentMethod === 'PAYMENT_METHOD_NAME_ENUM_CARD' ? (
<>
CLIENT SECRET:&nbsp;
<CopyToClipboard
text={payment.paymentInsert?.clientSecret || ''}
displayText={
payment.paymentInsert?.clientSecret
? `${payment.paymentInsert?.clientSecret.slice(0, 4)}...${payment.paymentInsert?.clientSecret.slice(-4)}`
: ''
}
/>
</>
) : (
<>
TXID:&nbsp;
<CopyToClipboard
text={payment?.paymentInsert?.transactionId || ''}
displayText={
payment?.paymentInsert?.transactionId
? `${payment?.paymentInsert?.transactionId.slice(0, 4)}...${payment?.paymentInsert?.transactionId.slice(-4)}`
: ''
}
/>
</>
)}
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const MediaView: FC<MediaViewInterface> = ({
imagePreviewUrl ||
product?.product?.productDisplay?.thumbnail?.media?.thumbnail?.mediaUrl
}
isEditMode={isEditMode}
isAddingProduct={isAddingProduct}
aspectRatio={['4:5']}
hideVideos={true}
saveSelectedMedia={uploadThumbnailInProduct}
Expand Down
7 changes: 1 addition & 6 deletions src/features/mediaSelector/mediaSelectorLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ export const MediaSelectorLayout: FC<MediaSelectorLayoutProps> = ({
return (
<Grid container justifyContent='center'>
<Grid item>
<Button
variant='contained'
size='medium'
onClick={handleMediaSelectorVisibility}
disabled={!isEditMode}
>
<Button variant='contained' size='medium' onClick={handleMediaSelectorVisibility}>
{label}
</Button>
</Grid>
Expand Down
1 change: 1 addition & 0 deletions src/styles/hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
display: flex;
align-items: center;
justify-content: center;
margin-top: 20px;
margin-bottom: 100px;
}
}

0 comments on commit 2601c78

Please sign in to comment.