-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCatalogTrophiesLayoutView.tsx
More file actions
61 lines (55 loc) · 2.7 KB
/
CatalogTrophiesLayoutView.tsx
File metadata and controls
61 lines (55 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { useOfferLocalization } from '#base/hooks/index.ts';
import { useCatalogStore } from '#base/stores/useCatalogStore.ts';
import { FC, useEffect, useState } from 'react';
import { useShallow } from 'zustand/shallow';
import { CatalogPageImageView, CatalogPageTextView } from '../common';
import { CatalogOfferGridWidgetView, CatalogPriceDisplayWidget, CatalogPurchaseWidgetView, CatalogViewOfferWidgetView } from '../widgets';
import { CatalogLayoutProps } from './CatalogLayoutProps';
export const CatalogTrophiesLayoutView: FC<CatalogLayoutProps> = props =>
{
const { page = null, roomPreviewer = null, currentOffer = null } = props;
const [ trophyText, setTrophyText ] = useState<string>('');
const offerLocalization = useOfferLocalization(currentOffer);
const [
updateCurrentOfferOptions
] = useCatalogStore(
useShallow(state => [
state.updateCurrentOfferOptions
]));
useEffect(() => {
if(!currentOffer) return;
updateCurrentOfferOptions({
extraData: (trophyText || '')
});
}, [currentOffer, trophyText, updateCurrentOfferOptions]);
return (
<div className="grid h-full grid-cols-12 gap-2">
<div className="flex flex-col col-span-7 gap-2 overflow-hidden">
<CatalogOfferGridWidgetView />
<textarea className="w-full grow p-2 text-sm bg-gray-100 h-1/2" value={ trophyText || '' } onChange={ event => setTrophyText(event.target.value) } />
</div>
<div className="flex flex-col col-span-5 gap-1 overflow-hidden">
{(currentOffer === null) &&
<div className="flex flex-col items-center justify-center grow gap-2">
<CatalogPageImageView page={page} imageIndex={1} />
<CatalogPageTextView className="text-center" page={page} textIndex={0} />
</div>}
{(currentOffer !== null) &&
<>
<CatalogViewOfferWidgetView roomPreviewer={roomPreviewer} />
<div className="flex flex-col grow">
<span className="text-base truncate grow">
{offerLocalization.name}
</span>
<div className="flex flex-col justify-between gap-1">
<div className="flex justify-end">
<CatalogPriceDisplayWidget />
</div>
<CatalogPurchaseWidgetView />
</div>
</div>
</>}
</div>
</div>
)
}