Skip to content

Commit 2a8b7b5

Browse files
committed
feat: add free shipping banner
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
1 parent 1df3646 commit 2a8b7b5

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

flags.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"$schema": "./flags-schema.json",
33
"flags": {
4-
"offer-free-shipping": {
5-
"description": "Add free shipping to the UI.",
4+
"free-shipping-banner": {
5+
"description": "Controls the free shipping banner on the website. SHOP-4287",
66
"defaultValue": false,
77
"flagType": "boolean",
88
"state": "ENABLED",

src/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import Banner from "@/components/Banner";
1010
import heroImage from "../../public/img/hero.jpg";
1111

1212
import { useAutoAnimate } from "@formkit/auto-animate/react";
13-
import { useSuspenseOfferFreeShipping } from "@/generated/react/openfeature";
13+
import { useSuspenseFreeShippingBanner } from "@/generated/react/openfeature";
1414

1515
export default function Home() {
1616
const [parent] = useAutoAnimate();
17-
const { value: showBanner } = useSuspenseOfferFreeShipping();
17+
const { value: showBanner } = useSuspenseFreeShippingBanner();
1818

1919
return (
2020
<>

src/generated/react/openfeature.ts

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,50 @@
33
import {
44
type ReactFlagEvaluationOptions,
55
type ReactFlagEvaluationNoSuspenseOptions,
6+
type FlagQuery,
67
useFlag,
78
useSuspenseFlag,
9+
JsonValue
810
} from "@openfeature/react-sdk";
911

12+
// Flag key constants for programmatic access
13+
export const FlagKeys = {
14+
/** Flag key for Controls the free shipping banner on the website. SHOP-4287 */
15+
FREE_SHIPPING_BANNER: "free-shipping-banner",
16+
/** Flag key for Make the header stay at the top of the page while scrolling. */
17+
STICKY_HEADER: "sticky-header",
18+
/** Flag key for When on, use postgres else sqlite. */
19+
USE_DISTRIBUTED_DB: "use-distributed-db",
20+
/** Flag key for When on, use a secure connection to the database. This only applies when use-distributed-db is on. */
21+
USE_SECURE_PROTOCOL: "use-secure-protocol",
22+
} as const;
23+
24+
1025
/**
11-
* Add free shipping to the UI.
26+
* Controls the free shipping banner on the website. SHOP-4287
1227
*
1328
* **Details:**
14-
* - flag key: `offer-free-shipping`
29+
* - flag key: `free-shipping-banner`
1530
* - default value: `false`
1631
* - type: `boolean`
1732
*/
18-
export const useOfferFreeShipping = (options?: ReactFlagEvaluationOptions) => {
19-
return useFlag("offer-free-shipping", false, options);
33+
export const useFreeShippingBanner = (options?: ReactFlagEvaluationOptions): FlagQuery<boolean> => {
34+
return useFlag("free-shipping-banner", false, options);
2035
};
2136

2237
/**
23-
* Add free shipping to the UI.
38+
* Controls the free shipping banner on the website. SHOP-4287
2439
*
2540
* **Details:**
26-
* - flag key: `offer-free-shipping`
41+
* - flag key: `free-shipping-banner`
2742
* - default value: `false`
2843
* - type: `boolean`
2944
*
3045
* Equivalent to useFlag with options: `{ suspend: true }`
3146
* @experimental — Suspense is an experimental feature subject to change in future versions.
3247
*/
33-
export const useSuspenseOfferFreeShipping = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
34-
return useSuspenseFlag("offer-free-shipping", false, options);
48+
export const useSuspenseFreeShippingBanner = (options?: ReactFlagEvaluationNoSuspenseOptions): FlagQuery<boolean> => {
49+
return useSuspenseFlag("free-shipping-banner", false, options);
3550
};
3651

3752
/**
@@ -42,7 +57,7 @@ export const useSuspenseOfferFreeShipping = (options?: ReactFlagEvaluationNoSusp
4257
* - default value: `false`
4358
* - type: `boolean`
4459
*/
45-
export const useStickyHeader = (options?: ReactFlagEvaluationOptions) => {
60+
export const useStickyHeader = (options?: ReactFlagEvaluationOptions): FlagQuery<boolean> => {
4661
return useFlag("sticky-header", false, options);
4762
};
4863

@@ -57,7 +72,7 @@ export const useStickyHeader = (options?: ReactFlagEvaluationOptions) => {
5772
* Equivalent to useFlag with options: `{ suspend: true }`
5873
* @experimental — Suspense is an experimental feature subject to change in future versions.
5974
*/
60-
export const useSuspenseStickyHeader = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
75+
export const useSuspenseStickyHeader = (options?: ReactFlagEvaluationNoSuspenseOptions): FlagQuery<boolean> => {
6176
return useSuspenseFlag("sticky-header", false, options);
6277
};
6378

@@ -69,7 +84,7 @@ export const useSuspenseStickyHeader = (options?: ReactFlagEvaluationNoSuspenseO
6984
* - default value: `false`
7085
* - type: `boolean`
7186
*/
72-
export const useUseDistributedDb = (options?: ReactFlagEvaluationOptions) => {
87+
export const useUseDistributedDb = (options?: ReactFlagEvaluationOptions): FlagQuery<boolean> => {
7388
return useFlag("use-distributed-db", false, options);
7489
};
7590

@@ -84,7 +99,7 @@ export const useUseDistributedDb = (options?: ReactFlagEvaluationOptions) => {
8499
* Equivalent to useFlag with options: `{ suspend: true }`
85100
* @experimental — Suspense is an experimental feature subject to change in future versions.
86101
*/
87-
export const useSuspenseUseDistributedDb = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
102+
export const useSuspenseUseDistributedDb = (options?: ReactFlagEvaluationNoSuspenseOptions): FlagQuery<boolean> => {
88103
return useSuspenseFlag("use-distributed-db", false, options);
89104
};
90105

@@ -96,7 +111,7 @@ export const useSuspenseUseDistributedDb = (options?: ReactFlagEvaluationNoSuspe
96111
* - default value: `false`
97112
* - type: `boolean`
98113
*/
99-
export const useUseSecureProtocol = (options?: ReactFlagEvaluationOptions) => {
114+
export const useUseSecureProtocol = (options?: ReactFlagEvaluationOptions): FlagQuery<boolean> => {
100115
return useFlag("use-secure-protocol", false, options);
101116
};
102117

@@ -111,6 +126,6 @@ export const useUseSecureProtocol = (options?: ReactFlagEvaluationOptions) => {
111126
* Equivalent to useFlag with options: `{ suspend: true }`
112127
* @experimental — Suspense is an experimental feature subject to change in future versions.
113128
*/
114-
export const useSuspenseUseSecureProtocol = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
129+
export const useSuspenseUseSecureProtocol = (options?: ReactFlagEvaluationNoSuspenseOptions): FlagQuery<boolean> => {
115130
return useSuspenseFlag("use-secure-protocol", false, options);
116131
};

0 commit comments

Comments
 (0)