{"version":3,"sources":["theme.js","context/themeContext.js","hooks/useThemeMode.js","globalStyle.js","api/devices.js","pages/Home.js","App.js","serviceWorker.js","index.js"],"names":["theme","LIGHT","colors","primary","secondary","tertiary","grey","red","shadow","danger","warning","info","success","DARK","ThemeModeContext","createContext","useThemeMode","_useState","useState","mode","cookies","get","set","_useState2","Object","slicedToArray","themeMode","setThemeMode","newThemeMode","createGlobalStyle","_templateObject","props","remcalc","searchDevice","_ref","asyncToGenerator","regenerator_default","a","mark","_callee","serialNumber","res","wrap","_context","prev","next","axios","concat","headers","Authorization","sent","abrupt","t0","stop","_x","apply","this","arguments","StyledContainer","Styled","div","Home_templateObject","error","device","DeviceInfo","_templateObject2","InputContainer","_templateObject3","StyledText","Text","_templateObject4","Input","input","_templateObject5","Home","value","setValue","_useState3","_useState4","pending","setPending","_useState5","_useState6","valid","setValid","_useState7","_useState8","setDevice","_useState9","_useState10","setError","useEffect","handler","setTimeout","result","_valid","data","records","length","metadata","hd271","hd272","hw_baseboard","indexOf","device_uuid","clearTimeout","console","log","react_default","createElement","as","size","onChange","e","target","placeholder","mcloud_ui_esm","align","right","moment","createdAt","format","updatedAt","App","_useThemeMode","_useThemeMode2","toggleTheme","className","styled_components_browser_esm","themeContext","Provider","BrowserRouter","Route","exact","path","component","globalStyle","Boolean","window","location","hostname","match","ReactDOM","render","src_App","document","getElementById","navigator","serviceWorker","ready","then","registration","unregister"],"mappings":"sKAAeA,EAAA,CACbC,MAAO,CACLC,OAAQ,CACNC,QAAS,OACTC,UAAW,UACXC,SAAU,UACVC,KAAM,UACNC,IAAK,UACLC,OAAQ,mCACRC,OAAQ,UACRC,QAAS,UACTC,KAAM,UACNC,QAAS,YAGbC,KAAM,CACJX,OAAQ,CACNC,QAAS,UACTC,UAAW,UACXC,SAAU,UACVC,KAAM,UACNC,IAAK,UACLC,OAAQ,yCACRC,OAAQ,UACRC,QAAS,UACTC,KAAM,UACNC,QAAS,aCvBAE,EADUC,wBAAc,CAAC,GAAI,gCCC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A,KAAD,CAAMN,GAAG,IAAIC,KAAM,IACjBH,EAAAvE,EAAAwE,cAAA,8BADF,IACiC,IAC9B9C,EAAOkC,QAAQ,GAAGE,SAASC,MAAME,kBCxJjCqB,MAjBf,WAAe,IAAAC,EACoB5G,IADpB6G,EAAArG,OAAAC,EAAA,EAAAD,CAAAoG,EAAA,GACNlG,EADMmG,EAAA,GACKC,EADLD,EAAA,GAGb,OACEjB,EAAAvE,EAAAwE,cAAA,OAAKkB,UAAU,OACbnB,EAAAvE,EAAAwE,cAACmB,EAAA,cAAD,CAAehI,MAAOA,EAAK,OACzB4G,EAAAvE,EAAAwE,cAACoB,EAAiBC,SAAlB,CAA2BvD,MAAO,CAACjD,EAAWoG,IAC5ClB,EAAAvE,EAAAwE,cAACsB,EAAA,EAAD,KACEvB,EAAAvE,EAAAwE,cAACuB,EAAA,EAAD,CAAOC,OAAK,EAACC,KAAK,IAAIC,UAAW7D,KAEnCkC,EAAAvE,EAAAwE,cAAC2B,EAAD,UCTUC,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCZNC,IAASC,OAAOnC,EAAAvE,EAAAwE,cAACmC,EAAD,MAASC,SAASC,eAAe,SD2H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAMC,KAAK,SAAAC,GACjCA,EAAaC","file":"static/js/main.db4526c7.chunk.js","sourcesContent":["export default {\n LIGHT: {\n colors: {\n primary: '#fff',\n secondary: '#272822',\n tertiary: '#6d45ff',\n grey: '#f1f1f1',\n red: '#ff4949',\n shadow: 'rgba(0, 0, 0, 0.06) 0px 6px 20px',\n danger: '#96281b',\n warning: '#f15a22',\n info: '#1f3a93',\n success: '#1e824c',\n },\n },\n DARK: {\n colors: {\n primary: '#272822',\n secondary: '#f1f1f1',\n tertiary: '#ff9e9e',\n grey: '#404040',\n red: '#ff4949',\n shadow: 'rgba(255, 255, 255, 0.06) 0px 6px 20px',\n danger: '#ec644b',\n warning: '#f39c12',\n info: '#19b5fe',\n success: '#7befb2',\n },\n },\n};\n","import { createContext } from 'react';\n\nconst ThemeModeContext = createContext(['', () => {}]);\nexport default ThemeModeContext;\n","import { useState } from 'react';\nimport cookies from 'js-cookie';\n\nexport default () => {\n const getThemeMode = () => {\n let mode = cookies.get('mode_academy-builder');\n\n // set default to LIGHT\n if (!mode) {\n cookies.set('mode_academy-builder', 'LIGHT');\n mode = 'LIGHT';\n }\n\n return mode;\n };\n\n const [themeMode, setThemeMode] = useState(getThemeMode);\n\n const toggleTheme = () => {\n const newThemeMode = themeMode === 'LIGHT' ? 'DARK' : 'LIGHT';\n\n cookies.set('mode_academy-builder', newThemeMode);\n setThemeMode(newThemeMode);\n };\n\n return [themeMode, toggleTheme];\n};\n","import { createGlobalStyle } from 'styled-components'\nimport remcalc from 'remcalc'\n\nexport default createGlobalStyle`\n html {\n font-size: 100%; /* set base font-size for remcalc */\n font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, Helvetica, sans-serif;\n }\n\n body {\n background: ${props => props.theme.primary};\n color: ${props => props.theme.secondary};\n padding: 0;\n margin: 0;\n input {\n height: 35px;\n margin: 5px 0;\n font-size: 15px;\n border: 1px solid ${props => props.theme.grey};\n border-radius: 5px;\n font-size: 1.2rem;\n padding: 10px;\n width: 100%;\n margin-bottom: 20px;\n }\n textarea {\n border: 1px solid ${props => props.theme.grey};\n border-radius: 5px;\n font-size: 1.2rem;\n padding: 10px;\n width: 100%;\n height: 200px;\n }\n select {\n border: 1px solid ${props => props.theme.grey};\n border-radius: 5px;\n font-size: 1.2rem;\n padding: 10px;\n width: 100%;\n margin-bottom: 20px;\n }\n }\n\n a {\n color: inherit;\n text-decoration: none;\n }\n\n html, body, #app {\n width: 100%;\n height: 100%;\n background-color: ${props => props.theme.primary};\n overflow-x: hidden;\n }\n\n body {\n margin: 0px;\n padding: 0px;\n overflow-x: hidden;\n min-width: 320px;\n background-color: ${props => props.theme.primary};\n font-size: 14px;\n line-height: 1.4285em;\n color: ${props => props.theme.secondary};\n }\n\n input, textarea {\n color: ${props => props.theme.secondary} !important;\n }\n\n div {\n box-sizing: border-box;\n }\n\n h1, h2, h3, h4 {\n letter-spacing: 0.4px;\n margin: 0;\n }\n\n h1, h2, h3 {\n font-size: ${remcalc(20)};\n }\n\n h2 {\n font-weight: 700;\n color: ${props => props.theme.secondary};\n }\n \n h3 {\n font-weight: 600;\n color: ${props => props.theme.secondary};\n }\n\n h4, h5, h6 {\n font-size: ${remcalc(16)};\n }\n\n h4 {\n font-weight: 400;\n color: ${props => props.theme.secondary};\n }\n\n h5, h6 {\n font-weight: 300;\n color: ${props => props.theme.secondary};\n }\n\n`\n","import axios from 'axios';\nimport cookies from 'js-cookie';\n\nexport const searchDevice = async serialNumber => {\n try {\n const res = await axios.get(\n `api/v2/devices/${serialNumber}?expand=metadata`,\n {\n headers: {\n Authorization: `Bearer ${cookies.get('CLIENT_TOKEN')}`\n }\n }\n );\n return res;\n } catch (e) {\n throw e;\n }\n};\n","import React, { useState, useEffect } from 'react';\nimport Styled from 'styled-components';\nimport remcalc from 'remcalc';\nimport moment from 'moment';\n\nimport { Text } from '@cloud/mcloud-ui';\nimport { searchDevice } from '../api/devices';\n\nconst StyledContainer = Styled.div`\n height: 100vh;\n width: 100vw;\n color: white;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n background-color: ${props => props.theme.colors.info};\n ${props => props.error && `background-color: ${props.theme.colors.danger}`};\n ${props => props.device && `background-color: ${props.theme.colors.success}`};\n transition: background-color .2s ease-in-out;\n`;\n\nconst DeviceInfo = Styled.div`\n align-items: center;\n justify-content: center;\n flex-direction: column;\n`;\n\nconst InputContainer = Styled.div`\n display: flex;\n flex-direction: column;\n max-width: 700px;\n width: 100%;\n`;\n\nconst StyledText = Styled(Text)`\n margin-bottom: 20px;\n color: #96A9E9;\n ${props => props.error && `color: #F4C3BE`};\n ${props => props.device && `color: #AFD2A9`};\n`;\n\nconst Input = Styled.input`\n font-size: ${remcalc(26)};\n box-sizing: border-box;\n border-radius: 0;\n padding: 10px;\n width: 100%;\n max-width: 700px;\n height: 70px;\n border-color: #3E5BB9;\n ${props => props.device && `border-color: #32A266`};\n ${props => props.error && `border-color: #D40027`};\n`;\n\nconst Home = () => {\n const [value, setValue] = useState('');\n const [pending, setPending] = useState(false);\n const [valid, setValid] = useState(false);\n const [device, setDevice] = useState(null);\n const [error, setError] = useState(null);\n\n const onChange = e => {\n setValue(e.target.value);\n };\n\n const validateDevice = device => {\n if (device.records.length === 0) {\n setError('No device records found');\n return false;\n }\n\n if (!device.records[0].metadata) {\n setError('No device metadata found');\n return false;\n }\n\n if (!device.records[0].metadata.hd271) {\n setError('No data for HD271 board');\n return false;\n }\n\n if (!device.records[0].metadata.hd272) {\n setError('No data for HD272 board');\n return false;\n }\n\n if (!device.records[0].metadata.hd271.hw_baseboard) {\n setError('No hw_baseboard info found for HD271 board');\n return false;\n } else {\n if (device.records[0].metadata.hd271.hw_baseboard.indexOf('0x') === -1) {\n setError('Invalid format for HD271 hw_baseboard');\n return false;\n }\n }\n\n if (!device.records[0].metadata.hd271.device_uuid) {\n setError('No device_uuid info found for HD271 board');\n return false;\n }\n\n if (!device.records[0].metadata.hd272.device_uuid) {\n setError('No device_uuid info found for HD272 board');\n return false;\n }\n\n return true;\n };\n\n useEffect(() => {\n setError(null);\n setDevice(null);\n if (value) {\n setPending(true);\n const handler = setTimeout(async () => {\n setPending(false);\n try {\n const result = await searchDevice(value);\n const valid = validateDevice(result.data);\n setValid(valid);\n return setDevice(result.data);\n } catch (e) {\n setValid(false);\n return setError('No device found for that serial number');\n }\n }, 500);\n return () => {\n clearTimeout(handler);\n };\n }\n }, [value]);\n console.log(device);\n return (\n \n \n \n Serial Number Checker\n \n \n {pending && (\n \n Searching...\n \n )}\n {error && !valid && (\n \n {error}.\n \n )}\n {device && (\n \n \n Manufacture Date:{' '}\n {moment(device.createdAt).format('DD/MM/YYYY hh:mm')}\n \n \n Last Updated:{' '}\n {moment(device.updatedAt).format('DD/MM/YYYY hh:mm')}\n \n \n )}\n {device && valid && (\n \n {/* {`Device found`} */}\n \n hw_baseboard:{' '}\n {device.records[0].metadata.hd271.hw_baseboard}\n \n \n )}\n \n \n );\n};\n\nexport default Home;\n","import React from 'react';\nimport { BrowserRouter as Router, Route } from 'react-router-dom';\nimport { createGlobalStyle, ThemeProvider } from 'styled-components';\n\nimport theme from './theme';\nimport ThemeModeContext from './context/themeContext';\nimport useThemeMode from './hooks/useThemeMode';\nimport GlobalStyle from './globalStyle'\n\nimport Home from './pages/Home';\n\nfunction App() {\n const [themeMode, toggleTheme] = useThemeMode();\n\n return (\n
\n \n \n \n \n \n \n \n \n
\n );\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read http://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.1/8 is considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit http://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See http://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl)\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\n\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: http://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}