Skip to content

Commit

Permalink
Redesigned the create form #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovert Lota Palonpon committed Mar 30, 2019
1 parent db169ff commit fa18ebb
Show file tree
Hide file tree
Showing 8 changed files with 758 additions and 454 deletions.
13 changes: 9 additions & 4 deletions app/Http/Controllers/Api/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,24 @@ public function index(Request $request) : JsonResponse
public function store(Request $request) : JsonResponse
{
$request->validate([
'type' => 'required|in:superuser,user',
'firstname' => 'required|string|max:255',
'lastname' => 'required|string|max:255',
'firstname' => 'required_if:step,0|string|max:255',
'lastname' => 'required_if:step,0|string|max:255',

'gender' => 'nullable|in:female,male',
'birthdate' =>
'nullable|date:Y-m-d|before:'.now()->subYear(10)->format('Y-m-d'),
'address' => 'nullable|string|max:510',

'email' => 'required|email|unique:users,email,NULL,id,deleted_at,NULL',
'type' => 'required_if:step,1|in:superuser,user',
'email' => 'required_if:step,1|email|unique:users,email,NULL,id,deleted_at,NULL',
'username' => 'nullable|unique:users'
]);

// Return here if the user is just in the first step.
if ($request->input('step') === 0) {
return response()->json(200);
}

$user = User::create([
'type' => $request->input('type'),
'firstname' => ($firstname = $request->input('firstname')),
Expand Down
23 changes: 23 additions & 0 deletions resources/js/ui/Loaders/LinearIndeterminate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';

import { LinearProgress, withStyles } from '@material-ui/core';

const LinearIndeterminate = props => (
<LinearProgress className={props.classes.root} />
);

const styles = theme => ({
root: {
margin: `0 ${theme.spacing.unit}px`,
minHeight: theme.spacing.unit,
borderTopRightRadius: '100%',
borderTopLeftRadius: '100%',
},
});

LinearIndeterminate.propTypes = {
classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(LinearIndeterminate);
1 change: 1 addition & 0 deletions resources/js/ui/Loaders/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as LinearDeterminate } from './LinearDeterminate';
export { default as LinearIndeterminate } from './LinearIndeterminate';
Loading

0 comments on commit fa18ebb

Please sign in to comment.