-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: manufacturer information (#695)
* feat: implement manufacturer information * fix: manufacturer updates and increase package version * fix: trailing comma for lang json * fix: changelog lint * chore: lang change * chore: add translatation labels
- Loading branch information
1 parent
523a769
commit b62282e
Showing
16 changed files
with
225 additions
and
11 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
apps/web/components/ManufacturerInformation/ManufacturerInformation.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<template> | ||
<div v-if="manufacturerName || manufacturerExternalName"> | ||
<p v-if="manufacturerName">{{ manufacturerName }}</p> | ||
<p v-if="manufacturerExternalName">{{ manufacturerExternalName }}</p> | ||
</div> | ||
<div v-else> | ||
{{ t('manufacturer.noInformation') }} | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from 'vue'; | ||
import { productGetters } from '@plentymarkets/shop-api'; | ||
import type { ManufacturerInformationProps } from '~/components/ManufacturerInformation/types'; | ||
const props = defineProps<ManufacturerInformationProps>(); | ||
const { t } = useI18n(); | ||
const manufacturerName = computed(() => productGetters.getManufacturerName(props.product)); | ||
const manufacturerExternalName = computed(() => productGetters.getManufacturerExternalName(props.product)); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { Product } from '@plentymarkets/shop-api'; | ||
|
||
export type ManufacturerInformationProps = { | ||
product: Product; | ||
}; |
46 changes: 46 additions & 0 deletions
46
apps/web/components/ManufacturerResponsibleInfo/ManufacturerResponsibleInfo.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<template> | ||
<div v-if="hasAnyInfo"> | ||
<p v-if="manufacturerResponsibleInfo.name">{{ manufacturerResponsibleInfo.name }}</p> | ||
<p v-if="manufacturerResponsibleInfo.street || manufacturerResponsibleInfo.houseNo"> | ||
{{ manufacturerResponsibleInfo.street }} {{ manufacturerResponsibleInfo.houseNo }} | ||
</p> | ||
<p | ||
v-if=" | ||
manufacturerResponsibleInfo.postCode || manufacturerResponsibleInfo.town || manufacturerResponsibleInfo.country | ||
" | ||
> | ||
{{ manufacturerResponsibleInfo.postCode }} {{ manufacturerResponsibleInfo.town }}, | ||
{{ manufacturerResponsibleInfo.country }} | ||
</p> | ||
<p v-if="manufacturerResponsibleInfo.phoneNo">{{ t('phone') }}: {{ manufacturerResponsibleInfo.phoneNo }}</p> | ||
<p v-if="manufacturerResponsibleInfo.email">{{ t('email') }}: {{ manufacturerResponsibleInfo.email }}</p> | ||
</div> | ||
<div v-else> | ||
{{ t('manufacturer.noResponsibleInformation') }} | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from 'vue'; | ||
import { productGetters } from '@plentymarkets/shop-api'; | ||
import type { ManufacturerResponsibleInfoProps } from '~/components/ManufacturerResponsibleInfo/types'; | ||
const props = defineProps<ManufacturerResponsibleInfoProps>(); | ||
const { t } = useI18n(); | ||
const manufacturerResponsibleInfo = computed(() => ({ | ||
name: productGetters.getManufacturerResponsibleName(props.product), | ||
street: productGetters.getManufacturerResponsibleStreet(props.product), | ||
houseNo: productGetters.getManufacturerResponsibleHouseNo(props.product), | ||
postCode: productGetters.getManufacturerResponsiblePostCode(props.product), | ||
town: productGetters.getManufacturerResponsibleTown(props.product), | ||
country: productGetters.getManufacturerResponsibleCountry(props.product), | ||
email: productGetters.getManufacturerResponsibleEmail(props.product), | ||
phoneNo: productGetters.getManufacturerResponsiblePhoneNo(props.product), | ||
})); | ||
const hasAnyInfo = computed(() => { | ||
const info = manufacturerResponsibleInfo.value; | ||
return Object.values(info).some(Boolean); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { Product } from '@plentymarkets/shop-api'; | ||
|
||
export type ManufacturerResponsibleInfoProps = { | ||
product: Product; | ||
}; |
85 changes: 85 additions & 0 deletions
85
apps/web/components/ProductLegalDetailsDrawer/ProductLegalDetailsDrawer.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<template> | ||
<UiOverlay :visible="open"> | ||
<SfDrawer | ||
ref="productLegalDrawerRef" | ||
v-model="open" | ||
:placement="placement" | ||
:class="[ | ||
'bg-neutral-50', | ||
'border', | ||
'border-gray-300', | ||
'z-50', | ||
{ 'min-w-[400px]': placement === 'left' || placement === 'right' }, | ||
]" | ||
> | ||
<header class="flex items-center justify-between px-10 py-6 bg-primary-500"> | ||
<div class="flex items-center text-white">{{ t('productLegalDetailsHeader') }}</div> | ||
<UiButton square variant="tertiary" class="text-white" @click="open = false"> | ||
<SfIconClose /> | ||
</UiButton> | ||
</header> | ||
|
||
<div | ||
ref="tablistRef" | ||
role="tablist" | ||
aria-label="Select tab" | ||
aria-orientation="horizontal" | ||
class="flex gap-2 border-b border-b-neutral-200 p-4 overflow-x-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]" | ||
> | ||
<UiButton | ||
v-for="(tab, index) in tabs" | ||
:key="tab.label" | ||
type="button" | ||
role="tab" | ||
:variant="isActiveTab(index) ? 'primary' : 'secondary'" | ||
:aria-selected="isActiveTab(index)" | ||
:aria-controls="`tabpanel-${index}`" | ||
:disabled="tab.disabled" | ||
@click="setActiveTab(index)" | ||
> | ||
{{ tab.label }} | ||
</UiButton> | ||
</div> | ||
|
||
<div | ||
v-for="(tab, index) in tabs" | ||
:key="tab.label" | ||
role="tabpanel" | ||
:id="`tabpanel-${index}`" | ||
:aria-labelledby="`tab-${index}`" | ||
v-show="isActiveTab(index)" | ||
class="p-4" | ||
> | ||
<component :is="tab.component" :product="product" /> | ||
</div> | ||
</SfDrawer> | ||
</UiOverlay> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { SfDrawer, SfIconClose, SfDrawerPlacement, useTrapFocus } from '@storefront-ui/vue'; | ||
import { ProductLegalDetailsProps } from '~/components/ProductLegalDetailsDrawer/types'; | ||
import ManufacturerResponsibleInfo from '~/components/ManufacturerResponsibleInfo/ManufacturerResponsibleInfo.vue'; | ||
import ManufacturerInformation from '~/components/ManufacturerInformation/ManufacturerInformation.vue'; | ||
defineProps<ProductLegalDetailsProps>(); | ||
const { t } = useI18n(); | ||
const placement = ref<`${SfDrawerPlacement}`>('right'); | ||
const tabs = [ | ||
{ label: t('manufacturer.euResponsibleTabName'), component: ManufacturerResponsibleInfo, disabled: false }, | ||
{ label: t('manufacturer.manufacturerTabName'), component: ManufacturerInformation, disabled: false }, | ||
]; | ||
const activeTabIndex = ref(0); | ||
const isActiveTab = (index: number) => activeTabIndex.value === index; | ||
const setActiveTab = (index: number) => { | ||
activeTabIndex.value = index; | ||
}; | ||
const productLegalDrawerRef = ref(); | ||
const { open } = useProductLegalDetailsDrawer(); | ||
useTrapFocus(productLegalDrawerRef, { activeState: open }); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { Product } from '@plentymarkets/shop-api'; | ||
|
||
export type ProductLegalDetailsProps = { | ||
product: Product; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './types'; | ||
export * from './useProductLegalDetailsDrawer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type OpenDrawer = () => void; | ||
|
||
export interface UseProductLegalDetailsMethods { | ||
open: Readonly<Ref<boolean>>; | ||
openDrawer: OpenDrawer; | ||
} | ||
|
||
export type UseProductLegalDetailsMethodsReturn = () => UseProductLegalDetailsMethods; |
11 changes: 11 additions & 0 deletions
11
apps/web/composables/useProductLegalDetailsDrawer/useProductLegalDetailsDrawer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { UseProductLegalDetailsMethodsReturn } from './types'; | ||
|
||
const open = ref(false); | ||
|
||
const openDrawer = () => { | ||
open.value = true; | ||
}; | ||
|
||
export const useProductLegalDetailsDrawer: UseProductLegalDetailsMethodsReturn = () => { | ||
return { open, openDrawer }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters