refactor: change a file name (#447)

* refactor: file upload component

* refactor: changed name of a function and added a new line
This commit is contained in:
2024-11-23 00:14:49 -06:00
committed by GitHub
parent a5e921fd75
commit 3abb11734a
5 changed files with 21 additions and 26 deletions

View File

@@ -21,6 +21,7 @@ export default async function addCourse(scheduleId: string, course: Course, hasC
if (!hasColor) { if (!hasColor) {
course.colors = getUnusedColor(activeSchedule, course); course.colors = getUnusedColor(activeSchedule, course);
} }
activeSchedule.courses.push(course); activeSchedule.courses.push(course);
activeSchedule.updatedAt = Date.now(); activeSchedule.updatedAt = Date.now();
await UserScheduleStore.set('schedules', schedules); await UserScheduleStore.set('schedules', schedules);

View File

@@ -26,7 +26,6 @@ export default async function importSchedule(scheduleData: unknown): Promise<voi
const course = new Course(c); const course = new Course(c);
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await addCourse(newScheduleId, course, true); await addCourse(newScheduleId, course, true);
console.log(course.colors);
} }
console.log('Course schedule successfully parsed!'); console.log('Course schedule successfully parsed!');
} else { } else {

View File

@@ -1,21 +1,16 @@
import { colorsFlattened } from '@shared/util/themeColors'; import { colorsFlattened } from '@shared/util/themeColors';
import type { Meta, StoryObj } from '@storybook/react'; import type { Meta, StoryObj } from '@storybook/react';
import InputButton from '@views/components/common/InputButton'; import FileUpload from '@views/components/common/FileUpload';
import React from 'react'; import React from 'react';
import AddIcon from '~icons/material-symbols/add';
import CalendarMonthIcon from '~icons/material-symbols/calendar-month';
import DescriptionIcon from '~icons/material-symbols/description';
import ImagePlaceholderIcon from '~icons/material-symbols/image'; import ImagePlaceholderIcon from '~icons/material-symbols/image';
import HappyFaceIcon from '~icons/material-symbols/mood';
import ReviewsIcon from '~icons/material-symbols/reviews';
/** /**
* Stole this straight from Button.stories.tsx to test the input * Stole this straight from Button.stories.tsx to test the input
*/ */
const meta = { const meta = {
title: 'Components/Common/InputButton', title: 'Components/Common/FileUpload',
component: InputButton, component: FileUpload,
parameters: { parameters: {
layout: 'centered', layout: 'centered',
}, },
@@ -39,7 +34,7 @@ const meta = {
}, },
onChange: { action: 'file selected' }, // action to show when file is selected onChange: { action: 'file selected' }, // action to show when file is selected
}, },
} satisfies Meta<typeof InputButton>; } satisfies Meta<typeof FileUpload>;
export default meta; export default meta;
type Story = StoryObj<typeof meta>; type Story = StoryObj<typeof meta>;
@@ -64,17 +59,17 @@ export const Grid: Story = {
render: props => ( render: props => (
<div style={{ display: 'flex', flexDirection: 'column', gap: '15px' }}> <div style={{ display: 'flex', flexDirection: 'column', gap: '15px' }}>
<div style={{ display: 'flex', gap: '15px' }}> <div style={{ display: 'flex', gap: '15px' }}>
<InputButton {...props} variant='filled' color='ut-black' /> <FileUpload {...props} variant='filled' color='ut-black' />
<InputButton {...props} variant='outline' color='ut-black' /> <FileUpload {...props} variant='outline' color='ut-black' />
<InputButton {...props} variant='single' color='ut-black' /> <FileUpload {...props} variant='single' color='ut-black' />
</div> </div>
<hr /> <hr />
<div style={{ display: 'flex', gap: '15px' }}> <div style={{ display: 'flex', gap: '15px' }}>
<InputButton {...props} variant='filled' color='ut-black' disabled /> <FileUpload {...props} variant='filled' color='ut-black' disabled />
<InputButton {...props} variant='outline' color='ut-black' disabled /> <FileUpload {...props} variant='outline' color='ut-black' disabled />
<InputButton {...props} variant='single' color='ut-black' disabled /> <FileUpload {...props} variant='single' color='ut-black' disabled />
</div> </div>
</div> </div>
), ),
@@ -92,15 +87,15 @@ export const PrettyColors: Story = {
<div style={{ display: 'flex', flexDirection: 'column', gap: '15px' }}> <div style={{ display: 'flex', flexDirection: 'column', gap: '15px' }}>
{colorsNames.map(color => ( {colorsNames.map(color => (
<div style={{ display: 'flex', gap: '15px' }} key={color}> <div style={{ display: 'flex', gap: '15px' }} key={color}>
<InputButton {...props} variant='filled' color={color}> <FileUpload {...props} variant='filled' color={color}>
Button Button
</InputButton> </FileUpload>
<InputButton {...props} variant='outline' color={color}> <FileUpload {...props} variant='outline' color={color}>
Button Button
</InputButton> </FileUpload>
<InputButton {...props} variant='single' color={color}> <FileUpload {...props} variant='single' color={color}>
Button Button
</InputButton> </FileUpload>
</div> </div>
))} ))}
</div> </div>

View File

@@ -22,7 +22,7 @@ interface Props {
* *
* @returns * @returns
*/ */
export default function InputButton({ export default function FileUpload({
className, className,
style, style,
variant, variant,

View File

@@ -29,7 +29,7 @@ import IconoirGitFork from '~icons/iconoir/git-fork';
// import { ExampleCourse } from 'src/stories/components/ConflictsWithWarning.stories'; // import { ExampleCourse } from 'src/stories/components/ConflictsWithWarning.stories';
import DeleteForeverIcon from '~icons/material-symbols/delete-forever'; import DeleteForeverIcon from '~icons/material-symbols/delete-forever';
import InputButton from '../common/InputButton'; import FileUpload from '../common/FileUpload';
import { useMigrationDialog } from '../common/MigrationDialog'; import { useMigrationDialog } from '../common/MigrationDialog';
// import RefreshIcon from '~icons/material-symbols/refresh'; // import RefreshIcon from '~icons/material-symbols/refresh';
import DevMode from './DevMode'; import DevMode from './DevMode';
@@ -383,9 +383,9 @@ export default function Settings(): JSX.Element {
</Text> </Text>
<p className='text-sm text-gray-600'>Import from a schedule file</p> <p className='text-sm text-gray-600'>Import from a schedule file</p>
</div> </div>
<InputButton variant='filled' color='ut-burntorange' onChange={handleImportClick}> <FileUpload variant='filled' color='ut-burntorange' onChange={handleImportClick}>
Import Schedule Import Schedule
</InputButton> </FileUpload>
</div> </div>
<Divider size='auto' orientation='horizontal' /> <Divider size='auto' orientation='horizontal' />