feat: color picker

This commit is contained in:
Nevo David 2024-07-14 15:31:23 +07:00
parent 2a1efdd96e
commit 977c9ef3c8
2 changed files with 5 additions and 4 deletions

View File

@ -5,9 +5,11 @@ import { APPROVED_SUBMIT_FOR_ORDER, Post, State } from '@prisma/client';
import { GetPostsDto } from '@gitroom/nestjs-libraries/dtos/posts/get.posts.dto';
import dayjs from 'dayjs';
import isoWeek from 'dayjs/plugin/isoWeek';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import { v4 as uuidv4 } from 'uuid';
dayjs.extend(isoWeek);
dayjs.extend(weekOfYear);
@Injectable()
export class PostsRepository {
@ -61,12 +63,11 @@ export class PostsRepository {
}
getPosts(orgId: string, query: GetPostsDto) {
const date = dayjs().year(query.year).isoWeek(query.week);
const date = dayjs().year(query.year).week(query.week);
const startDate = date.startOf('week').toDate();
const endDate = date.endOf('week').toDate();
console.log(startDate, endDate);
return this._post.model.post.findMany({
where: {
OR: [

View File

@ -1,8 +1,8 @@
import { FC, useCallback, useState } from 'react';
import { Button } from './button';
import { HexColorPicker } from 'react-colorful';
import { useFormContext } from 'react-hook-form';
import interClass from '../helpers/inter.font';
import { Button } from './button';
export const ColorPicker: FC<{
name: string;
@ -12,9 +12,9 @@ export const ColorPicker: FC<{
}> = (props) => {
const { name, label, enabled, canBeCancelled } = props;
const form = useFormContext();
const [enabledState, setEnabledState] = useState(enabled);
const color = form.register(name);
const watch = form.watch(name);
const [enabledState, setEnabledState] = useState(!!watch);
const enable = useCallback(async () => {
await color.onChange({ target: { name, value: '#FFFFFF' } });