-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: complete implementation of classroom reservation (#574)
* refactor(minor): changed date and time format in formData * feat: reservation record to database * feat: managing reservations * feat: full features of reservation
- Loading branch information
Showing
28 changed files
with
17,754 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
const enums = { | ||
days: { | ||
values: [ | ||
'SUNDAY', | ||
'MONDAY', | ||
'TUESDAY', | ||
'WEDNESDAY', | ||
'THURSDAY', | ||
'FRIDAY', | ||
'SATURDAY', | ||
], | ||
map: { | ||
SUNDAY: '周日', | ||
MONDAY: '周一', | ||
TUESDAY: '周二', | ||
WEDNESDAY: '周三', | ||
THURSDAY: '周四', | ||
FRIDAY: '周五', | ||
SATURDAY: '周六', | ||
}, | ||
}, | ||
periods: { | ||
values: [ | ||
'MORNING', | ||
'ONE', | ||
'TWO', | ||
'THREE', | ||
'FOUR', | ||
'NOON', | ||
'FIVE', | ||
'SIX', | ||
'SEVEN', | ||
'EIGHT', | ||
'NINE', | ||
'AFTERCLASS', | ||
], | ||
map: { | ||
MORNING: '早读', | ||
ONE: '第 1 节课', | ||
TWO: '第 2 节课', | ||
THREE: '第 3 节课', | ||
FOUR: '第 4 节课', | ||
NOON: '午休', | ||
FIVE: '第 5 节课', | ||
SIX: '第 6 节课', | ||
SEVEN: '第 7 节课', | ||
EIGHT: '第 8 节课', | ||
NINE: '第 9 节课', | ||
AFTERCLASS: '放学后', | ||
}, | ||
}, | ||
} | ||
|
||
function time2period(hhmm: number, day: string) { | ||
const timePeriods = [ | ||
{ name: 'ONE', start: 815, end: 855 }, | ||
{ name: 'TWO', start: 855, end: 945 }, | ||
{ name: 'THREE', start: 945, end: 1035 }, | ||
{ name: 'FOUR', start: 1035, end: 1125 }, | ||
{ name: 'NOON', start: 1125, end: 1230 }, | ||
{ name: 'FIVE', start: 1230, end: 1310 }, | ||
{ name: 'SIX', start: 1310, end: 1400 }, | ||
{ name: 'SEVEN', start: 1400, end: 1450 }, | ||
{ name: 'EIGHT', start: 1450, end: 1540 }, | ||
{ name: 'NINE', start: 1540, end: 1630 }, | ||
] | ||
if (hhmm < timePeriods[0].start) { | ||
return 'MORNING' | ||
} | ||
else if (day === 'FRIDAY' && hhmm >= timePeriods[8].end) { | ||
return 'AFTERCLASS' | ||
} | ||
else if (hhmm >= timePeriods[9].end) { | ||
return 'AFTERCLASS' | ||
} | ||
else { | ||
for (const period of timePeriods) { | ||
if (period.start <= hhmm && hhmm < period.end) { | ||
return period.name | ||
} | ||
} | ||
} | ||
} | ||
|
||
export { enums, time2period } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script setup lang="ts"> | ||
import type { HTMLAttributes } from 'vue' | ||
import { type AlertVariants, alertVariants } from '.' | ||
import { cn } from '@/lib/utils' | ||
const props = defineProps<{ | ||
class?: HTMLAttributes['class'] | ||
variant?: AlertVariants['variant'] | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<div :class="cn(alertVariants({ variant }), props.class)" role="alert"> | ||
<slot /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script setup lang="ts"> | ||
import type { HTMLAttributes } from 'vue' | ||
import { cn } from '@/lib/utils' | ||
const props = defineProps<{ | ||
class?: HTMLAttributes['class'] | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<div :class="cn('text-sm [&_p]:leading-relaxed', props.class)"> | ||
<slot /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script setup lang="ts"> | ||
import type { HTMLAttributes } from 'vue' | ||
import { cn } from '@/lib/utils' | ||
const props = defineProps<{ | ||
class?: HTMLAttributes['class'] | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<h5 :class="cn('mb-1 font-medium leading-none tracking-tight', props.class)"> | ||
<slot /> | ||
</h5> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { type VariantProps, cva } from 'class-variance-authority' | ||
|
||
export { default as Alert } from './Alert.vue' | ||
export { default as AlertTitle } from './AlertTitle.vue' | ||
export { default as AlertDescription } from './AlertDescription.vue' | ||
|
||
export const alertVariants = cva( | ||
'relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7', | ||
{ | ||
variants: { | ||
variant: { | ||
default: 'bg-background text-foreground', | ||
destructive: | ||
'border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'default', | ||
}, | ||
}, | ||
) | ||
|
||
export type AlertVariants = VariantProps<typeof alertVariants> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script setup lang="ts"> | ||
import { HoverCardRoot, type HoverCardRootEmits, type HoverCardRootProps, useForwardPropsEmits } from 'radix-vue' | ||
const props = defineProps<HoverCardRootProps>() | ||
const emits = defineEmits<HoverCardRootEmits>() | ||
const forwarded = useForwardPropsEmits(props, emits) | ||
</script> | ||
|
||
<template> | ||
<HoverCardRoot v-bind="forwarded"> | ||
<slot /> | ||
</HoverCardRoot> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script setup lang="ts"> | ||
import { type HTMLAttributes, computed } from 'vue' | ||
import { | ||
HoverCardContent, | ||
type HoverCardContentProps, | ||
HoverCardPortal, | ||
useForwardProps, | ||
} from 'radix-vue' | ||
import { cn } from '@/lib/utils' | ||
const props = withDefaults( | ||
defineProps<HoverCardContentProps & { class?: HTMLAttributes['class'] }>(), | ||
{ | ||
sideOffset: 4, | ||
}, | ||
) | ||
const delegatedProps = computed(() => { | ||
const { class: _, ...delegated } = props | ||
return delegated | ||
}) | ||
const forwardedProps = useForwardProps(delegatedProps) | ||
</script> | ||
|
||
<template> | ||
<HoverCardPortal> | ||
<HoverCardContent | ||
v-bind="forwardedProps" | ||
:class=" | ||
cn( | ||
'z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', | ||
props.class, | ||
) | ||
" | ||
> | ||
<slot /> | ||
</HoverCardContent> | ||
</HoverCardPortal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script setup lang="ts"> | ||
import { HoverCardTrigger, type HoverCardTriggerProps } from 'radix-vue' | ||
const props = defineProps<HoverCardTriggerProps>() | ||
</script> | ||
|
||
<template> | ||
<HoverCardTrigger v-bind="props"> | ||
<slot /> | ||
</HoverCardTrigger> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as HoverCard } from './HoverCard.vue' | ||
export { default as HoverCardTrigger } from './HoverCardTrigger.vue' | ||
export { default as HoverCardContent } from './HoverCardContent.vue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
id,name,alias,size | ||
1,C201,中教室,24 | ||
2,C202,中教室,20 | ||
3,C203,中教室,24 | ||
4,C204,中教室,28 | ||
5,C207,大教室,52 | ||
6,C208,大教室,38 | ||
7,C302,小教室,16 | ||
8,C309,中教室,24 | ||
9,C308,大教室,38 | ||
10,D102,大教室,36 | ||
11,B201,音乐教室,16 | ||
12,B303,形体房,0 | ||
13,A112,小教室,16 | ||
14,A310,小教室,16 | ||
15,A409,中教室,26 | ||
16,A410,小教室,16 | ||
17,A309,中教室,24 | ||
18,A509,小教室,16 | ||
19,A206,中教室,24 | ||
20,A201,,0 | ||
21,C304,,0 | ||
22,C307,,0 | ||
23,操场,靠近旗杆,0 | ||
24,操场,操场中间,0 | ||
25,操场,靠近雨棚,0 | ||
26,旗杆边排球场,,0 | ||
27,动感单车边场地,,0 | ||
28,学校耕地,,0 | ||
29,学生事务中心前空地,,0 | ||
30,教工休息室旁乒乓桌,,0 |
Oops, something went wrong.