@@ -15,60 +15,81 @@ class EditUser extends EditRecord
1515 protected function getHeaderActions (): array
1616 {
1717 return [
18- Actions \Action::make ('createStripeCustomer ' )
19- ->label ('Create Stripe Customer ' )
20- ->color ('gray ' )
21- ->icon ('heroicon-o-credit-card ' )
22- ->action (function (User $ record ) {
23- if ($ record ->hasStripeId ()) {
24- Notification::make ()
25- ->danger ()
26- ->title ('User is already a Stripe customer. ' )
27- ->send ();
18+ Actions \ActionGroup::make ([
19+ Actions \Action::make ('createStripeCustomer ' )
20+ ->label ('Create Stripe Customer ' )
21+ ->color ('gray ' )
22+ ->icon ('heroicon-o-credit-card ' )
23+ ->action (function (User $ record ) {
24+ if ($ record ->hasStripeId ()) {
25+ Notification::make ()
26+ ->danger ()
27+ ->title ('User is already a Stripe customer. ' )
28+ ->send ();
2829
29- return ;
30- }
30+ return ;
31+ }
3132
32- $ record ->createOrGetStripeCustomer ();
33- })
34- ->visible (fn (User $ record ) => empty ($ record ->stripe_id )),
33+ $ record ->createOrGetStripeCustomer ();
34+ })
35+ ->visible (fn (User $ record ) => empty ($ record ->stripe_id )),
3536
36- Actions \Action::make ('createAnystackLicense ' )
37- ->label ('Create Anystack License ' )
38- ->color ('gray ' )
39- ->icon ('heroicon-o-key ' )
40- ->form ([
41- \Filament \Forms \Components \Select::make ('subscription ' )
42- ->label ('Subscription Plan ' )
43- ->options (collect (\App \Enums \Subscription::cases ())->mapWithKeys (function ($ case ) {
44- return [$ case ->value => $ case ->name ()];
45- }))
46- ->required (),
47- ])
48- ->action (function (array $ data , User $ record ) {
49- $ subscription = \App \Enums \Subscription::from ($ data ['subscription ' ]);
37+ Actions \Action::make ('createAnystackLicense ' )
38+ ->label ('Create Anystack License ' )
39+ ->color ('gray ' )
40+ ->icon ('heroicon-o-key ' )
41+ ->form ([
42+ \Filament \Forms \Components \Select::make ('subscription ' )
43+ ->label ('Subscription Plan ' )
44+ ->options (collect (\App \Enums \Subscription::cases ())->mapWithKeys (function ($ case ) {
45+ return [$ case ->value => $ case ->name ()];
46+ }))
47+ ->required (),
48+ ])
49+ ->action (function (array $ data , User $ record ) {
50+ $ subscription = \App \Enums \Subscription::from ($ data ['subscription ' ]);
5051
51- \App \Jobs \CreateAnystackLicenseJob::dispatch (
52- $ record ,
53- $ subscription ,
54- null ,
55- $ record ->first_name ,
56- $ record ->last_name ,
57- );
58- }),
52+ \App \Jobs \CreateAnystackLicenseJob::dispatch (
53+ $ record ,
54+ $ subscription ,
55+ null ,
56+ $ record ->first_name ,
57+ $ record ->last_name ,
58+ );
59+ }),
5960
60- Actions \Action::make ('sendPasswordReset ' )
61- ->label ('Send Password Reset ' )
62- ->color ('gray ' )
63- ->icon ('heroicon-o-envelope ' )
64- ->requiresConfirmation ()
65- ->action (function (User $ record ) {
66- \Illuminate \Support \Facades \Password::sendResetLink (
67- ['email ' => $ record ->email ]
68- );
69- }),
61+ Actions \Action::make ('sendPasswordReset ' )
62+ ->label ('Send Password Reset ' )
63+ ->color ('gray ' )
64+ ->icon ('heroicon-o-envelope ' )
65+ ->requiresConfirmation ()
66+ ->action (function (User $ record ) {
67+ \Illuminate \Support \Facades \Password::sendResetLink (
68+ ['email ' => $ record ->email ]
69+ );
70+ }),
7071
71- Actions \DeleteAction::make (),
72+ Actions \Action::make ('view_on_stripe ' )
73+ ->label ('View on Stripe ' )
74+ ->color ('gray ' )
75+ ->icon ('heroicon-o-arrow-top-right-on-square ' )
76+ ->url (fn (User $ record ) => 'https://dashboard.stripe.com/customers/ ' .$ record ->stripe_id )
77+ ->openUrlInNewTab ()
78+ ->visible (fn (User $ record ) => filled ($ record ->stripe_id )),
79+
80+ Actions \Action::make ('view_on_anystack ' )
81+ ->label ('View on Anystack ' )
82+ ->color ('gray ' )
83+ ->icon ('heroicon-o-arrow-top-right-on-square ' )
84+ ->url (fn (User $ record ) => 'https://app.anystack.sh/contacts/ ' .$ record ->anystack_contact_id )
85+ ->openUrlInNewTab ()
86+ ->visible (fn (User $ record ) => filled ($ record ->anystack_contact_id )),
87+
88+ Actions \DeleteAction::make (),
89+
90+ ])
91+ ->label ('Actions ' )
92+ ->icon ('heroicon-m-ellipsis-vertical ' ),
7293 ];
7394 }
7495}
0 commit comments