feat: report issue popup (#261)

* feat: report issue popup

* style: modified styles in feedback form

* chore: minor UI fixes

* chore: update useEffect

* chore: change width to 400px

---------

Co-authored-by: doprz <52579214+doprz@users.noreply.github.com>
Co-authored-by: Isaiah David Rodriguez <51803892+IsaDavRod@users.noreply.github.com>
This commit is contained in:
Sriram Hariharan
2024-10-12 20:31:26 -05:00
committed by GitHub
parent bd17e33537
commit 65ff6bfbbf
14 changed files with 1855 additions and 989 deletions

View File

@@ -1,8 +1,6 @@
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';
import { generateRandomId } from '@shared/util/random';
import handleDuplicate from './handleDuplicate';
/**
* Creates a new schedule with the given name
* @param scheduleName the name of the schedule to create
@@ -10,13 +8,23 @@ import handleDuplicate from './handleDuplicate';
*/
export default async function createSchedule(scheduleName: string): Promise<string | undefined> {
const schedules = await UserScheduleStore.get('schedules');
// get the number of schedules that either have the same name or have the same name with a number appended (e.g. "New Schedule (1)")
// this way we can prevent duplicate schedule names and increment the number if necessary
// Duplicate schedule found, we need to append a number to the end of the schedule name
const updatedName = await handleDuplicate(scheduleName);
// Regex to match schedule names that follow the pattern "ScheduleName" or "ScheduleName (1)", "ScheduleName (2)", etc.
const regex = new RegExp(`^${scheduleName}( \\(\\d+\\))?$`);
// Find how many schedules match the base name or follow the pattern with a number
const count = schedules.filter(s => regex.test(s.name)).length;
// If any matches are found, append the next number to the schedule name
let name = scheduleName;
if (count > 0) {
name = `${scheduleName} (${count})`;
}
schedules.push({
id: generateRandomId(),
name: updatedName,
name,
courses: [],
hours: 0,
updatedAt: Date.now(),

View File

@@ -9,7 +9,7 @@
body {
margin: 0;
padding: 0;
width: 360px;
width: 400px;
height: 540px;
}
</style>

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>UTRP Report Issue</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="./index.tsx" type="module"></script>
</body>
</html>

View File

@@ -0,0 +1,5 @@
import ReportIssueMain from '@views/components/ReportIssueMain';
import React from 'react';
import { createRoot } from 'react-dom/client';
createRoot(document.getElementById('root')!).render(<ReportIssueMain />);