@influto/react-native-sdk 1.2.0 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -126,7 +126,9 @@ const ReferralCodeInput = ({ autoPrefill = true, autoValidate = false, onValidat
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
const handleValidate = async (codeToValidate = code) => {
|
|
129
|
-
|
|
129
|
+
// Uppercase the code before validation
|
|
130
|
+
const uppercaseCode = codeToValidate.toUpperCase();
|
|
131
|
+
if (!uppercaseCode || uppercaseCode.length < 4) {
|
|
130
132
|
setState('invalid');
|
|
131
133
|
setValidationResult({
|
|
132
134
|
valid: false,
|
|
@@ -138,12 +140,12 @@ const ReferralCodeInput = ({ autoPrefill = true, autoValidate = false, onValidat
|
|
|
138
140
|
setState('validating');
|
|
139
141
|
setValidationResult(null);
|
|
140
142
|
try {
|
|
141
|
-
const result = await InfluTo_1.default.validateCode(
|
|
143
|
+
const result = await InfluTo_1.default.validateCode(uppercaseCode);
|
|
142
144
|
setValidationResult(result);
|
|
143
145
|
if (result.valid) {
|
|
144
146
|
setState('valid');
|
|
145
|
-
// Automatically set the code if valid
|
|
146
|
-
const setResult = await InfluTo_1.default.setReferralCode(
|
|
147
|
+
// Automatically set the code if valid (use uppercase version)
|
|
148
|
+
const setResult = await InfluTo_1.default.setReferralCode(uppercaseCode, appUserId);
|
|
147
149
|
if (setResult.success) {
|
|
148
150
|
onApplied?.(result);
|
|
149
151
|
}
|
|
@@ -225,7 +227,7 @@ const ReferralCodeInput = ({ autoPrefill = true, autoValidate = false, onValidat
|
|
|
225
227
|
},
|
|
226
228
|
style.input
|
|
227
229
|
], value: code, onChangeText: (text) => {
|
|
228
|
-
setCode(text
|
|
230
|
+
setCode(text);
|
|
229
231
|
if (state !== 'idle' && state !== 'validating') {
|
|
230
232
|
setState('idle');
|
|
231
233
|
setValidationResult(null);
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@influto/react-native-sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "InfluTo SDK for React Native - Track influencer referrals and conversions",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
|
+
"react-native": "lib/index.js",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"import": "./lib/index.js",
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
"files": [
|
|
20
21
|
"lib",
|
|
21
22
|
"src",
|
|
23
|
+
"ui.js",
|
|
22
24
|
"README.md",
|
|
23
25
|
"LICENSE"
|
|
24
26
|
],
|
|
@@ -228,7 +228,10 @@ export const ReferralCodeInput: React.FC<ReferralCodeInputProps> = ({
|
|
|
228
228
|
};
|
|
229
229
|
|
|
230
230
|
const handleValidate = async (codeToValidate: string = code) => {
|
|
231
|
-
|
|
231
|
+
// Uppercase the code before validation
|
|
232
|
+
const uppercaseCode = codeToValidate.toUpperCase();
|
|
233
|
+
|
|
234
|
+
if (!uppercaseCode || uppercaseCode.length < 4) {
|
|
232
235
|
setState('invalid');
|
|
233
236
|
setValidationResult({
|
|
234
237
|
valid: false,
|
|
@@ -242,14 +245,14 @@ export const ReferralCodeInput: React.FC<ReferralCodeInputProps> = ({
|
|
|
242
245
|
setValidationResult(null);
|
|
243
246
|
|
|
244
247
|
try {
|
|
245
|
-
const result = await InfluTo.validateCode(
|
|
248
|
+
const result = await InfluTo.validateCode(uppercaseCode);
|
|
246
249
|
setValidationResult(result);
|
|
247
250
|
|
|
248
251
|
if (result.valid) {
|
|
249
252
|
setState('valid');
|
|
250
253
|
|
|
251
|
-
// Automatically set the code if valid
|
|
252
|
-
const setResult = await InfluTo.setReferralCode(
|
|
254
|
+
// Automatically set the code if valid (use uppercase version)
|
|
255
|
+
const setResult = await InfluTo.setReferralCode(uppercaseCode, appUserId);
|
|
253
256
|
|
|
254
257
|
if (setResult.success) {
|
|
255
258
|
onApplied?.(result);
|
|
@@ -352,7 +355,7 @@ export const ReferralCodeInput: React.FC<ReferralCodeInputProps> = ({
|
|
|
352
355
|
]}
|
|
353
356
|
value={code}
|
|
354
357
|
onChangeText={(text) => {
|
|
355
|
-
setCode(text
|
|
358
|
+
setCode(text);
|
|
356
359
|
if (state !== 'idle' && state !== 'validating') {
|
|
357
360
|
setState('idle');
|
|
358
361
|
setValidationResult(null);
|
package/ui.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InfluTo SDK - UI Components Entry Point
|
|
3
|
+
*
|
|
4
|
+
* This file exists at the root level for Metro bundler compatibility.
|
|
5
|
+
* Metro doesn't support package.json "exports" field.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { ReferralCodeInput } from '@influto/react-native-sdk/ui';
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
module.exports = require('./lib/ui');
|