mirror of https://github.com/open-feature/cli.git
145 lines
4.0 KiB
Plaintext
145 lines
4.0 KiB
Plaintext
'use client';
|
|
|
|
import {
|
|
type ReactFlagEvaluationOptions,
|
|
type ReactFlagEvaluationNoSuspenseOptions,
|
|
useFlag,
|
|
useSuspenseFlag,
|
|
JsonValue
|
|
} from "@openfeature/react-sdk";
|
|
|
|
/**
|
|
* Discount percentage applied to purchases.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `discountPercentage`
|
|
* - default value: `0.15`
|
|
* - type: `number`
|
|
*/
|
|
export const useDiscountPercentage = (options?: ReactFlagEvaluationOptions) => {
|
|
return useFlag("discountPercentage", 0.15, options);
|
|
};
|
|
|
|
/**
|
|
* Discount percentage applied to purchases.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `discountPercentage`
|
|
* - default value: `0.15`
|
|
* - type: `number`
|
|
*
|
|
* Equivalent to useFlag with options: `{ suspend: true }`
|
|
* @experimental — Suspense is an experimental feature subject to change in future versions.
|
|
*/
|
|
export const useSuspenseDiscountPercentage = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
|
|
return useSuspenseFlag("discountPercentage", 0.15, options);
|
|
};
|
|
|
|
/**
|
|
* Controls whether Feature A is enabled.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `enableFeatureA`
|
|
* - default value: `false`
|
|
* - type: `boolean`
|
|
*/
|
|
export const useEnableFeatureA = (options?: ReactFlagEvaluationOptions) => {
|
|
return useFlag("enableFeatureA", false, options);
|
|
};
|
|
|
|
/**
|
|
* Controls whether Feature A is enabled.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `enableFeatureA`
|
|
* - default value: `false`
|
|
* - type: `boolean`
|
|
*
|
|
* Equivalent to useFlag with options: `{ suspend: true }`
|
|
* @experimental — Suspense is an experimental feature subject to change in future versions.
|
|
*/
|
|
export const useSuspenseEnableFeatureA = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
|
|
return useSuspenseFlag("enableFeatureA", false, options);
|
|
};
|
|
|
|
/**
|
|
* The message to use for greeting users.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `greetingMessage`
|
|
* - default value: `Hello there!`
|
|
* - type: `string`
|
|
*/
|
|
export const useGreetingMessage = (options?: ReactFlagEvaluationOptions) => {
|
|
return useFlag("greetingMessage", "Hello there!", options);
|
|
};
|
|
|
|
/**
|
|
* The message to use for greeting users.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `greetingMessage`
|
|
* - default value: `Hello there!`
|
|
* - type: `string`
|
|
*
|
|
* Equivalent to useFlag with options: `{ suspend: true }`
|
|
* @experimental — Suspense is an experimental feature subject to change in future versions.
|
|
*/
|
|
export const useSuspenseGreetingMessage = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
|
|
return useSuspenseFlag("greetingMessage", "Hello there!", options);
|
|
};
|
|
|
|
/**
|
|
* Allows customization of theme colors.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `themeCustomization`
|
|
* - default value: `{"primaryColor":"#007bff","secondaryColor":"#6c757d"}`
|
|
* - type: `JsonValue`
|
|
*/
|
|
export const useThemeCustomization = (options?: ReactFlagEvaluationOptions) => {
|
|
return useFlag("themeCustomization", {"primaryColor":"#007bff","secondaryColor":"#6c757d"}, options);
|
|
};
|
|
|
|
/**
|
|
* Allows customization of theme colors.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `themeCustomization`
|
|
* - default value: `{"primaryColor":"#007bff","secondaryColor":"#6c757d"}`
|
|
* - type: `JsonValue`
|
|
*
|
|
* Equivalent to useFlag with options: `{ suspend: true }`
|
|
* @experimental — Suspense is an experimental feature subject to change in future versions.
|
|
*/
|
|
export const useSuspenseThemeCustomization = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
|
|
return useSuspenseFlag("themeCustomization", {"primaryColor":"#007bff","secondaryColor":"#6c757d"}, options);
|
|
};
|
|
|
|
/**
|
|
* Maximum allowed length for usernames.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `usernameMaxLength`
|
|
* - default value: `50`
|
|
* - type: `number`
|
|
*/
|
|
export const useUsernameMaxLength = (options?: ReactFlagEvaluationOptions) => {
|
|
return useFlag("usernameMaxLength", 50, options);
|
|
};
|
|
|
|
/**
|
|
* Maximum allowed length for usernames.
|
|
*
|
|
* **Details:**
|
|
* - flag key: `usernameMaxLength`
|
|
* - default value: `50`
|
|
* - type: `number`
|
|
*
|
|
* Equivalent to useFlag with options: `{ suspend: true }`
|
|
* @experimental — Suspense is an experimental feature subject to change in future versions.
|
|
*/
|
|
export const useSuspenseUsernameMaxLength = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
|
|
return useSuspenseFlag("usernameMaxLength", 50, options);
|
|
};
|