Skip to content

Commit

Permalink
wip (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovert Lota Palonpon authored Apr 28, 2019
1 parent 4fa0864 commit 86f718e
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 44 deletions.
6 changes: 3 additions & 3 deletions resources/js/core/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const Navigator = props => {
return (
<Redirect
to={{
search: UrlUtils._queryString({
search: UrlUtils.queryString({
username,
}),
pathname: NavigationUtils._route(
pathname: NavigationUtils.route(
'auth.signin',
),
}}
Expand All @@ -40,7 +40,7 @@ const Navigator = props => {
if (authenticated) {
return (
<Redirect
to={NavigationUtils._route(
to={NavigationUtils.route(
`${environment}.home`,
)}
/>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/index.backoffice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './bootstrap';
import React from 'react';
import ReactDOM from 'react-dom';

import { _register as registerServiceWorker } from './utils/ServiceWorker';
import { register as registerServiceWorker } from './utils/ServiceWorker';
import App from './App';
import { dark as darkTheme, light as lightTheme } from './themes/backoffice';

Expand Down
4 changes: 2 additions & 2 deletions resources/js/utils/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as UrlUtils from '../utils/URL';
* @param {object} segmentParams
* @param {object} queryParams
*/
export function _route(name, segmentParams = {}, queryParams = {}) {
export function route(name, segmentParams = {}, queryParams = {}) {
const i = ROUTES.findIndex(route => route.name === name);

if (i < 0) {
Expand All @@ -31,7 +31,7 @@ export function _route(name, segmentParams = {}, queryParams = {}) {

// We will append a query string if there are query parameters provided.
if (segmentParams && Object.values(segmentParams).length > 0) {
routePath = `${routePath}${UrlUtils._queryString(queryParams)}`;
routePath = `${routePath}${UrlUtils.queryString(queryParams)}`;
}

return routePath;
Expand Down
2 changes: 1 addition & 1 deletion resources/js/utils/Random.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @return {string}
*/
export const _color = key => {
export const color = key => {
const colors = [
'red',
'pink',
Expand Down
2 changes: 1 addition & 1 deletion resources/js/utils/ServiceWorker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Register the service worker file.
*/
export function _register(serviceWorkerFile) {
export function register(serviceWorkerFile) {
if ('serviceWorker' in navigator) {
if (serviceWorkerFile) {
navigator.serviceWorker
Expand Down
4 changes: 2 additions & 2 deletions resources/js/utils/String.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @return {string}
*/
export function _uppercaseFirst(string) {
export function uppercaseFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

Expand All @@ -18,6 +18,6 @@ export function _uppercaseFirst(string) {
*
* @return {string}
*/
export function _limit(string, count, delimiter = '...') {
export function limit(string, count, delimiter = '...') {
return string.slice(0, count) + (string.length > count ? delimiter : '');
}
4 changes: 2 additions & 2 deletions resources/js/utils/URL.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @return {object}
*/
export function _queryParams(queryString) {
export function queryParams(queryString) {
let pairs = queryString
.substring(1)
.replace(/&$/, '')
Expand All @@ -29,7 +29,7 @@ export function _queryParams(queryString) {
*
* @return {string}
*/
export function _queryString(queryParams) {
export function queryString(queryParams) {
var paramString = '?';

for (let param in queryParams) {
Expand Down
6 changes: 3 additions & 3 deletions resources/js/views/__backoffice/layouts/Master.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function Master(props) {
component={linkProps => (
<RouterLink
{...linkProps}
to={NavigationUtils._route(
to={NavigationUtils.route(
'backoffice.home',
)}
/>
Expand All @@ -149,7 +149,7 @@ function Master(props) {
key={key}
className={classes.breadcrumbItem}
>
{StringUtils._uppercaseFirst(segment)}
{StringUtils.uppercaseFirst(segment)}
</Typography>
);

Expand Down Expand Up @@ -177,7 +177,7 @@ function Master(props) {
)}
className={classes.breadcrumbItem}
>
{StringUtils._uppercaseFirst(segment)}
{StringUtils.uppercaseFirst(segment)}
</Link>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions resources/js/views/__backoffice/partials/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const UserAvatar = props => {
<Avatar
style={{
fontSize: 17,
backgroundColor: RandomUtils._color(
backgroundColor: RandomUtils.color(
user.firstname.length -
user.created_at.charAt(user.created_at.length - 2),
),
Expand Down Expand Up @@ -204,7 +204,7 @@ const AccountMenu = props => {
<MenuItem
onClick={() =>
navigate(
NavigationUtils._route(
NavigationUtils.route(
'backoffice.settings.profile',
),
)
Expand Down
6 changes: 3 additions & 3 deletions resources/js/views/__backoffice/partials/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function Sidebar(props) {
<DashboardIcon />
</Tooltip>
),
path: NavigationUtils._route('backoffice.home'),
path: NavigationUtils.route('backoffice.home'),
};

const linkGroups = [
Expand All @@ -82,7 +82,7 @@ function Sidebar(props) {
<PeopleIcon />
</Tooltip>
),
path: NavigationUtils._route(
path: NavigationUtils.route(
'backoffice.resources.users.index',
),
},
Expand Down Expand Up @@ -254,7 +254,7 @@ function Sidebar(props) {
) : (
<ListItem>
<Typography noWrap color="textSecondary">
{StringUtils._limit(
{StringUtils.limit(
links
.map(link => link.name)
.join(', '),
Expand Down
2 changes: 1 addition & 1 deletion resources/js/views/__backoffice/settings/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function Account(props) {
};

useEffect(() => {
const queryParams = UrlUtils._queryParams(location.search);
const queryParams = UrlUtils.queryParams(location.search);

if (queryParams.hasOwnProperty('visible')) {
setFormVisibility(true);
Expand Down
2 changes: 1 addition & 1 deletion resources/js/views/__backoffice/settings/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function Profile(props) {
};

useEffect(() => {
const queryParams = UrlUtils._queryParams(location.search);
const queryParams = UrlUtils.queryParams(location.search);

if (queryParams.hasOwnProperty('visible')) {
setFormVisibility(true);
Expand Down
2 changes: 1 addition & 1 deletion resources/js/views/__backoffice/users/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function Create(props) {
user={user}
handleSkip={() =>
history.push(
NavigationUtils._route(
NavigationUtils.route(
'backoffice.resources.users.index',
),
)
Expand Down
4 changes: 2 additions & 2 deletions resources/js/views/__backoffice/users/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Edit(props) {
const { params } = props.match;
const { location } = props;

const queryParams = UrlUtils._queryParams(location.search);
const queryParams = UrlUtils.queryParams(location.search);

if (queryParams.hasOwnProperty('step')) {
setActiveStep(parseInt(queryParams.step));
Expand Down Expand Up @@ -207,7 +207,7 @@ function Edit(props) {
user={user}
handleSkip={() =>
history.push(
NavigationUtils._route(
NavigationUtils.route(
'backoffice.resources.users.index',
),
)
Expand Down
12 changes: 6 additions & 6 deletions resources/js/views/__backoffice/users/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function List(props) {
const { current_page: page, per_page: perPage } = pagination;
const { by: sortBy, type: sortType } = sorting;

const queryString = UrlUtils._queryString({
const queryString = UrlUtils.queryString({
page,
perPage,
sortBy,
Expand All @@ -315,7 +315,7 @@ function List(props) {

const { location } = props;
const queryParams = location.search
? UrlUtils._queryParams(location.search)
? UrlUtils.queryParams(location.search)
: {};

const prevFilters = {};
Expand Down Expand Up @@ -350,7 +350,7 @@ function List(props) {
}),
clicked: () =>
history.push(
NavigationUtils._route('backoffice.resources.users.create'),
NavigationUtils.route('backoffice.resources.users.create'),
),
};

Expand Down Expand Up @@ -396,7 +396,7 @@ function List(props) {
<Avatar
style={{
fontSize: 17,
backgroundColor: RandomUtils._color(
backgroundColor: RandomUtils.color(
user.firstname.length -
user.created_at.charAt(
user.created_at.length - 2,
Expand Down Expand Up @@ -427,7 +427,7 @@ function List(props) {
<IconButton
onClick={() =>
history.push(
NavigationUtils._route(
NavigationUtils.route(
'backoffice.resources.users.edit',
{
id: user.id,
Expand All @@ -451,7 +451,7 @@ function List(props) {
<IconButton
onClick={() =>
history.push(
NavigationUtils._route(
NavigationUtils.route(
'backoffice.resources.users.edit',
{
id: user.id,
Expand Down
8 changes: 4 additions & 4 deletions resources/js/views/auth/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function SignIn(props) {
setUsername(response.data);
setLoading(false);

const queryString = UrlUtils._queryString({
const queryString = UrlUtils.queryString({
username: response.data,
});

Expand Down Expand Up @@ -181,7 +181,7 @@ function SignIn(props) {

const { location } = props;

const q = UrlUtils._queryParams(location.search);
const q = UrlUtils.queryParams(location.search);

if (q.hasOwnProperty('username') && q.username !== '') {
identify(q.username, {});
Expand Down Expand Up @@ -316,12 +316,12 @@ function SignIn(props) {
<RouterLink
{...props}
to={{
search: UrlUtils._queryString(
search: UrlUtils.queryString(
{
username,
},
),
pathname: NavigationUtils._route(
pathname: NavigationUtils.route(
'auth.passwords.request',
),
}}
Expand Down
12 changes: 6 additions & 6 deletions resources/js/views/auth/passwords/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function PasswordRequest(props) {

const { history } = props;
const { email } = values;
const routeSuffix = NavigationUtils._route('auth.passwords.reset');
const routeSuffix = NavigationUtils.route('auth.passwords.reset');

await axios.post('api/v1/auth/password/request', {
email,
Expand Down Expand Up @@ -76,8 +76,8 @@ function PasswordRequest(props) {
const { location } = props;

setEmail(
UrlUtils._queryParams(location.search).hasOwnProperty('username')
? UrlUtils._queryParams(location.search).username
UrlUtils.queryParams(location.search).hasOwnProperty('username')
? UrlUtils.queryParams(location.search).username
: '',
);
});
Expand All @@ -96,7 +96,7 @@ function PasswordRequest(props) {
<Formik
initialValues={{
email: !email
? UrlUtils._queryParams(location.search).username
? UrlUtils.queryParams(location.search).username
: email,
}}
onSubmit={handleRequestPasswordSubmit}
Expand Down Expand Up @@ -144,10 +144,10 @@ function PasswordRequest(props) {
<RouterLink
{...props}
to={{
search: UrlUtils._queryString({
search: UrlUtils.queryString({
username: email,
}),
pathname: NavigationUtils._route(
pathname: NavigationUtils.route(
'auth.signin',
),
}}
Expand Down
6 changes: 3 additions & 3 deletions resources/js/views/auth/passwords/Reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function PasswordReset(props) {

const { location } = props;

const queryParams = UrlUtils._queryParams(location.search);
const queryParams = UrlUtils.queryParams(location.search);

if (!queryParams.hasOwnProperty('email')) {
return;
Expand Down Expand Up @@ -269,10 +269,10 @@ function PasswordReset(props) {
<RouterLink
{...props}
to={{
search: UrlUtils._queryString({
search: UrlUtils.queryString({
username: email,
}),
pathname: NavigationUtils._route(
pathname: NavigationUtils.route(
'auth.signin',
),
}}
Expand Down

0 comments on commit 86f718e

Please sign in to comment.