package cast

import (
	"fmt"
	"fonchain-fiee/pkg/service"
	"net/url"

	"github.com/gin-gonic/gin"
)

func TikTokRedirect(ctx *gin.Context) {
	var state, decodeParams, code string
	var err error
	var values url.Values
	fmt.Println(code)
	state = ctx.Query("state")
	decodeParams, err = url.QueryUnescape(state)
	values, err = url.ParseQuery(decodeParams)
	if err != nil {
		service.Error(ctx, err)
		return
	}
	switch values.Get("source") {
	case "authcode":
		code = ctx.Query("code")
		/*resp, _err := service.CastProvider.OAuthTikTokToken(ctx, &cast.OAuthTikTokTokenReq{
			Code:   code,
			UserID: values.Get("userid"),
		})
		if _err != nil {
			service.Error(ctx, _err)
			return
		}
		service.Success(ctx, resp)*/
	}

	return
}
