Skip to content

Commit

Permalink
feat: change primary user role
Browse files Browse the repository at this point in the history
* speed up intellisense by excluding node_modules
* make sure app is rendered only on client side to avoid window not defined error

Signed-off-by: Rakib Ansary <[email protected]>
  • Loading branch information
rakibansary committed Mar 15, 2023
1 parent 94fceaf commit ced2605
Show file tree
Hide file tree
Showing 13 changed files with 703 additions and 21 deletions.
3 changes: 2 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"paths": {
"*": ["src/shared/*", "src/*", "node_modules/*"]
}
}
},
"exclude": ["node_modules", "build"]
}
70 changes: 53 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions src/shared/actions/identity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createActions } from 'redux-actions';
import { getService } from '../services/identity';

/**
* @static
* @desc Creates an action that signals beginning of updating users primary role.
* @return {Action}
*/
function updatePrimaryRoleInit() {}

/**
* @static
* @desc Update users primary role
* @param {String} role - role to be updated can be 'Topcoder Talent' or 'Topcoder Customer'
* @return {Action}
*/
async function updatePrimaryRoleDone(role, tokenV3) {
return getService(tokenV3).updatePrimaryRole(role);
}


export default createActions({
IDENTITY: {
UPDATE_PRIMARY_ROLE_INIT: updatePrimaryRoleInit,
UPDATE_PRIMARY_ROLE_DONE: updatePrimaryRoleDone,
},
});
8 changes: 5 additions & 3 deletions src/shared/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ if (process.env.NODE_ENV === 'production') {
/* eslint-enable global-require */

export default function App() {
if (!isomorphy.isClientSide()) {
return null;
}

return (
<div>
<Helmet htmlAttributes={{ lang: 'en' }}>
Expand All @@ -54,9 +58,7 @@ export default function App() {
/>
{isomorphy.isDevBuild() ? <DevTools /> : undefined}
{
config.GAMIFICATION.ENABLE_SKILLS_REMIND_MODAL
&& isomorphy.isClientSide()
? <Gamification /> : undefined
config.GAMIFICATION.ENABLE_SKILLS_REMIND_MODAL ? <Gamification /> : undefined
}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import PT from 'prop-types';

import './styles.scss';

const FormInputRadio = ({
text, value, selectedValue, onSelectionChange,
}) => {
const handleChange = () => {
onSelectionChange(value);
};

const inputId = `roundedInputFieldRadioGroup-${value}`;
return (
<div styleName="rounded-input-field">
<div styleName="input-text-wrapper">
<span styleName="input-text">{text}</span>
</div>
<label styleName="input-radio-wrapper" htmlFor={inputId}>
<input
type="radio"
id={inputId}
name="roundedInputFieldRadioGroup"
value={value}
checked={selectedValue === value}
onChange={handleChange}
styleName="input-radio"
/>
<span styleName="custom-radio" />
</label>
</div>
);
};


FormInputRadio.propTypes = {
text: PT.string.isRequired,
value: PT.string.isRequired,
selectedValue: PT.string.isRequired,
onSelectionChange: PT.func.isRequired,
};

export default FormInputRadio;
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
@import "~styles/mixins";

.rounded-input-field {
box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding-left: 16px;
width: calc(50% - 32px); // Subtract half the gap size from each button width
height: 72px;
background: #ffffff;
border: 1px solid #d4d4d4;
border-radius: 8px;
margin-right: 32px; // Add the other half of the gap size as margin
&:last-child {
margin-right: 0; // Remove margin from the last button
}
}


.input-option {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
width: 100%;
}

.input-text-wrapper {
display: flex;
align-items: center;
}

.input-text {
@include roboto-medium;

font-size: 16px;
line-height: 20px;
letter-spacing: 0.5px;
text-transform: capitalize;
color: $tco-black;
flex-grow: 0;
}

.input-radio-wrapper {
position: relative;
display: flex;
align-items: center;
flex: none;
order: 0;
align-self: stretch;
flex-grow: 0;
}

.input-radio {
position: absolute;
opacity: 0;
width: 20px;
height: 20px;
cursor: pointer;
z-index: 1;
}

.custom-radio {
position: absolute;
right: 16px;
top: 55%;
transform: translateY(-50%);
width: 20px;
height: 20px;
background-color: white;
border: 2px solid #aaa;
border-radius: 50%;
cursor: pointer;
}

.input-radio:checked ~ .custom-radio {
border-color: #137D60;
}

.input-radio:checked ~ .custom-radio::after {
content: "";
position: absolute;
width: 10px;
height: 10px;
background-color: #137D60;
border-radius: 50%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}

Loading

0 comments on commit ced2605

Please sign in to comment.