|
1 | 1 | /* |
2 | 2 | * ping-sample-web-react-davinci |
3 | 3 | * |
4 | | - * object-value.js |
| 4 | + * phone-number.js |
5 | 5 | * |
6 | | - * Copyright (c) 2025 - 2026 Ping Identity Corporation. All rights reserved. |
| 6 | + * Copyright (c) 2026 Ping Identity Corporation. All rights reserved. |
7 | 7 | * This software may be modified and distributed under the terms |
8 | 8 | * of the MIT license. See the LICENSE file for details. |
9 | 9 | */ |
10 | 10 |
|
11 | | -import React, { useEffect, useContext, useState } from 'react'; |
12 | | -import { ThemeContext } from '../../context/theme.context.js'; |
| 11 | +import React, { useState } from 'react'; |
13 | 12 |
|
14 | | -export default function ObjectValueComponent({ collector, updater, inputName }) { |
15 | | - const [selectedDevice, setSelectedDevice] = useState( |
16 | | - collector.output.options?.[0]?.value ?? null, |
17 | | - ); |
| 13 | +export default function PhoneNumberComponent({ collector, updater, inputName }) { |
18 | 14 | const [phoneValue, setPhoneValue] = useState({ |
19 | 15 | phoneNumber: collector.input.value?.phoneNumber ?? '', |
20 | 16 | extension: collector.input.value?.extension ?? '', |
21 | 17 | }); |
22 | | - const theme = useContext(ThemeContext); |
23 | 18 |
|
24 | | - useEffect(() => { |
25 | | - if ( |
26 | | - collector.type === 'DeviceAuthenticationCollector' || |
27 | | - collector.type === 'DeviceRegistrationCollector' |
28 | | - ) { |
29 | | - updater(selectedDevice); |
30 | | - } |
31 | | - }, [selectedDevice, updater, collector.type]); |
32 | | - |
33 | | - const handleChangeDevice = (event) => { |
34 | | - event.preventDefault(); |
35 | | - setSelectedDevice(event.target.value); |
36 | | - }; |
37 | | - if ( |
38 | | - collector.type === 'DeviceAuthenticationCollector' || |
39 | | - collector.type === 'DeviceRegistrationCollector' |
40 | | - ) { |
41 | | - return ( |
42 | | - <div className="d-flex flex-column align-items-center mt-2 mb-2"> |
43 | | - <label |
44 | | - htmlFor="device-select" |
45 | | - className={`form-label cstm_subhead-text mb-4 fw-bold text-center ${theme.textMutedClass}`} |
46 | | - > |
47 | | - {collector.output.label || 'select an option'} |
48 | | - </label> |
49 | | - <select |
50 | | - id="device-select" |
51 | | - className="form-select form-select-lg w-100" |
52 | | - value={selectedDevice} |
53 | | - onChange={handleChangeDevice} |
54 | | - > |
55 | | - {collector.output.options.map((option) => ( |
56 | | - <option key={option.value + option.label} value={option.value}> |
57 | | - {option.label} |
58 | | - </option> |
59 | | - ))} |
60 | | - </select> |
61 | | - <button className="mt-5 justify-content w-100 btn btn-primary">Next</button> |
62 | | - </div> |
63 | | - ); |
64 | | - } else if (collector.type === 'PhoneNumberCollector') { |
| 19 | + if (collector.type === 'PhoneNumberCollector') { |
65 | 20 | const phoneInputId = `${inputName}-phone-number`; |
66 | 21 | const required = collector.input.validation?.some( |
67 | 22 | (validation) => validation.type === 'required' && validation.rule === true, |
@@ -146,6 +101,6 @@ export default function ObjectValueComponent({ collector, updater, inputName }) |
146 | 101 | </> |
147 | 102 | ); |
148 | 103 | } else { |
149 | | - return null; // Or handle other collector types, if applicable |
| 104 | + return null; |
150 | 105 | } |
151 | 106 | } |
0 commit comments