-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
15,994 additions
and
4,719 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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"extends": ["next/core-web-vitals", "prettier"], | ||
"ignorePatterns": ["node_modules/**/*"] | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"prettier", | ||
"plugin:storybook/recommended" | ||
], | ||
"ignorePatterns": ["node_modules/**/*", "stories/**/*"] | ||
} |
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,33 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
- name: Build Next.js application | ||
run: npm run build | ||
- name: Start Next.js server | ||
run: npm run start -- -p 3000 & | ||
- name: Wait for server to be ready | ||
run: npx wait-on http://localhost:3000 | ||
- name: Run Playwright tests | ||
run: npx playwright test | ||
- uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
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 |
---|---|---|
|
@@ -41,3 +41,5 @@ next-env.d.ts | |
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
|
||
*storybook.log |
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 |
---|---|---|
@@ -1,27 +1 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
|
||
# Run ESLint with automatic fixes, and capture the result and exit code | ||
eslint_result=$(npx eslint . --fix) | ||
eslint_exit_code=$? | ||
if [ $eslint_exit_code -eq 0 ]; then | ||
printf "✅ ESLint checks passed!\n" | ||
else | ||
printf "❌ ESLint found issues that could not be automatically fixed.\n%s\n" "$eslint_result" | ||
exit 1 | ||
fi | ||
|
||
# Run Prettier with write option, capture the result and exit code | ||
prettier_result=$(npx prettier --write .) | ||
prettier_exit_code=$? | ||
if [ $prettier_exit_code -eq 0 ]; then | ||
printf "✅ Prettier formatting passed!\n" | ||
else | ||
printf "❌ Prettier found formatting issues.\n%s\n" "$prettier_result" | ||
exit 1 | ||
fi | ||
|
||
printf "✨ All checks passed! Your code is clean and formatted! ✨\n" | ||
npm run precommit |
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 |
---|---|---|
@@ -1,4 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
printf 'Husky started...\n' | ||
npm run prepush |
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,21 @@ | ||
import type { StorybookConfig } from '@storybook/nextjs'; | ||
|
||
const config: StorybookConfig = { | ||
stories: [ | ||
'../stories/**/*.mdx', | ||
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)', | ||
], | ||
addons: [ | ||
'@storybook/addon-onboarding', | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@chromatic-com/storybook', | ||
'@storybook/addon-interactions', | ||
], | ||
framework: { | ||
name: '@storybook/nextjs', | ||
options: {}, | ||
}, | ||
staticDirs: ['../public'], | ||
}; | ||
export default config; |
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 @@ | ||
import type { Preview } from '@storybook/react'; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
'use server'; | ||
|
||
import { IAddProjectForm } from '@/types/forms'; | ||
import { AddProjectFormData } from '@/types/forms'; | ||
|
||
export const addNewProject = async (data: IAddProjectForm) => { | ||
export const addNewProject = async (data: AddProjectFormData) => { | ||
console.log(data); | ||
}; |
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
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
105 changes: 87 additions & 18 deletions
105
components/Common/Modals/AddProjectmodal/FileUploader.tsx
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 |
---|---|---|
@@ -1,37 +1,106 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import { UploadIcon } from './UploadIcon'; | ||
import { UseFormRegister, FieldValues } from 'react-hook-form'; | ||
import { UseFormRegister, FieldValues, UseFormSetValue } from 'react-hook-form'; | ||
import { FormFieldRegistration } from '@/types/forms'; | ||
import { useTranslations } from 'next-intl'; | ||
|
||
const getErrorMessage = (errors: any, name: string) => { | ||
return errors?.[name]?.message || ''; | ||
}; | ||
|
||
interface FileUploaderProps extends FormFieldRegistration { | ||
register: UseFormRegister<FieldValues>; | ||
name: string; | ||
onFileChange?: UseFormSetValue<FieldValues>; | ||
errors?: FieldValues; | ||
} | ||
|
||
export const FileUploader: React.FC<FileUploaderProps> = ({ | ||
register, | ||
name, | ||
onFileChange, | ||
errors, | ||
}) => { | ||
const [fileName, setFileName] = useState(''); | ||
const t = useTranslations('Maintainers.maintainerForm'); | ||
|
||
const errorMessage = getErrorMessage(errors, name); | ||
const formProps = register(name, { required: false }); | ||
return ( | ||
<div className="flex flex-row items-center"> | ||
<p className="text-2xl whitespace-nowrap">{t('logo')}</p> | ||
<div className="ml-4 flex items-center dark:bg-gray-700 bg-gray-200 rounded-md m-auto"> | ||
<label htmlFor="file-input" className="cursor-pointer"> | ||
<input | ||
{...register(name, { required: false })} | ||
id="file-input" | ||
type="file" | ||
name={name} | ||
className="hidden" | ||
/> | ||
<div className="flex justify-center items-center rounded-md max-w-[150px]"> | ||
<UploadIcon /> | ||
</div> | ||
</label> | ||
<div> | ||
<div className="flex flex-row gap-4 items-center"> | ||
<p className="whitespace-nowrap">{t('logo')}</p> | ||
<div className="flex items-center dark:bg-gray-700 bg-gray-200 rounded-md m-auto justify-center flex-1"> | ||
<label htmlFor="file-input" className="cursor-pointer"> | ||
<input | ||
{...formProps} | ||
id="file-input" | ||
type="file" | ||
name={name} | ||
accept="image/*" | ||
className="hidden" | ||
onChange={e => { | ||
setFileName(e.target.files?.item(0)?.name || ''); | ||
formProps.onChange(e); | ||
}} | ||
/> | ||
<div className="flex justify-between items-center h-14 rounded-md w-[150px] gap-2"> | ||
{fileName ? ( | ||
<SelectedFile | ||
fileName={fileName} | ||
onCancel={() => { | ||
setFileName(''); | ||
onFileChange && | ||
onFileChange(name, null, { shouldValidate: true }); | ||
}} | ||
name={name} | ||
errors={errors} | ||
/> | ||
) : ( | ||
<div className="w-[26px] h-[26px] mx-auto"> | ||
<UploadIcon /> | ||
</div> | ||
)} | ||
</div> | ||
</label> | ||
</div> | ||
</div> | ||
{errorMessage && <p className="text-error">{errorMessage}</p>} | ||
</div> | ||
); | ||
}; | ||
|
||
interface ISelectedFiled { | ||
fileName: string; | ||
onCancel: () => void; | ||
name: string; | ||
errors?: FieldValues; | ||
} | ||
const SelectedFile = ({ fileName, onCancel, errors, name }: ISelectedFiled) => { | ||
const fileParts = fileName.split('.'); | ||
const extention = fileParts.slice(-1)[0]; | ||
const base = | ||
fileParts.length < 1 ? fileParts : fileParts.slice(0, -1).join('.'); | ||
const errorMessage = getErrorMessage(errors, name); | ||
return ( | ||
<> | ||
<span | ||
className="" | ||
onClick={e => { | ||
e.preventDefault(); | ||
onCancel(); | ||
}} | ||
> | ||
X | ||
</span> | ||
<div | ||
className="file-name flex min-w-0 justify-start" | ||
style={{ direction: 'ltr' }} | ||
> | ||
<span className="overflow-hidden whitespace-nowrap text-ellipsis"> | ||
{base} | ||
</span> | ||
<span>.{extention}</span> | ||
</div> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.