Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript Integration #73

Merged
merged 32 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
145979a
ts refactor part 1
liorocks2 May 20, 2024
0bbf3f8
add types
liorocks2 May 20, 2024
5cb92f5
refactor table components
liorocks2 May 20, 2024
1840a0d
wip
liorocks2 May 21, 2024
454dc28
remove react-helmet
liorocks2 May 21, 2024
1ff8969
form elements wip
liorocks2 May 21, 2024
9419937
refactor more ts
liorocks2 May 21, 2024
732a3fb
simplify Table
liorocks2 May 21, 2024
7d33650
fix more types
liorocks2 May 21, 2024
ee33d7b
Shared -> components
liorocks2 May 21, 2024
609be25
pages__ wip
liorocks2 May 21, 2024
12ccfe5
Pages -> pages
liorocks2 May 21, 2024
1864f2f
wip
liorocks2 May 21, 2024
e826afb
icons wip
liorocks2 May 21, 2024
b452e7e
switch to lucide-icons
liorocks2 May 21, 2024
b6ad458
switch to tailwind forms
liorocks2 May 21, 2024
d0240da
fix failing test
liorocks2 May 21, 2024
8ca2f54
pages dir
liorocks2 May 21, 2024
15ffd62
revert to use Pages dir again
liorocks2 May 21, 2024
5bf95fc
minor ui tweaks
liorocks2 May 21, 2024
35045e3
__components__
liorocks2 May 21, 2024
b3ea3e5
Components dir are now just like in breeze
liorocks2 May 21, 2024
a297ed1
fix: search filter
liorocks2 May 23, 2024
ca1b41a
fix avatar upload and display
liorocks2 May 23, 2024
81ca1e8
create user file input ts fix
liorocks2 May 23, 2024
824fd33
remove type=text from inputs
liorocks2 May 23, 2024
d87221a
add fieldgroup
liorocks2 May 23, 2024
aaa7181
Layouts dir + component refactoring
liorocks2 May 23, 2024
4aca7b0
remove label attribute
liorocks2 May 23, 2024
7eaf6ac
svg fill removed from navigation
liorocks2 May 23, 2024
8b0a65f
fix fieldgroup import
liorocks2 May 23, 2024
2165904
refactor error, success and trashed messages
liorocks2 May 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
APP_NAME=Laravel
APP_NAME="Ping CRM"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
Expand Down
14 changes: 13 additions & 1 deletion app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ public function create(): Response

public function store(UserStoreRequest $request): RedirectResponse
{
Auth::user()->account->users()->create(
$user = Auth::user()->account->users()->create(
$request->validated()
);

if ($request->hasFile('photo')) {
$user->update([
'photo' => $request->file('photo')->store('users'),
]);
}

return Redirect::route('users')->with('success', 'User created.');
}

Expand All @@ -58,6 +64,12 @@ public function update(User $user, UserUpdateRequest $request): RedirectResponse
$request->validated()
);

if ($request->hasFile('photo')) {
$user->update([
'photo' => $request->file('photo')->store('users'),
]);
}

return Redirect::back()->with('success', 'User updated.');
}

Expand Down
11 changes: 8 additions & 3 deletions app/Http/Resources/UserCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ class UserCollection extends ResourceCollection
*/
public function toArray($request)
{
return $this->collection->map->only(
'id', 'name', 'email', 'owner', 'photo', 'deleted_at'
);
return $this->collection->map(fn ($user) => [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'owner' => $user->owner,
'photo' => $user->photo ? url()->route('image', ['path' => $user->photo, 'w' => 60, 'h' => 60, 'fit' => 'crop']) : null,
'deleted_at' => $user->deleted_at,
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function toArray($request)
'name' => $this->name,
'email' => $this->email,
'owner' => $this->owner,
'photo' => $this->photo,
'photo' => $this->photo ? url()->route('image', ['path' => $this->photo, 'w' => 60, 'h' => 60, 'fit' => 'crop']) : null,
'deleted_at' => $this->deleted_at,
'account' => $this->whenLoaded('account'),
];
Expand Down
3 changes: 3 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ class User extends Authenticatable
*/
protected $fillable = [
'name',
'first_name',
'last_name',
'email',
'password',
'photo',
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function up(): void
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->boolean('owner')->default(false);
$table->string('photo_path', 100)->nullable();
$table->string('photo', 100)->nullable();
$table->rememberToken();
$table->timestamps();
$table->softDeletes();
Expand Down
8 changes: 0 additions & 8 deletions jsconfig.json

This file was deleted.

127 changes: 94 additions & 33 deletions package-lock.json

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

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@
"cross-env": "^7.0.3",
"eslint": "^8.32.0",
"lodash": "^4.17.21",
"lucide-react": "^0.378.0",
"postcss-import": "^15.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-use": "^17.4.0",
"tailwindcss": "^3.4.3"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.7",
"@types/lodash": "^4.17.4",
"@types/node": "^20.12.12",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint-plugin-react": "^7.32.1",
"laravel-vite-plugin": "^1.0.4",
"postcss": "^8.4.21",
"typescript": "^5.4.5",
"vite": "^5.2.11"
}
}
2 changes: 1 addition & 1 deletion resources/css/app.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import 'components/form';
/* @import 'components/form'; */
@import 'components/button';

@tailwind base;
Expand Down
50 changes: 50 additions & 0 deletions resources/js/Components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { Check, CircleX, TriangleAlert } from 'lucide-react';
import CloseButton from '@/Components/Button/CloseButton';

interface Alert {
message: string;
icon?: React.ReactNode;
action?: React.ReactNode;
onClose?: () => void;
variant?: 'success' | 'error' | 'warning';
}

export default function Alert({
icon,
action,
message,
variant,
onClose
}: Alert) {
const color = {
success: 'green',
error: 'red',
warning: 'yellow'
}[variant || 'success'];

const backGroundColor = {
success: 'bg-green-500 text-white',
error: 'bg-red-500 text-white',
warning: 'bg-yellow-500 text-yellow-800'
}[variant || 'success'];

const iconComponent = {
success: <Check size={20} />,
error: <CircleX size={20} />,
warning: <TriangleAlert size={20} />
}[variant || 'success'];

return (
<div
className={`${backGroundColor} px-4 mb-8 flex items-center justify-between rounded max-w-3xl`}
>
<div className="flex items-center space-x-2">
{icon || iconComponent}
<div className="py-4 text-sm font-medium">{message}</div>
</div>
{action}
{onClose && <CloseButton onClick={onClose} color={color} />}
</div>
);
}
Loading
Loading