# Conflicts:
#	pages/api/account/index.js
This commit is contained in:
Mike Cao 2022-10-03 17:17:53 -07:00
commit d784b2a8db
31 changed files with 178 additions and 149 deletions

View file

@ -11,7 +11,7 @@ import useDateRange from 'hooks/useDateRange';
function RefreshButton({ websiteId }) {
const [dateRange] = useDateRange(websiteId);
const [loading, setLoading] = useState(false);
const selector = useCallback(state => state[`/website/${websiteId}/stats`], [websiteId]);
const selector = useCallback(state => state[`/websites/${websiteId}/stats`], [websiteId]);
const completed = useStore(selector);
function handleClick() {

View file

@ -34,7 +34,7 @@ export default function AccountEditForm({ values, onSave, onClose }) {
const handleSubmit = async values => {
const { user_id } = values;
const { ok, data } = await post(user_id ? `/account/${user_id}` : '/account', values);
const { ok, data } = await post(user_id ? `/accounts/${user_id}` : '/accounts', values);
if (ok) {
onSave();

View file

@ -9,6 +9,7 @@ import FormLayout, {
FormRow,
} from 'components/layout/FormLayout';
import useApi from 'hooks/useApi';
import useUser from '../../hooks/useUser';
const initialValues = {
current_password: '',
@ -39,9 +40,10 @@ const validate = ({ current_password, new_password, confirm_password }) => {
export default function ChangePasswordForm({ values, onSave, onClose }) {
const { post } = useApi();
const [message, setMessage] = useState();
const { user } = useUser();
const handleSubmit = async values => {
const { ok, data } = await post('/account/password', values);
const { ok, data } = await post(`/accounts/${user.user_id}/password`, values);
if (ok) {
onSave();

View file

@ -38,7 +38,6 @@ const validate = ({ name, domain }) => {
};
const OwnerDropDown = ({ user, accounts }) => {
console.info(styles);
const { setFieldValue, values } = useFormikContext();
useEffect(() => {
@ -79,7 +78,8 @@ export default function WebsiteEditForm({ values, onSave, onClose }) {
const [message, setMessage] = useState();
const handleSubmit = async values => {
const { ok, data } = await post('/website', values);
const { website_id } = values;
const { ok, data } = await post(website_id ? `/websites/${website_id}` : '/websites', values);
if (ok) {
onSave();
@ -137,6 +137,7 @@ export default function WebsiteEditForm({ values, onSave, onClose }) {
defaultMessage="Enable share URL"
/>
}
value={null}
/>
)}
</Field>

View file

@ -6,7 +6,7 @@ import Dot from 'components/common/Dot';
import styles from './ActiveUsers.module.css';
export default function ActiveUsers({ websiteId, className, value, interval = 60000 }) {
const url = websiteId ? `/website/${websiteId}/active` : null;
const url = websiteId ? `/websites/${websiteId}/active` : null;
const { data } = useFetch(url, {
interval,
});

View file

@ -16,7 +16,7 @@ export default function EventsChart({ websiteId, className, token }) {
} = usePageQuery();
const { data, loading } = useFetch(
`/website/${websiteId}/events`,
`/websites/${websiteId}/events`,
{
params: {
start_at: +startDate,

View file

@ -19,7 +19,7 @@ export default function MetricsBar({ websiteId, className }) {
} = usePageQuery();
const { data, error, loading } = useFetch(
`/website/${websiteId}/stats`,
`/websites/${websiteId}/stats`,
{
params: {
start_at: +startDate,

View file

@ -38,7 +38,7 @@ export default function MetricsTable({
const { formatMessage } = useIntl();
const { data, loading, error } = useFetch(
`/website/${websiteId}/metrics`,
`/websites/${websiteId}/metrics`,
{
params: {
type,

View file

@ -35,7 +35,7 @@ export default function WebsiteChart({
const { get } = useApi();
const { data, loading, error } = useFetch(
`/website/${websiteId}/pageviews`,
`/websites/${websiteId}/pageviews`,
{
params: {
start_at: +startDate,
@ -70,7 +70,7 @@ export default function WebsiteChart({
async function handleDateChange(value) {
if (value === 'all') {
const { data, ok } = await get(`/website/${websiteId}`);
const { data, ok } = await get(`/websites/${websiteId}`);
if (ok) {
setDateRange({ value, ...getDateRangeValues(new Date(data.created_at), Date.now()) });
}

View file

@ -17,8 +17,8 @@ export default function WebsiteHeader({ websiteId, title, domain, showLink = fal
<Favicon domain={domain} />
<Link
className={styles.titleLink}
href="/website/[...id]"
as={`/website/${websiteId}/${title}`}
href="/websites/[...id]"
as={`/websites/${websiteId}/${title}`}
>
<OverflowText tooltipId={`${websiteId}-title`}>{title}</OverflowText>
</Link>
@ -41,8 +41,8 @@ export default function WebsiteHeader({ websiteId, title, domain, showLink = fal
<RefreshButton websiteId={websiteId} />
{showLink && (
<Link
href="/website/[...id]"
as={`/website/${websiteId}/${title}`}
href="/websites/[...id]"
as={`/websites/${websiteId}/${title}`}
className={styles.link}
icon={<Arrow />}
size="small"

View file

@ -52,7 +52,7 @@ const views = {
};
export default function WebsiteDetails({ websiteId }) {
const { data } = useFetch(`/website/${websiteId}`);
const { data } = useFetch(`/websites/${websiteId}`);
const [chartLoaded, setChartLoaded] = useState(false);
const [countryData, setCountryData] = useState();
const [eventsData, setEventsData] = useState();

View file

@ -86,8 +86,8 @@ export default function WebsiteSettings() {
const DetailsLink = ({ website_id, name, domain }) => (
<Link
className={styles.detailLink}
href="/website/[...id]"
as={`/website/${website_id}/${name}`}
href="/websites/[...id]"
as={`/websites/${website_id}/${name}`}
>
<Favicon domain={domain} />
<OverflowText tooltipId={`${website_id}-name`}>{name}</OverflowText>