Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
DO NOT USE THIS CODE, IT IS JUST VERY WRONG BUT I WANTED TO DOCUMENT IT
Browse files Browse the repository at this point in the history
  • Loading branch information
pdp32147 committed Mar 20, 2024
1 parent 65d7830 commit b91749f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 16 deletions.
26 changes: 25 additions & 1 deletion src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,31 @@ export class Api<
type: ContentType.Json,
format: 'json',
...params
})
}),

/**
* @description a user me.
*
* @tags User
* @name v1UserUpdate
* @summary update user information
* @request PUT:/api/v1/users/me
* @secure
*/
v1UserUpdate: (
id: string,
updateUser: SchemaUpdateUser,
params: RequestParams = {}
) =>
this.request<SchemaUpdateUser, SchemaErrorResponse>({
path: `/api/v1/users/${id}`,
method: 'PUT',
body: updateUser,
secure: true,
type: ContentType.Json,
format: 'json',
...params
}),
}
misc = {
/**
Expand Down
66 changes: 52 additions & 14 deletions src/pages/EditProfile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,63 @@
import { useRequest } from 'ahooks'
import type { SchemaUserDetail } from 'client'
import type { SchemaUpdateUser, SchemaUserDetail } from 'client'
import PageContainer from 'components/PageContainer'
import type React from 'react'
import { useState } from 'react'
import { Form, Button, Col, Row, Accordion } from 'react-bootstrap'
import Backend from 'utils/service'

const UserProfileForm: React.FC = () => {
// TODO: submit update user
const { run: submit } = useRequest(async () => null)
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
submit()
}
const [user, setUser] = useState<SchemaUserDetail>()
const { loading } = useRequest(async () => Backend.user.v1UsersMeList(), {
onSuccess: res => {
setUser(res.data)
const UserProfileForm: React.FC<{
key: string
updateUser: SchemaUpdateUser
refresh: () => void
}>= ({ key, updateUser, refresh }) => {
const [show, setShow] = useState(false)
const handleClose = () => setShow(false)
const handleShow = () => setShow(true)
const [address, setAddress] = useState(updateUser.address)
const [address2,setAddress2] = useState(updateUser.address2)
const [card_address,setCard_address] = useState(updateUser.card_address)
const [card_address2,setCard_address2] = useState(updateUser.card_address2)
const [card_city, setCard_city] = useState(updateUser.card_city)
const [card_expiration, setCard_expiration] = useState(updateUser.card_expiration)
const [card_number, setCard_number] = useState(updateUser.card_number)
const [card_state, setCard_state] = useState(updateUser.card_state)
const [card_type, setCard_type] = useState(updateUser.card_type)
const [card_zip, setCard_zip] = useState(updateUser.card_zip)
const [city, setCity] = useState(updateUser.city)
const [name, setName] = useState(updateUser.name)
const [need_promotion, setNeed_promotion] = useState(updateUser.need_promotion)
const { run: submit } = useRequest(
async () => {
Backend.user.v1UserUpdate(updateUser.username, {
address,
address2,
card_address,
card_address2,
card_city,
card_expiration,
card_number,
card_state,
card_type,
card_zip,
city,
name,
need_promotion,
password: '',
phone: '',
state: '',
username: '',
zip: ''
})
},
{
manual: true,
onSuccess: () => {
refresh()
handleClose()
}
}
})

)
return (
<>
<div className='text-center'>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MovieManage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ const Index: React.FC = () => {
create()
}}
>
Create
Create!!
</Button>
</Modal.Footer>
</Modal>
Expand Down

0 comments on commit b91749f

Please sign in to comment.