Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 1 addition & 8 deletions app/Http/Controllers/Admin/SupportTicketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,7 @@ public function index(Request $request)
'category' => $category,
'search' => $search,
],
'categories' => [
SupportTicket::CATEGORY_GENERAL => 'General Inquiry',
SupportTicket::CATEGORY_BUG_REPORT => 'Bug Report',
SupportTicket::CATEGORY_MISSING_RESOURCE => 'Missing / Broken Resource',
SupportTicket::CATEGORY_ACCOUNT_ISSUE => 'Account Issue',
SupportTicket::CATEGORY_SUGGESTION => 'Suggestion / Feedback',
SupportTicket::CATEGORY_OTHER => 'Other',
],
'categories' => SupportTicket::getCategories(),
]);
}

Expand Down
20 changes: 3 additions & 17 deletions app/Http/Controllers/SupportTicketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ public function index(Request $request)
return Inertia::render('Support', [
'ticketsCount' => $ticketsCount,
'openTicketsCount' => $openTicketsCount,
'categories' => [
SupportTicket::CATEGORY_GENERAL => 'General Inquiry',
SupportTicket::CATEGORY_BUG_REPORT => 'Bug Report',
SupportTicket::CATEGORY_MISSING_RESOURCE => 'Missing / Broken Resource',
SupportTicket::CATEGORY_ACCOUNT_ISSUE => 'Account Issue',
SupportTicket::CATEGORY_SUGGESTION => 'Suggestion / Feedback',
SupportTicket::CATEGORY_OTHER => 'Other',
],
'categories' => SupportTicket::getCategories(),
]);
}

Expand All @@ -43,14 +36,7 @@ public function myTickets(Request $request)

return Inertia::render('SupportMyTickets', [
'tickets' => $tickets,
'categories' => [
SupportTicket::CATEGORY_GENERAL => 'General Inquiry',
SupportTicket::CATEGORY_BUG_REPORT => 'Bug Report',
SupportTicket::CATEGORY_MISSING_RESOURCE => 'Missing / Broken Resource',
SupportTicket::CATEGORY_ACCOUNT_ISSUE => 'Account Issue',
SupportTicket::CATEGORY_SUGGESTION => 'Suggestion / Feedback',
SupportTicket::CATEGORY_OTHER => 'Other',
],
'categories' => SupportTicket::getCategories(),
]);
}

Expand All @@ -68,7 +54,7 @@ public function store(Request $request)
}

$validated = $request->validate([
'category' => 'required|string|in:general,bug_report,missing_resource,account_issue,suggestion,other',
'category' => 'required|string|in:'.implode(',', array_keys(SupportTicket::getCategories())),
'subject' => 'required|string|min:3|max:255',
'message' => 'required|string|min:10|max:5000',
'attachment' => 'nullable|image|mimes:jpeg,png,jpg,webp|max:5120',
Expand Down
15 changes: 15 additions & 0 deletions app/Models/SupportTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class SupportTicket extends Model

public const CATEGORY_GENERAL = 'general';

public const CATEGORY_APPLY_ROLE = 'apply_role';

public const CATEGORY_BUG_REPORT = 'bug_report';

public const CATEGORY_MISSING_RESOURCE = 'missing_resource';
Expand All @@ -32,6 +34,19 @@ class SupportTicket extends Model

public const STATUS_CLOSED = 'closed';

public static function getCategories(): array
{
return [
self::CATEGORY_GENERAL => 'General Inquiry',
self::CATEGORY_APPLY_ROLE => 'Apply for Contributor Role',
self::CATEGORY_BUG_REPORT => 'Bug Report',
self::CATEGORY_MISSING_RESOURCE => 'Missing / Broken Resource',
self::CATEGORY_ACCOUNT_ISSUE => 'Account Issue',
self::CATEGORY_SUGGESTION => 'Suggestion / Feedback',
self::CATEGORY_OTHER => 'Other',
];
}

protected $fillable = [
'ticket_number',
'user_id',
Expand Down
27 changes: 23 additions & 4 deletions resources/js/pages/Support.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,38 @@ const authUser = computed<UserInfo | null>(
() => (page.props.auth?.user as UserInfo) || null,
);

const urlParams =
typeof window !== 'undefined'
? new URLSearchParams(window.location.search)
: null;

const initialCategory = urlParams?.get('category') || 'general';
const initialSubject = urlParams?.get('subject') || '';
const initialMessage = urlParams?.get('message') || '';

const form = useForm<{
category: string;
subject: string;
message: string;
attachment: File | null;
general?: string;
}>({
category: 'general',
subject: '',
message: '',
category: initialCategory,
subject: initialSubject,
message: initialMessage,
attachment: null,
});

const loginRedirectUrl = computed(() => {
if (typeof window !== 'undefined') {
const fullPath = window.location.pathname + window.location.search;

return `/login?redirect=${encodeURIComponent(fullPath)}`;
}

return '/login?redirect=/support';
});

const previewUrl = ref<string | null>(null);

const handleFileChange = (e: Event) => {
Expand Down Expand Up @@ -123,7 +142,7 @@ const submitTicket = () => {
class="mt-6 flex flex-col justify-center gap-3 sm:flex-row"
>
<Link
href="/login?redirect=/support"
:href="loginRedirectUrl"
class="inline-flex items-center justify-center gap-2 rounded-xl bg-indigo-600 px-6 py-3 text-sm font-bold text-white shadow-md shadow-indigo-200 transition-all hover:bg-indigo-700 hover:shadow-lg active:scale-95 dark:shadow-indigo-500/30"
>
<span>লগইন করুন</span>
Expand Down
Loading