Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow user to change his password/email/name #20

Closed
wants to merge 13 commits into from

Conversation

AdiPol1359
Copy link

Fixes #18
image

@render
Copy link

render bot commented Jan 16, 2023

@@ -13,7 +13,7 @@ export const Input = forwardRef<
<label className="block text-sm font-medium text-gray-700">
{children}
</label>
<div className="relative mt-1 rounded-md shadow-sm">
<div className="relative rounded-md shadow-sm">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check login and register page and other places where input is used, to check if something is illegible

readonly initValue?: string;
}

export const UserSettingsRow = ({
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use memo here, please check CONTRIBUTING for component structure

initValue,
}: UserSettingsRowProps) => {
const [value, setValue] = useState(initValue);
const [editMode, setEditMode] = useState(false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isEditMode or isEditing

</>
}
/>
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's basically going on here? We should stick with our row structure and modify content from props, but all content and probably it should be determined by isEditing mode flag

readonly children: ReactNode;
}

export const Action = ({ onClick, children }: ActionProps) => (
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have Button component? Is it different?

</li>
);

SettingsRow.Action = Action;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why that way?

onChange={handleSelectChange}
>
{labels.map((label, i) => (
<option key={i} value={i}>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't pass index as a key

<Tabs labels={labels} index={activeTab} onChange={setActiveTab} />

{panels.map((panel, index) => (
<Tabs.Panel key={index} index={index} value={activeTab}>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use index, what's value?

Settings
</h2>

<Tabs labels={labels} index={activeTab} onChange={setActiveTab} />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's labels? they should be named tabs I guess

key={i}
className={twMerge(
"cursor-pointer whitespace-nowrap border-b-2 py-4 px-1 text-sm font-medium",
i === index
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we should change active tab based on url param:
/settings -> general active
/settings/notifications -> notifications active etc.


import type { HTMLAttributes } from "react";

const variants = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be enum probably

};

type HeadingProps = Readonly<{
level?: keyof typeof variants;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why level is optional? And why we are passing 1 as default value?

<h2 className="text-lg font-medium leading-6 text-gray-900">
All feeds
</h2>
<Heading level={3}>All feeds</Heading>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's level 3 for example? I guess that our main title should be h1 indeed

@@ -141,9 +140,9 @@ export const HomeView = () => {
</div>

<section className="mx-auto mt-10 max-w-6xl sm:px-6 lg:mt-12 lg:px-8">
<h2 className="px-4 text-lg font-medium leading-6 text-gray-900 sm:px-0">
<Heading level={3} className="px-4 sm:px-0">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our headings order is completely inappropriate here

readonly onChange: (content: string) => void;
}

export const SettingsRow = ({
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this component in /settings folder

<div className="grow text-gray-800">
{isEditMode ? (
<Input
type={contentType ?? "text"}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default value?

label: "General",
pathname: "/dashboard/settings",
},
];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make /settings folder, move all components related to it there (without Settings prefix) and move something like this to consts file in /config

import { Heading } from "../heading/Heading";
import { SettingsRow } from "../settingsRow/SettingsRow";

export const GeneralTab = () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tab?

"mt-1 flex items-start sm:col-span-2 sm:mt-0 sm:items-center";
export const LEFT_SECTION_STYLES = "grow text-gray-800";
export const RIGHT_SECTION_STYLES =
"ml-2.5 flex h-full flex-shrink-0 flex-col items-stretch gap-1 font-medium sm:flex-row sm:items-center";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why consts? Just put it into element directly

onInvalid?: SubmitErrorHandler<TypeOf<T>>;
}

export const useYupForm = <T extends ZodType>(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this hook? And we are not using Yup in our app, btw

readonly children: ReactNode;
}

export const Panel = ({ index, value, children }: PanelProps) =>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what we need this component?

readonly label: string;
readonly schema: ZodObject<{ content: ZodString }>;
readonly contentType: HTMLInputTypeAttribute;
readonly content?: string;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

content is optional?

@AdiPol1359 AdiPol1359 deleted the 18-update-user-data branch April 23, 2023 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow user to change his password/email/name - settings view
2 participants