-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3 added energy label efficiency arrow preview to admin block
- Loading branch information
1 parent
642f035
commit 9a636e9
Showing
17 changed files
with
153 additions
and
30 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
apps/sfy-eu-blocks-app/admin-block-extension/src/components/EnergyLabelPreview.tsx
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,49 @@ | ||
import { | ||
Banner, | ||
BlockStack, | ||
Image, | ||
InlineStack, | ||
Link, | ||
Paragraph, | ||
Pressable | ||
} from '@shopify/ui-extensions-react/admin'; | ||
import React from 'react'; | ||
|
||
import { coreApiConfig, t } from '../environment'; | ||
import { TEnergyLabel } from '../lib'; | ||
|
||
export const EnergyLabelPreview: React.FC<TProps> = (props) => { | ||
const { energyLabel, primaryLocale } = props; | ||
const sheetUrl = React.useMemo( | ||
() => (energyLabel.sheetUrlMap as Record<string, string>)[primaryLocale], | ||
[energyLabel.sheetUrlMap, primaryLocale] | ||
); | ||
|
||
return ( | ||
<BlockStack gap> | ||
<InlineStack gap> | ||
<Pressable href={energyLabel.labelUrlMap.PDF} target="_blank"> | ||
<Image | ||
alt={`Energy Label Efficiency Class ${energyLabel.energyClass}`} | ||
source={`${coreApiConfig.baseUrl}/v1/energy-label/efficiency-class/arrow.svg?efficiencyClass=${energyLabel.energyClass}&size=26`} | ||
/> | ||
</Pressable> | ||
<Link href={sheetUrl} target="_blank"> | ||
Product Datasheet | ||
</Link> | ||
</InlineStack> | ||
{sheetUrl == null && ( | ||
<Banner title={t('banner.warning.noDatasheetForLocale.title')} tone="warning"> | ||
<Paragraph> | ||
{t('banner.warning.noDatasheetForLocale.content', { locale: primaryLocale })} | ||
</Paragraph> | ||
</Banner> | ||
)} | ||
</BlockStack> | ||
); | ||
}; | ||
|
||
interface TProps { | ||
energyLabel: TEnergyLabel; | ||
primaryLocale: string; | ||
} |
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
1 change: 1 addition & 0 deletions
1
apps/sfy-eu-blocks-app/admin-block-extension/src/components/index.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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './BannerBlock'; | ||
export * from './EnergyLabelPreview'; | ||
export * from './FormTextField'; | ||
export * from './LoadEnergyLabelSection'; | ||
export * from './UpdateEnergyLabelMetaFieldsSection'; |
2 changes: 1 addition & 1 deletion
2
apps/sfy-eu-blocks-app/admin-block-extension/src/environment/config/core-api.config.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const coreApiConfig = { | ||
baseUrl: 'https://rica-neither-reducing-legends.trycloudflare.com' // TODO: Find way to sync url from api-core-node | ||
baseUrl: 'https://excess-dear-samsung-blonde.trycloudflare.com' // TODO: Find way to sync url from api-core-node | ||
}; |
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
24 changes: 24 additions & 0 deletions
24
apps/sfy-eu-blocks-app/admin-block-extension/src/lib/graphql/get-shop-locales.query.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,24 @@ | ||
import { gql } from 'feature-fetch'; | ||
|
||
import { q } from '../../environment'; | ||
|
||
export async function getShopLocales() { | ||
return await q<{}, TGetShopLocalesQueryResponseData>( | ||
gql` | ||
query shopInfo { | ||
shopLocales { | ||
locale | ||
primary | ||
} | ||
} | ||
`, | ||
{} | ||
); | ||
} | ||
|
||
export interface TGetShopLocalesQueryResponseData { | ||
shopLocales: { | ||
locale: string; | ||
primary: boolean; | ||
}[]; | ||
} |
1 change: 1 addition & 0 deletions
1
apps/sfy-eu-blocks-app/admin-block-extension/src/lib/graphql/index.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './delete-metafield.mutation'; | ||
export * from './get-metafield.query'; | ||
export * from './get-shop-locales.query'; | ||
export * from './update-metafield.mutation'; |
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