(user)
| 30 | }; |
| 31 | |
| 32 | export const userToFormValues = (user) => { |
| 33 | const customProps = user.custom_properties || {}; |
| 34 | const networks = customProps.allowed_networks || {}; |
| 35 | |
| 36 | return { |
| 37 | username: user.username, |
| 38 | first_name: user.first_name || '', |
| 39 | last_name: user.last_name || '', |
| 40 | email: user.email, |
| 41 | user_level: `${user.user_level}`, |
| 42 | stream_limit: user.stream_limit || 0, |
| 43 | channel_profiles: |
| 44 | user.channel_profiles.length > 0 |
| 45 | ? user.channel_profiles.map((id) => `${id}`) |
| 46 | : ['0'], |
| 47 | xc_password: customProps.xc_password || '', |
| 48 | output_format: customProps.output_format || '', |
| 49 | output_profile: customProps.output_profile |
| 50 | ? `${customProps.output_profile}` |
| 51 | : '', |
| 52 | hide_adult_content: customProps.hide_adult_content || false, |
| 53 | epg_days: customProps.epg_days || 0, |
| 54 | epg_prev_days: customProps.epg_prev_days || 0, |
| 55 | allowed_ips: [ |
| 56 | ...new Set( |
| 57 | NETWORK_KEYS.flatMap((key) => |
| 58 | networks[key] ? networks[key].split(',').filter(Boolean) : [] |
| 59 | ) |
| 60 | ), |
| 61 | ], |
| 62 | }; |
| 63 | }; |
| 64 | |
| 65 | export const formValuesToPayload = (values, existingUser) => { |
| 66 | const customProps = { ...(existingUser?.custom_properties || {}) }; |
no test coverage detected