-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edit announcement and contact card (#199)
* Adding google maps package * Set secret path for docker swar * Debugging secrets * Debugging secrets * Debugging secrets * Backend secret backend setted up * Backend secret backend setted up v2 * Backend secret backend setted up v3 * Backend secret backend setted up v4 * Switch to UV for dependency and venv management * Remove GitHub uv cache * Missing dependencies * powershell -> pwsh * group tools vs stubs in dev dependencies * sync djangorestframework-stubs higher * Fix standalone isntaller to actually use Unix command * try adding bin to path * Add ref to astral-sh/uv#5964 * Remove dependency on pytz * Edit Contact works fine * Adding links edition , TODO add error validation * Announcement edition OK , still TODO: error handling * Fixing some html keys duplication * Cardinal edit site fixed * WIP * Fix adress * Error handling OK, TODO : Translation * Translations OK * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixing lint and few build errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixing mypy and pyrights warns * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Line to long for ruff ><' * Possibility to generate spec file by cli * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Rollbacking some mistakes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Ruff don't like bare exception, it is not really needed * Build test * Regenerating package.lock * Revert "Possibility to generate spec file by cli" This reverts commit 000da46. * Update package-lock * Update canopeum_frontend/src/components/analytics/site-modal/SiteModal.tsx Co-authored-by: Samuel T. <samuel.therrien@beslogic.com> * Update canopeum_frontend/src/components/analytics/site-modal/SiteModal.tsx Co-authored-by: Samuel T. <samuel.therrien@beslogic.com> * Update canopeum_backend/canopeum_backend/views.py Co-authored-by: Samuel T. <samuel.therrien@beslogic.com> * Rollback config database changes, opening another PR for these * Removing indexing list because unecessary since dev test previously created same treetype on a single batch but shouldn't * Simplifying things * Lint autofix * Mass linting * Reason mandatory onCancel SiteModal + Bringing back StrictMode * Update canopeum_frontend/src/components/social/AnnouncementCard.tsx Co-authored-by: Samuel T. <samuel.therrien@beslogic.com> * Update canopeum_frontend/src/components/social/AnnouncementCard.tsx Co-authored-by: Samuel T. <samuel.therrien@beslogic.com> * Rolling back to fit dprint requirements + deletion of requirement.txt --------- Co-authored-by: Theo Auffeuvre <theo.auffeuvre@beslogic.com> Co-authored-by: Samuel Therrien <samuel.therrien@beslogic.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5eb5bd5
commit 2647b45
Showing
30 changed files
with
672 additions
and
151 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
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 was deleted.
Oops, something went wrong.
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
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
44 changes: 44 additions & 0 deletions
44
canopeum_frontend/src/components/inputs/EmailTextField.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { type FC, type InputHTMLAttributes, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { isValidEmail } from '@utils/validators' | ||
|
||
type Props = { | ||
readonly value: string | undefined, | ||
readonly attributes?: InputHTMLAttributes<HTMLInputElement>, | ||
readonly onChange: (value: string) => void, | ||
readonly isValid: (valid: boolean) => void, | ||
} | ||
|
||
const EmailTextField: FC<Props> = props => { | ||
const { t } = useTranslation() | ||
const [error, setError] = useState<string | null>(null) | ||
|
||
const handleChange = (value: string) => { | ||
if (value && !isValidEmail(value)) { | ||
setError(t('errors.email-invalid')) | ||
props.isValid(false) | ||
} else { | ||
setError(null) | ||
props.isValid(true) | ||
} | ||
|
||
props.onChange(value) | ||
} | ||
|
||
return ( | ||
<div className='d-flex flex-column flex-grow-1'> | ||
{/* eslint-disable react/jsx-props-no-spreading -- Needed for custom input */} | ||
<input | ||
{...props.attributes} | ||
onChange={event => handleChange(event.target.value)} | ||
type='email' | ||
value={props.value} | ||
/> | ||
{/* eslint-enable react/jsx-props-no-spreading */} | ||
{error && <span className='help-block text-danger'>{error}</span>} | ||
</div> | ||
) | ||
} | ||
|
||
export default EmailTextField |
44 changes: 44 additions & 0 deletions
44
canopeum_frontend/src/components/inputs/PhoneTextField.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { type FC, type InputHTMLAttributes, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { isValidPhone } from '@utils/validators' | ||
|
||
type Props = { | ||
readonly value: string | undefined, | ||
readonly attributes?: InputHTMLAttributes<HTMLInputElement>, | ||
readonly onChange: (value: string) => void, | ||
readonly isValid: (valid: boolean) => void, | ||
} | ||
|
||
const PhoneTextField: FC<Props> = props => { | ||
const { t } = useTranslation() | ||
const [error, setError] = useState<string | null>(null) | ||
|
||
const handleChange = (value: string) => { | ||
if (value && !isValidPhone(value)) { | ||
setError(t('errors.phone-invalid')) | ||
props.isValid(false) | ||
} else { | ||
setError(null) | ||
props.isValid(true) | ||
} | ||
|
||
props.onChange(value) | ||
} | ||
|
||
return ( | ||
<div className='d-flex flex-column flex-grow-1'> | ||
{/* eslint-disable react/jsx-props-no-spreading -- Needed for custom input */} | ||
<input | ||
{...props.attributes} | ||
onChange={event => handleChange(event.target.value)} | ||
type='tel' | ||
value={props.value} | ||
/> | ||
{/* eslint-enable react/jsx-props-no-spreading */} | ||
{error && <span className='help-block text-danger'>{error}</span>} | ||
</div> | ||
) | ||
} | ||
|
||
export default PhoneTextField |
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,44 @@ | ||
import { type FC, type InputHTMLAttributes, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { isValidUrl } from '@utils/validators' | ||
|
||
type Props = { | ||
readonly value: string | undefined, | ||
readonly attributes?: InputHTMLAttributes<HTMLInputElement>, | ||
readonly onChange: (value: string) => void, | ||
readonly isValid: (valid: boolean) => void, | ||
} | ||
|
||
const UrlTextField: FC<Props> = props => { | ||
const { t } = useTranslation() | ||
const [error, setError] = useState<string | null>(null) | ||
|
||
const handleChange = (value: string) => { | ||
if (value && !isValidUrl(value)) { | ||
setError(t('errors.url-invalid')) | ||
props.isValid(false) | ||
} else { | ||
setError(null) | ||
props.isValid(true) | ||
} | ||
|
||
props.onChange(value) | ||
} | ||
|
||
return ( | ||
<div className='d-flex flex-column flex-grow-1'> | ||
{/* eslint-disable react/jsx-props-no-spreading -- Needed for custom input */} | ||
<input | ||
{...props.attributes} | ||
onChange={event => handleChange(event.target.value)} | ||
type='url' | ||
value={props.value} | ||
/> | ||
{/* eslint-enable react/jsx-props-no-spreading */} | ||
{error && <span className='help-block text-danger'>{error}</span>} | ||
</div> | ||
) | ||
} | ||
|
||
export default UrlTextField |
57 changes: 57 additions & 0 deletions
57
canopeum_frontend/src/components/social/AnnouncementCard.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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useState } from 'react' | ||
import { Link } from 'react-router-dom' | ||
|
||
import SiteAnnouncementModal from '@components/social/site-modal/SiteAnnouncementModal' | ||
import type { PageViewMode } from '@models/types/PageViewMode.Type' | ||
import type { Announcement } from '@services/api' | ||
|
||
type Props = { | ||
readonly announcement: Announcement, | ||
readonly viewMode: PageViewMode, | ||
readonly onEdit: (announcement: Announcement) => void, | ||
} | ||
|
||
const AnnouncementCard = ({ announcement, viewMode, onEdit }: Props) => { | ||
const [isModalOpen, setIsModalOpen] = useState(false) | ||
|
||
return ( | ||
<> | ||
<div className='card rounded'> | ||
<div className='card-body'> | ||
<div className='d-flex justify-content-between align-items-center pb-3'> | ||
<h2 className='card-title'>Announcement</h2> | ||
<div> | ||
{viewMode === 'admin' && ( | ||
<button | ||
className='material-symbols-outlined text-primary fs-2' | ||
onClick={() => setIsModalOpen(!isModalOpen)} | ||
type='button' | ||
> | ||
edit_square | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
<p className='card-text text-justify'> | ||
{announcement.body} | ||
</p> | ||
{announcement.link && ( | ||
<Link className='card-text' target='_blank' to={{ pathname: announcement.link }}> | ||
{announcement.link} | ||
</Link> | ||
)} | ||
</div> | ||
</div> | ||
<SiteAnnouncementModal | ||
announcement={announcement} | ||
handleClose={(newAnnouncement: Announcement | null): void => { | ||
setIsModalOpen(!isModalOpen) | ||
if (newAnnouncement) onEdit(newAnnouncement) | ||
}} | ||
isOpen={isModalOpen} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default AnnouncementCard |
Oops, something went wrong.