fix(linkedin): show connected company page on the accounts and onboarding grids
The unified LinkedIn card grouped connected accounts by looking the platform up in the rendered card list, but linkedin-page is no longer a card — so an org-only connection fell through to its own network key and the card showed 'Connect' for an already-connected page, with no way to disconnect or reconnect. Expose each account's network on SocialAccountResource and group by account.network instead. Onboarding still built its connect grid from SocialPlatform::enabled() instead of isConnectable(), so it rendered a standalone LinkedIn Page card with a missing logo whose connect button hit the deleted connect/linkedin-page route (404). Filter by isConnectable() to match the accounts page.
This commit is contained in:
parent
d84666360a
commit
dec2bc028a
5 changed files with 31 additions and 14 deletions
|
|
@ -86,12 +86,14 @@ public function connect(Request $request): Response|RedirectResponse
|
|||
|
||||
$accounts = $workspace->socialAccounts()->orderBy('id')->get();
|
||||
|
||||
$platforms = collect(SocialPlatform::enabled())->map(fn (SocialPlatform $platform): array => [
|
||||
'value' => $platform->value,
|
||||
'label' => $platform->label(),
|
||||
'color' => $platform->color(),
|
||||
'network' => $platform->network(),
|
||||
])->values();
|
||||
$platforms = collect(SocialPlatform::cases())
|
||||
->filter(fn (SocialPlatform $platform): bool => $platform->isConnectable())
|
||||
->map(fn (SocialPlatform $platform): array => [
|
||||
'value' => $platform->value,
|
||||
'label' => $platform->label(),
|
||||
'color' => $platform->color(),
|
||||
'network' => $platform->network(),
|
||||
])->values();
|
||||
|
||||
return Inertia::render('onboarding/Connect', [
|
||||
'platforms' => $platforms,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public function toArray(Request $request): array
|
|||
return [
|
||||
'id' => $this->id,
|
||||
'platform' => $this->platform,
|
||||
'network' => $this->platform->network(),
|
||||
'platform_user_id' => $this->platform_user_id,
|
||||
'username' => $this->username,
|
||||
'display_name' => $this->display_name,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export interface AvailablePlatform {
|
|||
export interface ConnectedAccount {
|
||||
id: string;
|
||||
platform: string;
|
||||
network: string;
|
||||
username: string;
|
||||
display_name: string;
|
||||
avatar_url: string | null;
|
||||
|
|
@ -120,20 +121,14 @@ const platformTheme: Record<
|
|||
const themeFor = (value: string) =>
|
||||
platformTheme[value] ?? { bg: 'bg-muted', rotate: '', image: '' };
|
||||
|
||||
const networkOf = (value: string): string =>
|
||||
props.platforms.find((platform) => platform.value === value)?.network ??
|
||||
value;
|
||||
|
||||
// One account per network: map each connected network to its account so every
|
||||
// platform card belonging to that network reflects the connection.
|
||||
const connectedByNetwork = computed((): Record<string, ConnectedAccount> => {
|
||||
const map: Record<string, ConnectedAccount> = {};
|
||||
|
||||
for (const account of props.connectedAccounts) {
|
||||
const network = networkOf(account.platform);
|
||||
|
||||
if (!map[network]) {
|
||||
map[network] = account;
|
||||
if (!map[account.network]) {
|
||||
map[account.network] = account;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use App\Actions\Billing\StartSubscriptionCheckout;
|
||||
use App\Enums\Plan\Slug;
|
||||
use App\Enums\SocialAccount\Platform;
|
||||
use App\Enums\User\Persona;
|
||||
use App\Jobs\PostHog\SendEvent;
|
||||
use App\Models\Account;
|
||||
|
|
@ -135,6 +136,21 @@ function subscribeOnboardingAccount(Account $account): void
|
|||
);
|
||||
});
|
||||
|
||||
test('connect offers a single linkedin card and no standalone linkedin page card', function () {
|
||||
$this->user->update(['persona' => Persona::Agency->value]);
|
||||
onboardingWorkspace($this->user);
|
||||
|
||||
$response = $this->actingAs($this->user->fresh())->get(route('app.onboarding.connect'));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
->component('onboarding/Connect')
|
||||
->where('platforms', fn ($platforms) => collect($platforms)->contains('value', Platform::LinkedIn->value)
|
||||
&& ! collect($platforms)->contains('value', Platform::LinkedInPage->value)
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
test('connect lists the workspace social accounts already connected', function () {
|
||||
$this->user->update(['persona' => Persona::Agency->value]);
|
||||
$workspace = onboardingWorkspace($this->user);
|
||||
|
|
|
|||
|
|
@ -87,9 +87,12 @@
|
|||
$response = $this->actingAs($this->user)->get(route('app.accounts'));
|
||||
|
||||
$response->assertOk();
|
||||
// The grid groups by the account's own `network`, so a linkedin-page account
|
||||
// must report network=linkedin to surface under the single LinkedIn card.
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
->component('accounts/Index', false)
|
||||
->where('connectedAccounts.0.platform', Platform::LinkedInPage->value)
|
||||
->where('connectedAccounts.0.network', 'linkedin')
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue